summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Assets/kenney_pixelplatformer/Tiles/tile_0044.png.import2
-rw-r--r--GUI.gd14
-rw-r--r--GUI.tscn21
-rw-r--r--GlobalData.gd7
-rw-r--r--Level.tscn20
-rw-r--r--PatrolEnemy.gd1
-rw-r--r--PatrolEnemy.tscn1
-rw-r--r--Player.gd1
8 files changed, 60 insertions, 7 deletions
diff --git a/Assets/kenney_pixelplatformer/Tiles/tile_0044.png.import b/Assets/kenney_pixelplatformer/Tiles/tile_0044.png.import
index 0f86aeb..671c5e2 100644
--- a/Assets/kenney_pixelplatformer/Tiles/tile_0044.png.import
+++ b/Assets/kenney_pixelplatformer/Tiles/tile_0044.png.import
@@ -20,7 +20,7 @@ compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
-flags/filter=true
+flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
diff --git a/GUI.gd b/GUI.gd
new file mode 100644
index 0000000..8368474
--- /dev/null
+++ b/GUI.gd
@@ -0,0 +1,14 @@
+extends Control
+
+const HP_WIDTH = 18
+
+func update_hp_indicator():
+ $HPIndicator.rect_min_size.x = GlobalData.player_hp * HP_WIDTH
+ $HPIndicator.rect_size = Vector2.ZERO
+
+func _ready():
+ GlobalData.connect("player_hp_changed", self, "_on_GlobalData_player_hp_changed")
+ update_hp_indicator()
+
+func _on_GlobalData_player_hp_changed(_player_hp: int):
+ update_hp_indicator()
diff --git a/GUI.tscn b/GUI.tscn
new file mode 100644
index 0000000..a69a9b2
--- /dev/null
+++ b/GUI.tscn
@@ -0,0 +1,21 @@
+[gd_scene load_steps=3 format=2]
+
+[ext_resource path="res://GUI.gd" type="Script" id=1]
+[ext_resource path="res://Assets/kenney_pixelplatformer/Tiles/tile_0044.png" type="Texture" id=2]
+
+[node name="GUI" type="MarginContainer"]
+anchor_right = 1.0
+anchor_bottom = 1.0
+margin_right = 54.0
+margin_bottom = 18.0
+script = ExtResource( 1 )
+
+[node name="HPIndicator" type="TextureRect" parent="."]
+margin_right = 54.0
+margin_bottom = 18.0
+rect_min_size = Vector2( 54, 18 )
+size_flags_horizontal = 0
+size_flags_vertical = 0
+texture = ExtResource( 2 )
+expand = true
+stretch_mode = 2
diff --git a/GlobalData.gd b/GlobalData.gd
index 1ee67a1..8cf9d94 100644
--- a/GlobalData.gd
+++ b/GlobalData.gd
@@ -4,11 +4,16 @@ export(int) var player_hp = 3
export(float) var GRAVITY: float = 1200
export(float) var MAX_FALL_SPEED: float = 1200
+signal player_hp_changed
+
+func add_player_hp(delta: int):
+ player_hp += delta
+ emit_signal("player_hp_changed", player_hp)
+
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
-
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
diff --git a/Level.tscn b/Level.tscn
index b4a9b7a..46de4c5 100644
--- a/Level.tscn
+++ b/Level.tscn
@@ -1,10 +1,11 @@
-[gd_scene load_steps=29 format=2]
+[gd_scene load_steps=30 format=2]
[ext_resource path="res://Player.tscn" type="PackedScene" id=1]
[ext_resource path="res://Assets/kenney_pixelplatformer/Tilemap/tiles_packed.png" type="Texture" id=2]
[ext_resource path="res://Assets/background_glacial_mountains.png" type="Texture" id=3]
[ext_resource path="res://PatrolEnemy.tscn" type="PackedScene" id=4]
[ext_resource path="res://SimplePlatform.tscn" type="PackedScene" id=5]
+[ext_resource path="res://GUI.tscn" type="PackedScene" id=6]
[sub_resource type="ConvexPolygonShape2D" id=2]
points = PoolVector2Array( 0, 0, 18, 0, 18, 18, 0, 18 )
@@ -249,6 +250,7 @@ points = PoolVector2Array( 0, 0, 18, 0, 18, 18, 0, 18 )
[node name="Player" parent="." instance=ExtResource( 1 )]
position = Vector2( 74, 54 )
scale = Vector2( 1, 1 )
+z_index = 10
JUMP_FORCE = 600.0
COYOTE_TIME = 120.0
@@ -274,15 +276,15 @@ smoothing_enabled = true
smoothing_speed = 8.0
[node name="AutoTileMap" type="TileMap" parent="."]
-position = Vector2( 3, -2 )
scale = Vector2( 2, 2 )
+z_index = 20
tile_set = SubResource( 1 )
cell_size = Vector2( 18, 18 )
cell_custom_transform = Transform2D( 0, 0, 0, 0, 0, 0 )
format = 1
tile_data = PoolIntArray( -327681, 0, 65537, -393216, 0, 65539, -262145, 0, 393217, -327680, 0, 393219, -196609, 0, 393217, -262144, 0, 393219, -131073, 0, 393217, -196608, 0, 393219, -65537, 0, 393217, -131072, 0, 393219, -1, 0, 393217, -65536, 0, 393219, 65535, 0, 393217, 0, 0, 393219, 21, 0, 0, 131071, 0, 393217, 65536, 0, 393219, 196607, 0, 393217, 131072, 0, 393219, 131096, 0, 0, 131106, 0, 65537, 131107, 0, 65539, 262143, 0, 393217, 196608, 0, 65540, 196609, 0, 65538, 196610, 0, 65538, 196611, 0, 65539, 196619, 0, 65537, 196620, 0, 65539, 196642, 0, 393217, 196643, 0, 393219, 327679, 0, 393217, 262144, 0, 393218, 262145, 0, 393218, 262146, 0, 393218, 262147, 0, 393219, 262155, 0, 393217, 262156, 0, 65540, 262157, 0, 65538, 262158, 0, 65539, 262171, 0, 0, 262177, 0, 65537, 262178, 0, 65541, 262179, 0, 393219, 393215, 0, 393217, 327680, 0, 393218, 327681, 0, 4, 327682, 0, 458754, 327683, 0, 458755, 327687, 0, 0, 327691, 0, 458753, 327692, 0, 458754, 327693, 0, 458754, 327694, 0, 458755, 327698, 0, 0, 327713, 0, 458753, 327714, 0, 5, 327715, 0, 393219, 458751, 0, 393217, 393216, 0, 393218, 393217, 0, 393219, 393246, 0, 0, 393250, 0, 393217, 393251, 0, 65540, 393252, 0, 65539, 524287, 0, 393217, 458752, 0, 393218, 458753, 0, 393219, 458786, 0, 393217, 458787, 0, 393218, 458788, 0, 393219, 589823, 0, 393217, 524288, 0, 393218, 524289, 0, 393219, 524307, 0, 65537, 524308, 0, 65538, 524309, 0, 65538, 524310, 0, 65539, 524322, 0, 393217, 524323, 0, 393218, 524324, 0, 393219, 655359, 0, 393217, 589824, 0, 393218, 589825, 0, 393219, 589839, 0, 1, 589840, 0, 3, 589843, 0, 458753, 589844, 0, 458754, 589845, 0, 5, 589846, 0, 393219, 589858, 0, 393217, 589859, 0, 393218, 589860, 0, 393219, 720895, 0, 393217, 655360, 0, 393218, 655361, 0, 393219, 655373, 0, 65537, 655374, 0, 65539, 655381, 0, 458753, 655382, 0, 458755, 655393, 0, 65537, 655394, 0, 65541, 655395, 0, 393218, 655396, 0, 65540, 655397, 0, 65539, 786431, 0, 393217, 720896, 0, 393218, 720897, 0, 393219, 720904, 0, 1, 720905, 0, 2, 720906, 0, 3, 720909, 0, 458753, 720910, 0, 458755, 720929, 0, 393217, 720930, 0, 393218, 720931, 0, 393218, 720932, 0, 393218, 720933, 0, 393219, 851967, 0, 393217, 786432, 0, 393218, 786433, 0, 393219, 786464, 0, 65537, 786465, 0, 65541, 786466, 0, 393218, 786467, 0, 393218, 786468, 0, 4, 786469, 0, 458755, 917503, 0, 393217, 851968, 0, 393218, 851969, 0, 393219, 851994, 0, 65537, 851995, 0, 65538, 851996, 0, 65538, 851997, 0, 65538, 851998, 0, 65539, 852000, 0, 393217, 852001, 0, 393218, 852002, 0, 393218, 852003, 0, 393218, 852004, 0, 393219, 983039, 0, 393217, 917504, 0, 393218, 917505, 0, 65540, 917506, 0, 65538, 917507, 0, 65538, 917508, 0, 65538, 917509, 0, 65538, 917510, 0, 65538, 917511, 0, 65538, 917512, 0, 65538, 917513, 0, 65538, 917514, 0, 65538, 917515, 0, 65538, 917516, 0, 65538, 917517, 0, 65538, 917518, 0, 65538, 917519, 0, 65538, 917520, 0, 65538, 917521, 0, 65538, 917522, 0, 65538, 917523, 0, 65538, 917524, 0, 65538, 917525, 0, 65538, 917526, 0, 65538, 917527, 0, 65538, 917528, 0, 65538, 917529, 0, 65538, 917530, 0, 65541, 917531, 0, 393218, 917532, 0, 393218, 917533, 0, 393218, 917534, 0, 393219, 917536, 0, 393217, 917537, 0, 393218, 917538, 0, 393218, 917539, 0, 393218, 917540, 0, 393219, 1048575, 0, 393217, 983040, 0, 393218, 983041, 0, 393218, 983042, 0, 393218, 983043, 0, 393218, 983044, 0, 393218, 983045, 0, 393218, 983046, 0, 393218, 983047, 0, 393218, 983048, 0, 393218, 983049, 0, 393218, 983050, 0, 393218, 983051, 0, 393218, 983052, 0, 393218, 983053, 0, 393218, 983054, 0, 393218, 983055, 0, 393218, 983056, 0, 393218, 983057, 0, 393218, 983058, 0, 393218, 983059, 0, 393218, 983060, 0, 393218, 983061, 0, 393218, 983062, 0, 393218, 983063, 0, 393218, 983064, 0, 393218, 983065, 0, 393218, 983066, 0, 393218, 983067, 0, 393218, 983068, 0, 393218, 983069, 0, 393218, 983070, 0, 65540, 983071, 0, 65538, 983072, 0, 65541, 983073, 0, 393218, 983074, 0, 393218, 983075, 0, 393218, 983076, 0, 393219, 1114111, 0, 393217, 1048576, 0, 393218, 1048577, 0, 393218, 1048578, 0, 393218, 1048579, 0, 393218, 1048580, 0, 393218, 1048581, 0, 393218, 1048582, 0, 393218, 1048583, 0, 393218, 1048584, 0, 393218, 1048585, 0, 393218, 1048586, 0, 393218, 1048587, 0, 393218, 1048588, 0, 393218, 1048589, 0, 393218, 1048590, 0, 393218, 1048591, 0, 393218, 1048592, 0, 393218, 1048593, 0, 393218, 1048594, 0, 393218, 1048595, 0, 393218, 1048596, 0, 393218, 1048597, 0, 393218, 1048598, 0, 393218, 1048599, 0, 393218, 1048600, 0, 393218, 1048601, 0, 393218, 1048602, 0, 393218, 1048603, 0, 393218, 1048604, 0, 393218, 1048605, 0, 393218, 1048606, 0, 393218, 1048607, 0, 393218, 1048608, 0, 393218, 1048609, 0, 393218, 1048610, 0, 393218, 1048611, 0, 393218, 1048612, 0, 393219, 1179647, 0, 393217, 1114112, 0, 393218, 1114113, 0, 393218, 1114114, 0, 393218, 1114115, 0, 393218, 1114116, 0, 393218, 1114117, 0, 393218, 1114118, 0, 393218, 1114119, 0, 393218, 1114120, 0, 393218, 1114121, 0, 393218, 1114122, 0, 393218, 1114123, 0, 393218, 1114124, 0, 393218, 1114125, 0, 393218, 1114126, 0, 393218, 1114127, 0, 393218, 1114128, 0, 393218, 1114129, 0, 393218, 1114130, 0, 393218, 1114131, 0, 393218, 1114132, 0, 393218, 1114133, 0, 393218, 1114134, 0, 393218, 1114135, 0, 393218, 1114136, 0, 393218, 1114137, 0, 393218, 1114138, 0, 393218, 1114139, 0, 393218, 1114140, 0, 393218, 1114141, 0, 393218, 1114142, 0, 393218, 1114143, 0, 393218, 1114144, 0, 393218, 1114145, 0, 393218, 1114146, 0, 393218, 1114147, 0, 393218, 1114148, 0, 393219, 1245183, 0, 393217, 1179648, 0, 393218, 1179649, 0, 393218, 1179650, 0, 393218, 1179651, 0, 393218, 1179652, 0, 393218, 1179653, 0, 393218, 1179654, 0, 393218, 1179655, 0, 393218, 1179656, 0, 393218, 1179657, 0, 393218, 1179658, 0, 393218, 1179659, 0, 393218, 1179660, 0, 393218, 1179661, 0, 393218, 1179662, 0, 393218, 1179663, 0, 393218, 1179664, 0, 393218, 1179665, 0, 393218, 1179666, 0, 393218, 1179667, 0, 393218, 1179668, 0, 393218, 1179669, 0, 393218, 1179670, 0, 393218, 1179671, 0, 393218, 1179672, 0, 393218, 1179673, 0, 393218, 1179674, 0, 393218, 1179675, 0, 393218, 1179676, 0, 393218, 1179677, 0, 393218, 1179678, 0, 393218, 1179679, 0, 393218, 1179680, 0, 393218, 1179681, 0, 393218, 1179682, 0, 393218, 1179683, 0, 393218, 1179684, 0, 393219, 1310719, 0, 393217, 1245184, 0, 393218, 1245185, 0, 393218, 1245186, 0, 393218, 1245187, 0, 393218, 1245188, 0, 393218, 1245189, 0, 393218, 1245190, 0, 393218, 1245191, 0, 393218, 1245192, 0, 393218, 1245193, 0, 393218, 1245194, 0, 393218, 1245195, 0, 393218, 1245196, 0, 393218, 1245197, 0, 393218, 1245198, 0, 393218, 1245199, 0, 393218, 1245200, 0, 393218, 1245201, 0, 393218, 1245202, 0, 393218, 1245203, 0, 393218, 1245204, 0, 393218, 1245205, 0, 393218, 1245206, 0, 393218, 1245207, 0, 393218, 1245208, 0, 393218, 1245209, 0, 393218, 1245210, 0, 393218, 1245211, 0, 393218, 1245212, 0, 393218, 1245213, 0, 393218, 1245214, 0, 393218, 1245215, 0, 393218, 1245216, 0, 393218, 1245217, 0, 393218, 1245218, 0, 393218, 1245219, 0, 393218, 1245220, 0, 393219, 1376255, 0, 393217, 1310720, 0, 393218, 1310721, 0, 393218, 1310722, 0, 393218, 1310723, 0, 393218, 1310724, 0, 393218, 1310725, 0, 393218, 1310726, 0, 393218, 1310727, 0, 393218, 1310728, 0, 393218, 1310729, 0, 393218, 1310730, 0, 393218, 1310731, 0, 393218, 1310732, 0, 393218, 1310733, 0, 393218, 1310734, 0, 393218, 1310735, 0, 393218, 1310736, 0, 393218, 1310737, 0, 393218, 1310738, 0, 393218, 1310739, 0, 393218, 1310740, 0, 393218, 1310741, 0, 393218, 1310742, 0, 393218, 1310743, 0, 393218, 1310744, 0, 393218, 1310745, 0, 393218, 1310746, 0, 393218, 1310747, 0, 393218, 1310748, 0, 393218, 1310749, 0, 393218, 1310750, 0, 393218, 1310751, 0, 393218, 1310752, 0, 393218, 1310753, 0, 393218, 1310754, 0, 393218, 1310755, 0, 393218, 1310756, 0, 393219, 1441791, 0, 393217, 1376256, 0, 393218, 1376257, 0, 393218, 1376258, 0, 393218, 1376259, 0, 393218, 1376260, 0, 393218, 1376261, 0, 393218, 1376262, 0, 393218, 1376263, 0, 393218, 1376264, 0, 393218, 1376265, 0, 393218, 1376266, 0, 393218, 1376267, 0, 393218, 1376268, 0, 393218, 1376269, 0, 393218, 1376270, 0, 393218, 1376271, 0, 393218, 1376272, 0, 393218, 1376273, 0, 393218, 1376274, 0, 393218, 1376275, 0, 393218, 1376276, 0, 393218, 1376277, 0, 393218, 1376278, 0, 393218, 1376279, 0, 393218, 1376280, 0, 393218, 1376281, 0, 393218, 1376282, 0, 393218, 1376283, 0, 393218, 1376284, 0, 393218, 1376285, 0, 393218, 1376286, 0, 393218, 1376287, 0, 393218, 1376288, 0, 393218, 1376289, 0, 393218, 1376290, 0, 393218, 1376291, 0, 393218, 1376292, 0, 393219, 1507327, 0, 458753, 1441792, 0, 458754, 1441793, 0, 458754, 1441794, 0, 458754, 1441795, 0, 458754, 1441796, 0, 458754, 1441797, 0, 458754, 1441798, 0, 458754, 1441799, 0, 458754, 1441800, 0, 458754, 1441801, 0, 458754, 1441802, 0, 458754, 1441803, 0, 458754, 1441804, 0, 458754, 1441805, 0, 458754, 1441806, 0, 458754, 1441807, 0, 458754, 1441808, 0, 458754, 1441809, 0, 458754, 1441810, 0, 458754, 1441811, 0, 458754, 1441812, 0, 458754, 1441813, 0, 458754, 1441814, 0, 458754, 1441815, 0, 458754, 1441816, 0, 458754, 1441817, 0, 458754, 1441818, 0, 458754, 1441819, 0, 458754, 1441820, 0, 458754, 1441821, 0, 458754, 1441822, 0, 458754, 1441823, 0, 458754, 1441824, 0, 458754, 1441825, 0, 458754, 1441826, 0, 458754, 1441827, 0, 458754, 1441828, 0, 458755 )
-[node name="SingleTileMap" type="TileMap" parent="."]
+[node name="BgSingleTileMap" type="TileMap" parent="."]
scale = Vector2( 2, 2 )
tile_set = SubResource( 23 )
cell_size = Vector2( 18, 18 )
@@ -295,3 +297,15 @@ position = Vector2( 702, 450 )
[node name="SimplePlatform" parent="." instance=ExtResource( 5 )]
position = Vector2( 910, 490 )
rotation = -0.555015
+
+[node name="UIZIndexLayer" type="CanvasLayer" parent="."]
+scale = Vector2( 2, 2 )
+transform = Transform2D( 2, 0, 0, 2, 0, 0 )
+
+[node name="GUI" parent="UIZIndexLayer" instance=ExtResource( 6 )]
+anchor_left = 1.0
+anchor_top = 1.0
+margin_left = -1024.0
+margin_top = -600.0
+margin_right = -98.0
+margin_bottom = -500.0
diff --git a/PatrolEnemy.gd b/PatrolEnemy.gd
index b3d02e2..602df8f 100644
--- a/PatrolEnemy.gd
+++ b/PatrolEnemy.gd
@@ -14,7 +14,6 @@ func _physics_process(delta):
if $RayCastWall.is_colliding():
scale.x = -scale.x
velocity.x = -velocity.x
- print(scale, velocity)
velocity.y = clamp(velocity.y, -INF, GlobalData.MAX_FALL_SPEED)
move_and_slide(velocity, Vector2.UP)
diff --git a/PatrolEnemy.tscn b/PatrolEnemy.tscn
index 57ed3fa..aa30d87 100644
--- a/PatrolEnemy.tscn
+++ b/PatrolEnemy.tscn
@@ -21,6 +21,7 @@ script = ExtResource( 1 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
scale = Vector2( 2, 2 )
frames = SubResource( 1 )
+frame = 1
playing = true
[node name="RayCastWall" type="RayCast2D" parent="."]
diff --git a/Player.gd b/Player.gd
index 48c5e09..d61718c 100644
--- a/Player.gd
+++ b/Player.gd
@@ -67,5 +67,4 @@ func _physics_process(delta):
# snap needs to be ZERO when jumping
# print($AnimationPlayer.current_animation, ", ", $AnimationTree.get("parameters/walk_speed/scale"))
- # warning-ignore:return_value_discarded
move_and_slide(velocity, Vector2.UP)