Fakultas Ilmu Komputer UI
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Gamedev Final Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ADAM GHAVIYASHA
Gamedev Final Project
Commits
e6c6f7c8
Commit
e6c6f7c8
authored
1 year ago
by
Insta-x
Browse files
Options
Downloads
Patches
Plain Diff
ammo bar
parent
904c4dc5
No related branches found
No related tags found
1 merge request
!20
main menu
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
objects/characters/grovekeeper.tscn
+33
-3
33 additions, 3 deletions
objects/characters/grovekeeper.tscn
scripts/grovekeeper.gd
+14
-2
14 additions, 2 deletions
scripts/grovekeeper.gd
with
47 additions
and
5 deletions
objects/characters/grovekeeper.tscn
+
33
−
3
View file @
e6c6f7c8
[gd_scene load_steps=2
4
format=3 uid="uid://dgtcwxlnywi84"]
[gd_scene load_steps=2
6
format=3 uid="uid://dgtcwxlnywi84"]
[ext_resource type="Script" path="res://scripts/grovekeeper.gd" id="1_75nxq"]
[ext_resource type="Shader" path="res://shaders/outline.gdshader" id="1_rvav7"]
...
...
@@ -241,6 +241,22 @@ font_size = 10
outline_size = 2
outline_color = Color(0, 0, 0, 1)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_msbq6"]
bg_color = Color(0.169245, 0.169245, 0.169245, 1)
corner_radius_top_left = 4
corner_radius_top_right = 4
corner_radius_bottom_right = 4
corner_radius_bottom_left = 4
anti_aliasing = false
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_s5c8w"]
bg_color = Color(1, 1, 0, 1)
corner_radius_top_left = 4
corner_radius_top_right = 4
corner_radius_bottom_right = 4
corner_radius_bottom_left = 4
anti_aliasing = false
[node name="Grovekeeper" type="CharacterBody2D" node_paths=PackedStringArray("hurtbox")]
collision_layer = 2
script = ExtResource("1_75nxq")
...
...
@@ -332,14 +348,15 @@ shape = SubResource("CircleShape2D_tqguy")
[node name="HealthBar" type="ProgressBar" parent="."]
offset_left = -22.0
offset_top = -
46
.0
offset_top = -
50
.0
offset_right = 22.0
offset_bottom = -3
2
.0
offset_bottom = -3
6
.0
theme_override_styles/background = SubResource("StyleBoxFlat_k3tkm")
theme_override_styles/fill = SubResource("StyleBoxFlat_57ouj")
step = 1.0
value = 50.0
show_percentage = false
metadata/_edit_group_ = true
[node name="HealthLabel" type="Label" parent="HealthBar"]
layout_mode = 1
...
...
@@ -352,4 +369,17 @@ text = "HP: 100"
label_settings = SubResource("LabelSettings_3yqcj")
horizontal_alignment = 1
[node name="AmmoBar" type="ProgressBar" parent="."]
offset_left = -22.0
offset_top = -34.0
offset_right = 22.0
offset_bottom = -30.0
theme_override_styles/background = SubResource("StyleBoxFlat_msbq6")
theme_override_styles/fill = SubResource("StyleBoxFlat_s5c8w")
max_value = 20.0
step = 1.0
value = 10.0
show_percentage = false
metadata/_edit_group_ = true
[connection signal="area_entered" from="PickupableArea" to="." method="_on_pickupable_area_area_entered"]
This diff is collapsed.
Click to expand it.
scripts/grovekeeper.gd
+
14
−
2
View file @
e6c6f7c8
...
...
@@ -7,12 +7,17 @@ extends Actor
@
export
var
build_controller
:
BuildController
var
inventory
:
InventoryDataResource
=
preload
(
"res://scripts/inventory/player_inventory_data.tres"
)
var
_ammo
:
=
10
:
set
(
value
):
_ammo
=
clampi
(
value
,
0
,
20
)
_ammo_bar
.
value
=
_ammo
@
onready
var
rig
:
CanvasGroup
=
$
Rig
@
onready
var
animation_player
:
AnimationPlayer
=
$
AnimationPlayer
@
onready
var
projectile_shooter
:
ProjectileShooter
=
$
ProjectileShooter
@
onready
var
_health_bar
:
ProgressBar
=
$
HealthBar
@
onready
var
_health_label
:
Label
=
$
HealthBar
/
HealthLabel
@
onready
var
_ammo_bar
:
ProgressBar
=
$
AmmoBar
# Get the gravity from the project settings to be synced with RigidBody nodes.
var
gravity
:
int
=
ProjectSettings
.
get_setting
(
"physics/2d/default_gravity"
)
...
...
@@ -39,6 +44,7 @@ func _ready() -> void:
projectile_shooter
.
actor_stats
=
stats
# HACK: Should be _unhandled_input
func
_input
(
event
:
InputEvent
)
->
void
:
if
event
.
is_action_pressed
(
"interact_item"
):
get_viewport
()
.
set_input_as_handled
()
...
...
@@ -50,8 +56,10 @@ func _input(event: InputEvent) -> void:
return
if
event
.
is_action_pressed
(
"fire"
):
get_viewport
()
.
set_input_as_handled
()
projectile_shooter
.
fire
()
if
_ammo
>
0
:
get_viewport
()
.
set_input_as_handled
()
projectile_shooter
.
fire
()
_ammo
-=
1
return
if
event
.
is_action_pressed
(
"hotbar_left"
):
...
...
@@ -119,6 +127,10 @@ func get_vector(axis: Vector2) -> Vector2:
return
vector
func
_on_died
()
->
void
:
get_tree
()
.
change_scene_to_file
(
"res://rooms/main_menu.tscn"
)
func
_on_pickupable_area_area_entered
(
area
:
Pickupable
)
->
void
:
area
.
collect
(
inventory
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment