Add HP Logic

main
Luna Brovchuk 2023-09-30 19:37:52 +02:00
parent f3dd6ee65a
commit 7ee336c7d5
5 changed files with 33 additions and 9 deletions

View File

@ -20,7 +20,7 @@ compress/hdr_mode=0
compress/bptc_ldr=0 compress/bptc_ldr=0
compress/normal_map=0 compress/normal_map=0
flags/repeat=0 flags/repeat=0
flags/filter=true flags/filter=false
flags/mipmaps=false flags/mipmaps=false
flags/anisotropic=false flags/anisotropic=false
flags/srgb=2 flags/srgb=2
@ -31,5 +31,5 @@ process/invert_color=false
process/normal_map_invert_y=false process/normal_map_invert_y=false
stream=false stream=false
size_limit=0 size_limit=0
detect_3d=true detect_3d=false
svg/scale=1.0 svg/scale=1.0

View File

@ -8,6 +8,16 @@
config_version=4 config_version=4
_global_script_classes=[ {
"base": "EditorVCSInterface",
"class": "GitAPI",
"language": "NativeScript",
"path": "res://addons/godot-git-plugin/git_api.gdns"
} ]
_global_script_class_icons={
"GitAPI": ""
}
[application] [application]
config/name="LD54" config/name="LD54"
@ -38,7 +48,7 @@ version_control_plugin_name="GitAPI"
[gdnative] [gdnative]
singletons=[ ] singletons=[ "res://addons/godot-git-plugin/git_api.gdnlib" ]
[global] [global]

View File

@ -3,10 +3,10 @@ extends Node
var GAME_SCENE = preload("res://src/scenes/game/Game.tscn") var GAME_SCENE = preload("res://src/scenes/game/Game.tscn")
var playing = true var playing = true
var health = 0 var health = 2
func add_health(amount): func add_health(amount):
health = clamp(health + amount, 0, 3) health = clamp(health + amount, 0, 3)
emit_signal("health_update") get_tree().get_root().get_node("Game/UI/Health/HealthSprite").frame = health
if health == 0: if health == 0:
pass # TODO endgame pass # TODO endgame

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=14 format=2] [gd_scene load_steps=16 format=2]
[ext_resource path="res://src/scenes/menu/background/background.png" type="Texture" id=1] [ext_resource path="res://src/scenes/menu/background/background.png" type="Texture" id=1]
[ext_resource path="res://src/scenes/game/sprites/background_houses.png" type="Texture" id=2] [ext_resource path="res://src/scenes/game/sprites/background_houses.png" type="Texture" id=2]
@ -9,12 +9,14 @@
[ext_resource path="res://src/scenes/game/sprites/health/1.png" type="Texture" id=7] [ext_resource path="res://src/scenes/game/sprites/health/1.png" type="Texture" id=7]
[ext_resource path="res://src/scenes/game/sprites/health/2.png" type="Texture" id=8] [ext_resource path="res://src/scenes/game/sprites/health/2.png" type="Texture" id=8]
[ext_resource path="res://src/scenes/game/sprites/health/0.png" type="Texture" id=9] [ext_resource path="res://src/scenes/game/sprites/health/0.png" type="Texture" id=9]
[ext_resource path="res://icon.png" type="Texture" id=10]
[ext_resource path="res://src/scenes/game/game.gd" type="Script" id=11]
[sub_resource type="RectangleShape2D" id=2] [sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 10, 60 ) extents = Vector2( 10, 60 )
[sub_resource type="RectangleShape2D" id=3] [sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 140, 10.25 ) extents = Vector2( 140, 10.125 )
[sub_resource type="DynamicFont" id=1] [sub_resource type="DynamicFont" id=1]
size = 8 size = 8
@ -29,6 +31,7 @@ animations = [ {
} ] } ]
[node name="Game" type="Node"] [node name="Game" type="Node"]
script = ExtResource( 11 )
[node name="View" type="Node2D" parent="."] [node name="View" type="Node2D" parent="."]
@ -59,7 +62,7 @@ position = Vector2( 160, 10.25 )
shape = SubResource( 3 ) shape = SubResource( 3 )
[node name="CollisionShape2D4" type="CollisionShape2D" parent="View/Background/Houses"] [node name="CollisionShape2D4" type="CollisionShape2D" parent="View/Background/Houses"]
position = Vector2( 160, 110 ) position = Vector2( 160, 109.875 )
shape = SubResource( 3 ) shape = SubResource( 3 )
[node name="Player" parent="View" instance=ExtResource( 5 )] [node name="Player" parent="View" instance=ExtResource( 5 )]
@ -88,7 +91,14 @@ text = "spell modifiers"
margin_right = 40.0 margin_right = 40.0
margin_bottom = 40.0 margin_bottom = 40.0
[node name="AnimatedSprite" type="AnimatedSprite" parent="UI/Health"] [node name="HealthSprite" type="AnimatedSprite" parent="UI/Health"]
position = Vector2( 70, 145 ) position = Vector2( 70, 145 )
frames = SubResource( 4 ) frames = SubResource( 4 )
frame = 2
centered = false
[node name="PlayerIcon" type="Sprite" parent="UI"]
position = Vector2( 20, 134 )
scale = Vector2( 0.5, 0.5 )
texture = ExtResource( 10 )
centered = false centered = false

4
src/scenes/game/game.gd Normal file
View File

@ -0,0 +1,4 @@
extends Node
func _ready():
Global.add_health(1)