multi levels, timer, health, coins, key

This commit is contained in:
fabianainu 2024-12-23 21:28:20 -05:00
parent 5ca3a193d1
commit 39ac434d3c
11 changed files with 764 additions and 31 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://du0e0ddagpw2p"
path="res://.godot/imported/key.png-9a4111b1e9b4dbdd03db0f0fec3ea3ee.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/graphics/pickups/key.png"
dest_files=["res://.godot/imported/key.png-9a4111b1e9b4dbdd03db0f0fec3ea3ee.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=44 format=3 uid="uid://djgtbc1quqvwe"] [gd_scene load_steps=45 format=3 uid="uid://djgtbc1quqvwe"]
[ext_resource type="Script" path="res://scripts/dudecontroller.gd" id="1_ay2gi"] [ext_resource type="Script" path="res://scripts/dudecontroller.gd" id="1_ay2gi"]
[ext_resource type="Texture2D" uid="uid://dvgh32yadcjcq" path="res://assets/graphics/player/idle/Player Idle 48x48.png" id="2_5mbmt"] [ext_resource type="Texture2D" uid="uid://dvgh32yadcjcq" path="res://assets/graphics/player/idle/Player Idle 48x48.png" id="2_5mbmt"]
@ -6,6 +6,7 @@
[ext_resource type="Texture2D" uid="uid://1tiutqy11mhk" path="res://assets/graphics/player/hurt/Player Hurt 48x48.png" id="2_p1quv"] [ext_resource type="Texture2D" uid="uid://1tiutqy11mhk" path="res://assets/graphics/player/hurt/Player Hurt 48x48.png" id="2_p1quv"]
[ext_resource type="Texture2D" uid="uid://2mxlso64vnrk" path="res://assets/graphics/player/run/player run 48x48.png" id="3_2y1a6"] [ext_resource type="Texture2D" uid="uid://2mxlso64vnrk" path="res://assets/graphics/player/run/player run 48x48.png" id="3_2y1a6"]
[ext_resource type="Texture2D" uid="uid://cwiun1ntuu02d" path="res://assets/graphics/player/jump/player jump 48x48.png" id="3_5o14d"] [ext_resource type="Texture2D" uid="uid://cwiun1ntuu02d" path="res://assets/graphics/player/jump/player jump 48x48.png" id="3_5o14d"]
[ext_resource type="Texture2D" uid="uid://du0e0ddagpw2p" path="res://assets/graphics/pickups/key.png" id="7_o78ee"]
[sub_resource type="CircleShape2D" id="CircleShape2D_iice4"] [sub_resource type="CircleShape2D" id="CircleShape2D_iice4"]
radius = 6.32456 radius = 6.32456
@ -316,4 +317,9 @@ autoplay = "Idle"
[node name="Camera2D" type="Camera2D" parent="."] [node name="Camera2D" type="Camera2D" parent="."]
offset = Vector2(0, -30) offset = Vector2(0, -30)
[node name="Key" type="Sprite2D" parent="."]
position = Vector2(1, 0)
scale = Vector2(0.0360825, 0.0360825)
texture = ExtResource("7_o78ee")
[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animation_finished"] [connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animation_finished"]

View File

@ -1,17 +1,18 @@
[gd_scene load_steps=17 format=4 uid="uid://ciko2h5jj1a3k"] [gd_scene load_steps=18 format=4 uid="uid://ciko2h5jj1a3k"]
[ext_resource type="PackedScene" uid="uid://djgtbc1quqvwe" path="res://scenes/dude.tscn" id="1_4l1yw"] [ext_resource type="PackedScene" uid="uid://djgtbc1quqvwe" path="res://scenes/dude.tscn" id="1_4l1yw"]
[ext_resource type="Texture2D" uid="uid://d3da1xpx6f8do" path="res://assets/graphics/environment/background/forestbackground.png" id="1_i3nvv"] [ext_resource type="Texture2D" uid="uid://d3da1xpx6f8do" path="res://assets/graphics/environment/background/forestbackground.png" id="1_i3nvv"]
[ext_resource type="PackedScene" uid="uid://bw3gps1njvtgr" path="res://scenes/box.tscn" id="1_mg5q5"] [ext_resource type="PackedScene" uid="uid://bw3gps1njvtgr" path="res://scenes/box.tscn" id="1_mg5q5"]
[ext_resource type="Script" path="res://scripts/scene_manager.gd" id="1_tpgoh"] [ext_resource type="Script" path="res://scripts/scene_manager.gd" id="1_tpgoh"]
[ext_resource type="Texture2D" uid="uid://qftgnypwbikp" path="res://assets/graphics/environment/terrain/Terrain (32x32).png" id="1_yjgfx"] [ext_resource type="Texture2D" uid="uid://qftgnypwbikp" path="res://assets/graphics/environment/terrain/Terrain (32x32).png" id="1_yjgfx"]
[ext_resource type="Script" path="res://scripts/trigger.gd" id="2_a7w16"]
[ext_resource type="Texture2D" uid="uid://dr8tcpg5yp3ei" path="res://assets/graphics/environment/background/midgroud.png" id="2_ms4rf"] [ext_resource type="Texture2D" uid="uid://dr8tcpg5yp3ei" path="res://assets/graphics/environment/background/midgroud.png" id="2_ms4rf"]
[ext_resource type="Texture2D" uid="uid://bcwyohfx8ft18" path="res://assets/graphics/environment/background/sky_strip.png" id="2_twm8w"] [ext_resource type="Texture2D" uid="uid://bcwyohfx8ft18" path="res://assets/graphics/environment/background/sky_strip.png" id="2_twm8w"]
[ext_resource type="Texture2D" uid="uid://dmsqm0stkx5s2" path="res://assets/graphics/environment/background/clouds.png" id="3_nw1b4"] [ext_resource type="Texture2D" uid="uid://dmsqm0stkx5s2" path="res://assets/graphics/environment/background/clouds.png" id="3_nw1b4"]
[ext_resource type="Texture2D" uid="uid://c5r8lr50mwhws" path="res://assets/graphics/environment/background/midgroud_grass.png" id="4_d4yqf"] [ext_resource type="Texture2D" uid="uid://c5r8lr50mwhws" path="res://assets/graphics/environment/background/midgroud_grass.png" id="4_d4yqf"]
[ext_resource type="Script" path="res://scripts/trigger_key.gd" id="10_h7rqj"]
[ext_resource type="PackedScene" uid="uid://cttwpovmajtsa" path="res://scenes/coin.tscn" id="11_v5ca1"] [ext_resource type="PackedScene" uid="uid://cttwpovmajtsa" path="res://scenes/coin.tscn" id="11_v5ca1"]
[ext_resource type="PackedScene" uid="uid://b0pun5awvst0k" path="res://scenes/badguy.tscn" id="12_18k5f"] [ext_resource type="PackedScene" uid="uid://b0pun5awvst0k" path="res://scenes/badguy.tscn" id="12_18k5f"]
[ext_resource type="PackedScene" uid="uid://bj4sdxqrlfr02" path="res://scenes/ui.tscn" id="13_g6f7a"]
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_bdyqk"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_bdyqk"]
texture = ExtResource("1_yjgfx") texture = ExtResource("1_yjgfx")
@ -453,7 +454,7 @@ unique_name_in_owner = true
script = ExtResource("1_tpgoh") script = ExtResource("1_tpgoh")
[node name="CharacterBody2D" parent="." instance=ExtResource("1_4l1yw")] [node name="CharacterBody2D" parent="." instance=ExtResource("1_4l1yw")]
position = Vector2(305, -22) position = Vector2(37, 132)
[node name="Box" parent="." groups=["shootable"] instance=ExtResource("1_mg5q5")] [node name="Box" parent="." groups=["shootable"] instance=ExtResource("1_mg5q5")]
position = Vector2(137, 23) position = Vector2(137, 23)
@ -471,13 +472,13 @@ metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"] [node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"]
shape = SubResource("WorldBoundaryShape2D_vdfbk") shape = SubResource("WorldBoundaryShape2D_vdfbk")
[node name="Area2D" type="Area2D" parent="."] [node name="KeyTrigger" type="Area2D" parent="."]
position = Vector2(232, 291) position = Vector2(487, 61)
scale = Vector2(24.2, 4.16) scale = Vector2(1.04, 4.16)
script = ExtResource("2_a7w16") script = ExtResource("10_h7rqj")
metadata/_edit_group_ = true metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] [node name="CollisionShape2D" type="CollisionShape2D" parent="KeyTrigger"]
position = Vector2(0, -7.76443) position = Vector2(0, -7.76443)
shape = SubResource("RectangleShape2D_lbd3t") shape = SubResource("RectangleShape2D_lbd3t")
debug_color = Color(0.31865, 0.625237, 0, 0.42) debug_color = Color(0.31865, 0.625237, 0, 0.42)
@ -496,22 +497,18 @@ metadata/_edit_group_ = true
position = Vector2(277, -8) position = Vector2(277, -8)
metadata/_edit_group_ = true metadata/_edit_group_ = true
[node name="Coin6" parent="Coins" instance=ExtResource("11_v5ca1")]
position = Vector2(385, 58)
metadata/_edit_group_ = true
[node name="Coin5" parent="Coins" instance=ExtResource("11_v5ca1")] [node name="Coin5" parent="Coins" instance=ExtResource("11_v5ca1")]
position = Vector2(246, -16) position = Vector2(246, -16)
metadata/_edit_group_ = true metadata/_edit_group_ = true
[node name="Coin2" parent="Coins" instance=ExtResource("11_v5ca1")]
position = Vector2(486, 25)
metadata/_edit_group_ = true
[node name="BadGuys" type="Node" parent="."] [node name="BadGuys" type="Node" parent="."]
[node name="BadGuy" parent="BadGuys" instance=ExtResource("12_18k5f")] [node name="BadGuy" parent="BadGuys" instance=ExtResource("12_18k5f")]
position = Vector2(359, 60) position = Vector2(359, 60)
metadata/_edit_group_ = true metadata/_edit_group_ = true
[connection signal="body_entered" from="Area2D" to="Area2D" method="_on_body_entered"] [node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="Control" parent="CanvasLayer" instance=ExtResource("13_g6f7a")]
[connection signal="body_entered" from="KeyTrigger" to="KeyTrigger" method="_on_body_entered"]

View File

@ -0,0 +1,530 @@
[gd_scene load_steps=18 format=4 uid="uid://dmeh4ec7h0lsc"]
[ext_resource type="Texture2D" uid="uid://d3da1xpx6f8do" path="res://assets/graphics/environment/background/forestbackground.png" id="1_tnlsl"]
[ext_resource type="Texture2D" uid="uid://bcwyohfx8ft18" path="res://assets/graphics/environment/background/sky_strip.png" id="2_6ci1w"]
[ext_resource type="Texture2D" uid="uid://dmsqm0stkx5s2" path="res://assets/graphics/environment/background/clouds.png" id="3_uqjdf"]
[ext_resource type="Texture2D" uid="uid://c5r8lr50mwhws" path="res://assets/graphics/environment/background/midgroud_grass.png" id="4_71wd1"]
[ext_resource type="Texture2D" uid="uid://dr8tcpg5yp3ei" path="res://assets/graphics/environment/background/midgroud.png" id="5_b0wjm"]
[ext_resource type="Texture2D" uid="uid://qftgnypwbikp" path="res://assets/graphics/environment/terrain/Terrain (32x32).png" id="6_f2cdw"]
[ext_resource type="Script" path="res://scripts/scene_manager.gd" id="7_3s0ov"]
[ext_resource type="PackedScene" uid="uid://djgtbc1quqvwe" path="res://scenes/dude.tscn" id="8_ctqq8"]
[ext_resource type="PackedScene" uid="uid://bw3gps1njvtgr" path="res://scenes/box.tscn" id="9_b3256"]
[ext_resource type="Script" path="res://scripts/trigger.gd" id="10_c8glf"]
[ext_resource type="PackedScene" uid="uid://cttwpovmajtsa" path="res://scenes/coin.tscn" id="11_0vqln"]
[ext_resource type="PackedScene" uid="uid://b0pun5awvst0k" path="res://scenes/badguy.tscn" id="12_hwoa7"]
[ext_resource type="PackedScene" uid="uid://bj4sdxqrlfr02" path="res://scenes/ui.tscn" id="13_7qh3f"]
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_bdyqk"]
texture = ExtResource("6_f2cdw")
texture_region_size = Vector2i(32, 32)
0:0/0 = 0
0:0/0/terrain_set = 0
0:0/0/terrain = 0
0:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16)
0:0/0/terrains_peering_bit/right_side = 0
0:0/0/terrains_peering_bit/bottom_right_corner = 0
0:0/0/terrains_peering_bit/bottom_side = 0
1:0/0 = 0
1:0/0/terrain_set = 0
1:0/0/terrain = 0
1:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16)
1:0/0/terrains_peering_bit/right_side = 0
1:0/0/terrains_peering_bit/bottom_right_corner = 0
1:0/0/terrains_peering_bit/bottom_side = 0
1:0/0/terrains_peering_bit/bottom_left_corner = 0
1:0/0/terrains_peering_bit/left_side = 0
2:0/0 = 0
2:0/0/terrain_set = 0
2:0/0/terrain = 0
2:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16)
2:0/0/terrains_peering_bit/bottom_side = 0
2:0/0/terrains_peering_bit/bottom_left_corner = 0
2:0/0/terrains_peering_bit/left_side = 0
4:0/0 = 0
4:0/0/terrain_set = 0
4:0/0/terrain = 0
4:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16)
4:0/0/terrains_peering_bit/bottom_side = 0
6:0/0 = 0
6:0/0/terrain_set = 0
6:0/0/terrain = 0
6:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(16, 16, 0, 16, 0, 0, 16, 0)
6:0/0/terrains_peering_bit/right_side = 0
6:0/0/terrains_peering_bit/bottom_side = 0
6:0/0/terrains_peering_bit/bottom_left_corner = 0
6:0/0/terrains_peering_bit/left_side = 0
6:0/0/terrains_peering_bit/top_left_corner = 0
6:0/0/terrains_peering_bit/top_side = 0
6:0/0/terrains_peering_bit/top_right_corner = 0
7:0/0 = 0
7:0/0/terrain_set = 0
7:0/0/terrain = 0
7:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, 16, 0, 16, 0, 0, -16, 0)
7:0/0/terrains_peering_bit/right_side = 0
7:0/0/terrains_peering_bit/bottom_right_corner = 0
7:0/0/terrains_peering_bit/bottom_side = 0
7:0/0/terrains_peering_bit/left_side = 0
7:0/0/terrains_peering_bit/top_left_corner = 0
7:0/0/terrains_peering_bit/top_side = 0
7:0/0/terrains_peering_bit/top_right_corner = 0
9:0/0 = 0
9:0/0/terrain_set = 0
9:0/0/terrain = 0
9:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16)
9:0/0/terrains_peering_bit/right_side = 0
9:0/0/terrains_peering_bit/bottom_right_corner = 0
9:0/0/terrains_peering_bit/bottom_side = 0
9:0/0/terrains_peering_bit/bottom_left_corner = 0
9:0/0/terrains_peering_bit/left_side = 0
9:0/0/terrains_peering_bit/top_side = 0
10:0/0 = 0
10:0/0/terrain_set = 0
10:0/0/terrain = 0
10:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16)
10:0/0/terrains_peering_bit/bottom_side = 0
10:0/0/terrains_peering_bit/bottom_left_corner = 0
10:0/0/terrains_peering_bit/left_side = 0
10:0/0/terrains_peering_bit/top_left_corner = 0
10:0/0/terrains_peering_bit/top_side = 0
12:0/0 = 0
12:0/0/terrain_set = 0
12:0/0/terrain = 0
12:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16)
12:0/0/terrains_peering_bit/right_side = 0
12:0/0/terrains_peering_bit/bottom_right_corner = 0
12:0/0/terrains_peering_bit/bottom_side = 0
12:0/0/terrains_peering_bit/top_side = 0
13:0/0 = 0
13:0/0/terrain_set = 0
13:0/0/terrain = 0
13:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16)
13:0/0/terrains_peering_bit/bottom_side = 0
13:0/0/terrains_peering_bit/bottom_left_corner = 0
13:0/0/terrains_peering_bit/left_side = 0
13:0/0/terrains_peering_bit/top_side = 0
15:0/0 = 0
15:0/0/terrain_set = 0
15:0/0/terrain = 0
15:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(16, -16, 16, 16, -16, 16, -16, -16)
15:0/0/terrains_peering_bit/bottom_side = 0
15:0/0/terrains_peering_bit/top_side = 0
0:1/0 = 0
0:1/0/terrain_set = 0
0:1/0/terrain = 0
0:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16)
0:1/0/terrains_peering_bit/right_side = 0
0:1/0/terrains_peering_bit/bottom_right_corner = 0
0:1/0/terrains_peering_bit/bottom_side = 0
0:1/0/terrains_peering_bit/top_side = 0
0:1/0/terrains_peering_bit/top_right_corner = 0
1:1/0 = 0
1:1/0/terrain_set = 0
1:1/0/terrain = 0
1:1/0/terrains_peering_bit/right_side = 0
1:1/0/terrains_peering_bit/bottom_right_corner = 0
1:1/0/terrains_peering_bit/bottom_side = 0
1:1/0/terrains_peering_bit/bottom_left_corner = 0
1:1/0/terrains_peering_bit/left_side = 0
1:1/0/terrains_peering_bit/top_left_corner = 0
1:1/0/terrains_peering_bit/top_side = 0
1:1/0/terrains_peering_bit/top_right_corner = 0
2:1/0 = 0
2:1/0/terrain_set = 0
2:1/0/terrain = 0
2:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16)
2:1/0/terrains_peering_bit/bottom_side = 0
2:1/0/terrains_peering_bit/bottom_left_corner = 0
2:1/0/terrains_peering_bit/left_side = 0
2:1/0/terrains_peering_bit/top_left_corner = 0
2:1/0/terrains_peering_bit/top_side = 0
4:1/0 = 0
4:1/0/terrain_set = 0
4:1/0/terrain = 0
4:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16)
4:1/0/terrains_peering_bit/bottom_side = 0
4:1/0/terrains_peering_bit/top_side = 0
6:1/0 = 0
6:1/0/terrain_set = 0
6:1/0/terrain = 0
6:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(16, -16, 0, -16, 0, 0, 16, 0)
6:1/0/terrains_peering_bit/right_side = 0
6:1/0/terrains_peering_bit/bottom_right_corner = 0
6:1/0/terrains_peering_bit/bottom_side = 0
6:1/0/terrains_peering_bit/bottom_left_corner = 0
6:1/0/terrains_peering_bit/left_side = 0
6:1/0/terrains_peering_bit/top_left_corner = 0
6:1/0/terrains_peering_bit/top_side = 0
7:1/0 = 0
7:1/0/terrain_set = 0
7:1/0/terrain = 0
7:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 0, -16, 0, 0, -16, 0)
7:1/0/terrains_peering_bit/right_side = 0
7:1/0/terrains_peering_bit/bottom_right_corner = 0
7:1/0/terrains_peering_bit/bottom_side = 0
7:1/0/terrains_peering_bit/bottom_left_corner = 0
7:1/0/terrains_peering_bit/left_side = 0
7:1/0/terrains_peering_bit/top_side = 0
7:1/0/terrains_peering_bit/top_right_corner = 0
9:1/0 = 0
9:1/0/terrain_set = 0
9:1/0/terrain = 0
9:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16)
9:1/0/terrains_peering_bit/right_side = 0
9:1/0/terrains_peering_bit/bottom_right_corner = 0
9:1/0/terrains_peering_bit/bottom_side = 0
9:1/0/terrains_peering_bit/top_side = 0
9:1/0/terrains_peering_bit/top_right_corner = 0
10:1/0 = 0
10:1/0/terrain_set = 0
10:1/0/terrain = 0
10:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16)
10:1/0/terrains_peering_bit/right_side = 0
10:1/0/terrains_peering_bit/bottom_side = 0
10:1/0/terrains_peering_bit/left_side = 0
10:1/0/terrains_peering_bit/top_left_corner = 0
10:1/0/terrains_peering_bit/top_side = 0
10:1/0/terrains_peering_bit/top_right_corner = 0
12:1/0 = 0
12:1/0/terrain_set = 0
12:1/0/terrain = 0
12:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(0, -16, 0, 0, 16, 0, 16, 16, -16, 16, -16, -16)
12:1/0/terrains_peering_bit/right_side = 0
12:1/0/terrains_peering_bit/bottom_side = 0
12:1/0/terrains_peering_bit/top_side = 0
12:1/0/terrains_peering_bit/top_right_corner = 0
13:1/0 = 0
13:1/0/terrain_set = 0
13:1/0/terrain = 0
13:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(0, -16, 16, -16, 16, 16, -16, 16, -16, 0, 0, 0)
13:1/0/terrains_peering_bit/bottom_side = 0
13:1/0/terrains_peering_bit/left_side = 0
13:1/0/terrains_peering_bit/top_left_corner = 0
13:1/0/terrains_peering_bit/top_side = 0
15:1/0 = 0
15:1/0/terrain_set = 0
15:1/0/terrain = 0
15:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16)
15:1/0/terrains_peering_bit/right_side = 0
15:1/0/terrains_peering_bit/bottom_side = 0
15:1/0/terrains_peering_bit/bottom_left_corner = 0
15:1/0/terrains_peering_bit/top_side = 0
15:1/0/terrains_peering_bit/top_right_corner = 0
16:1/0 = 0
16:1/0/terrain_set = 0
16:1/0/terrain = 0
16:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16)
16:1/0/terrains_peering_bit/bottom_right_corner = 0
16:1/0/terrains_peering_bit/bottom_side = 0
16:1/0/terrains_peering_bit/left_side = 0
16:1/0/terrains_peering_bit/top_left_corner = 0
16:1/0/terrains_peering_bit/top_side = 0
0:2/0 = 0
0:2/0/terrain_set = 0
0:2/0/terrain = 0
0:2/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16)
0:2/0/terrains_peering_bit/right_side = 0
0:2/0/terrains_peering_bit/top_side = 0
0:2/0/terrains_peering_bit/top_right_corner = 0
1:2/0 = 0
1:2/0/terrain_set = 0
1:2/0/terrain = 0
1:2/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16)
1:2/0/terrains_peering_bit/right_side = 0
1:2/0/terrains_peering_bit/left_side = 0
1:2/0/terrains_peering_bit/top_left_corner = 0
1:2/0/terrains_peering_bit/top_side = 0
1:2/0/terrains_peering_bit/top_right_corner = 0
2:2/0 = 0
2:2/0/terrain_set = 0
2:2/0/terrain = 0
2:2/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16)
2:2/0/terrains_peering_bit/left_side = 0
2:2/0/terrains_peering_bit/top_left_corner = 0
2:2/0/terrains_peering_bit/top_side = 0
4:2/0 = 0
4:2/0/terrain_set = 0
4:2/0/terrain = 0
4:2/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16)
4:2/0/terrains_peering_bit/top_side = 0
6:3/0 = 0
6:3/0/terrain_set = 0
6:3/0/terrain = 0
6:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(16, 16, -16, 16, -16, -16, 0, -16, 0, 0, 16, 0)
6:3/0/terrains_peering_bit/right_side = 0
6:3/0/terrains_peering_bit/bottom_side = 0
6:3/0/terrains_peering_bit/top_side = 0
6:3/0/terrains_peering_bit/top_right_corner = 0
7:3/0 = 0
7:3/0/terrain_set = 0
7:3/0/terrain = 0
7:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, 16, 16, 16, 16, -16, 0, -16, 0, 0, -16, 0)
7:3/0/terrains_peering_bit/bottom_side = 0
7:3/0/terrains_peering_bit/left_side = 0
7:3/0/terrains_peering_bit/top_left_corner = 0
7:3/0/terrains_peering_bit/top_side = 0
9:3/0 = 0
9:3/0/terrain_set = 0
9:3/0/terrain = 0
9:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, 0, 16, 0, 0, -16, 0)
9:3/0/terrains_peering_bit/bottom_side = 0
9:3/0/terrains_peering_bit/bottom_left_corner = 0
9:3/0/terrains_peering_bit/left_side = 0
10:3/0 = 0
10:3/0/terrain_set = 0
10:3/0/terrain = 0
10:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(16, -16, -16, -16, -16, 16, 0, 16, 0, 0, 16, 0)
10:3/0/terrains_peering_bit/right_side = 0
10:3/0/terrains_peering_bit/bottom_right_corner = 0
10:3/0/terrains_peering_bit/bottom_side = 0
12:3/0 = 0
12:3/0/terrain_set = 0
12:3/0/terrain = 0
12:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(16, -16, 16, 16, -16, 16, -16, -16)
12:3/0/terrains_peering_bit/right_side = 0
12:3/0/terrains_peering_bit/bottom_side = 0
12:3/0/terrains_peering_bit/top_side = 0
13:3/0 = 0
13:3/0/terrain_set = 0
13:3/0/terrain = 0
13:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(16, -16, 16, 16, -16, 16, -16, -16)
13:3/0/terrains_peering_bit/right_side = 0
13:3/0/terrains_peering_bit/bottom_side = 0
13:3/0/terrains_peering_bit/left_side = 0
15:3/0 = 0
15:3/0/terrain_set = 0
15:3/0/terrain = 0
15:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(16, -16, 16, 16, -16, 16, -16, -16)
15:3/0/terrains_peering_bit/right_side = 0
15:3/0/terrains_peering_bit/bottom_side = 0
16:3/0 = 0
16:3/0/terrain_set = 0
16:3/0/terrain = 0
16:3/0/physics_layer_0/polygon_0/points = PackedVector2Array(16, -16, 16, 16, -16, 16, -16, -16)
16:3/0/terrains_peering_bit/bottom_side = 0
16:3/0/terrains_peering_bit/left_side = 0
0:4/0 = 0
0:4/0/terrain_set = 0
0:4/0/terrain = 0
0:4/0/physics_layer_0/polygon_0/points = PackedVector2Array(16, -16, -16, -16, -16, 16, 16, 16)
0:4/0/terrains_peering_bit/right_side = 0
1:4/0 = 0
1:4/0/terrain_set = 0
1:4/0/terrain = 0
1:4/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16)
1:4/0/terrains_peering_bit/right_side = 0
1:4/0/terrains_peering_bit/left_side = 0
2:4/0 = 0
2:4/0/terrain_set = 0
2:4/0/terrain = 0
2:4/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16)
2:4/0/terrains_peering_bit/left_side = 0
4:4/0 = 0
4:4/0/terrain_set = 0
4:4/0/terrain = 0
4:4/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, -16, 16)
6:4/0 = 0
6:4/0/terrain_set = 0
6:4/0/terrain = 0
6:4/0/physics_layer_0/polygon_0/points = PackedVector2Array(16, -16, -16, -16, -16, 16, 0, 16, 0, 0, 16, 0)
6:4/0/terrains_peering_bit/right_side = 0
6:4/0/terrains_peering_bit/bottom_right_corner = 0
6:4/0/terrains_peering_bit/bottom_side = 0
6:4/0/terrains_peering_bit/top_side = 0
7:4/0 = 0
7:4/0/terrain_set = 0
7:4/0/terrain = 0
7:4/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, -16, 16, -16, 16, 16, 0, 16, 0, 0, -16, 0)
7:4/0/terrains_peering_bit/bottom_side = 0
7:4/0/terrains_peering_bit/bottom_left_corner = 0
7:4/0/terrains_peering_bit/left_side = 0
7:4/0/terrains_peering_bit/top_side = 0
9:4/0 = 0
9:4/0/terrain_set = 0
9:4/0/terrain = 0
9:4/0/physics_layer_0/polygon_0/points = PackedVector2Array(-16, 16, 16, 16, 16, -16, 0, -16, 0, 0, -16, 0)
9:4/0/terrains_peering_bit/left_side = 0
9:4/0/terrains_peering_bit/top_left_corner = 0
9:4/0/terrains_peering_bit/top_side = 0
10:4/0 = 0
10:4/0/terrain_set = 0
10:4/0/terrain = 0
10:4/0/physics_layer_0/polygon_0/points = PackedVector2Array(16, 16, -16, 16, -16, -16, 0, -16, 0, 0, 16, 0)
10:4/0/terrains_peering_bit/right_side = 0
10:4/0/terrains_peering_bit/top_side = 0
10:4/0/terrains_peering_bit/top_right_corner = 0
12:4/0 = 0
12:4/0/terrain_set = 0
12:4/0/terrain = 0
12:4/0/physics_layer_0/polygon_0/points = PackedVector2Array(16, -16, 16, 16, -16, 16, -16, -16)
12:4/0/terrains_peering_bit/right_side = 0
12:4/0/terrains_peering_bit/left_side = 0
12:4/0/terrains_peering_bit/top_side = 0
13:4/0 = 0
13:4/0/terrain_set = 0
13:4/0/terrain = 0
13:4/0/physics_layer_0/polygon_0/points = PackedVector2Array(16, -16, 16, 16, -16, 16, -16, -16)
13:4/0/terrains_peering_bit/bottom_side = 0
13:4/0/terrains_peering_bit/left_side = 0
13:4/0/terrains_peering_bit/top_side = 0
15:4/0 = 0
15:4/0/terrain_set = 0
15:4/0/terrain = 0
15:4/0/physics_layer_0/polygon_0/points = PackedVector2Array(16, -16, 16, 16, -16, 16, -16, -16)
15:4/0/terrains_peering_bit/right_side = 0
15:4/0/terrains_peering_bit/top_side = 0
16:4/0 = 0
16:4/0/terrain_set = 0
16:4/0/terrain = 0
16:4/0/physics_layer_0/polygon_0/points = PackedVector2Array(16, -16, 16, 16, -16, 16, -16, -16)
16:4/0/terrains_peering_bit/left_side = 0
16:4/0/terrains_peering_bit/top_side = 0
[sub_resource type="TileSet" id="TileSet_vbomn"]
tile_size = Vector2i(32, 32)
physics_layer_0/collision_layer = 1
terrain_set_0/mode = 0
terrain_set_0/terrain_0/name = "Ground 0"
terrain_set_0/terrain_0/color = Color(0.5, 0.34375, 0.25, 1)
terrain_set_1/mode = 0
terrain_set_1/terrain_0/name = "Sky"
terrain_set_1/terrain_0/color = Color(0, 0.701961, 0.917647, 1)
sources/0 = SubResource("TileSetAtlasSource_bdyqk")
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_vdfbk"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_lbd3t"]
size = Vector2(20, 4.47115)
[node name="Game" type="Node2D"]
[node name="Background" type="Parallax2D" parent="."]
texture_filter = 1
scroll_scale = Vector2(0.5, 1)
repeat_size = Vector2(320, 0)
repeat_times = 4
[node name="Sprite2D" type="Sprite2D" parent="Background"]
texture_filter = 1
position = Vector2(160, 90)
texture = ExtResource("1_tnlsl")
[node name="Sprite2D2" type="Sprite2D" parent="Background"]
texture_filter = 1
position = Vector2(160, -128.25)
scale = Vector2(1, 51.5)
texture = ExtResource("2_6ci1w")
[node name="Clouds" type="Parallax2D" parent="."]
scroll_scale = Vector2(0.1, 0.1)
repeat_size = Vector2(320, 0)
repeat_times = 4
[node name="Sprite2D" type="Sprite2D" parent="Clouds"]
texture_filter = 1
position = Vector2(160, 90)
texture = ExtResource("3_uqjdf")
[node name="Grass" type="Parallax2D" parent="."]
scroll_scale = Vector2(0.8, 0.8)
repeat_size = Vector2(320, 0)
repeat_times = 3
[node name="Sprite2D" type="Sprite2D" parent="Grass"]
texture_filter = 1
position = Vector2(160, 90)
texture = ExtResource("4_71wd1")
[node name="Midground" type="Parallax2D" parent="."]
repeat_size = Vector2(320, 0)
repeat_times = 4
[node name="Sprite2D" type="Sprite2D" parent="Midground"]
texture_filter = 1
position = Vector2(160, 90)
texture = ExtResource("5_b0wjm")
[node name="TileMapLayer" type="TileMapLayer" parent="."]
texture_filter = 1
position = Vector2(918, 72)
tile_map_data = PackedByteArray("AADx/wMAAAACAAAAAADw/wMAAAABAAAAAADv/wMAAAABAAAAAADu/wMAAAABAAAAAADt/wMAAAABAAAAAADs/wMAAAABAAAAAADr/wMAAAABAAAAAADq/wMAAAABAAAAAADp/wMAAAABAAAAAADo/wMAAAABAAAAAADn/wMAAAABAAAAAADm/wMAAAABAAAAAADl/wMAAAABAAAAAADk/wMAAAABAAAAAADj/wMAAAAAAAAAAADj/wQAAAAAAAIAAADk/wQAAAABAAIAAADl/wQAAAABAAIAAADm/wQAAAABAAIAAADn/wQAAAABAAIAAADo/wQAAAABAAIAAADp/wQAAAABAAIAAADq/wQAAAABAAIAAADr/wQAAAABAAIAAADs/wQAAAABAAIAAADt/wQAAAABAAIAAADu/wQAAAABAAIAAADv/wQAAAABAAIAAADw/wQAAAABAAIAAADx/wQAAAACAAIAAADs////AAAEAAQAAADq/wAAAAACAAQAAADp/wAAAAAAAAQAAADu//7/AAAAAAQAAADv//7/AAABAAQAAADw//7/AAABAAQAAADx//7/AAACAAQAAADn/wEAAAAEAAQAAADl////AAACAAQAAADk////AAAAAAQAAADi//3/AAAEAAQAAADz/wAAAAAEAAQAAADv/wEAAAAAAAQAAADw/wEAAAACAAQAAAA=")
tile_set = SubResource("TileSet_vbomn")
[node name="SceneManager" type="Node" parent="."]
unique_name_in_owner = true
script = ExtResource("7_3s0ov")
[node name="CharacterBody2D" parent="." instance=ExtResource("8_ctqq8")]
position = Vector2(139, 80)
[node name="Box" parent="." groups=["shootable"] instance=ExtResource("9_b3256")]
position = Vector2(315, 140)
[node name="Box2" parent="." groups=["shootable"] instance=ExtResource("9_b3256")]
position = Vector2(60, -18)
[node name="Box3" parent="." groups=["shootable"] instance=ExtResource("9_b3256")]
position = Vector2(98, 142)
[node name="StaticBody2D" type="StaticBody2D" parent="."]
position = Vector2(142, 181)
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"]
shape = SubResource("WorldBoundaryShape2D_vdfbk")
[node name="Area2D" type="Area2D" parent="."]
position = Vector2(232, 291)
scale = Vector2(24.2, 4.16)
script = ExtResource("10_c8glf")
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
position = Vector2(0, -7.76443)
shape = SubResource("RectangleShape2D_lbd3t")
debug_color = Color(0.31865, 0.625237, 0, 0.42)
[node name="Coins" type="Node" parent="."]
[node name="Coin" parent="Coins" instance=ExtResource("11_0vqln")]
position = Vector2(54, 26)
metadata/_edit_group_ = true
[node name="Coin3" parent="Coins" instance=ExtResource("11_0vqln")]
position = Vector2(-29, -40)
metadata/_edit_group_ = true
[node name="Coin4" parent="Coins" instance=ExtResource("11_0vqln")]
position = Vector2(437, -7)
metadata/_edit_group_ = true
[node name="Coin7" parent="Coins" instance=ExtResource("11_0vqln")]
position = Vector2(377, -6)
metadata/_edit_group_ = true
[node name="Coin6" parent="Coins" instance=ExtResource("11_0vqln")]
position = Vector2(421, 93)
metadata/_edit_group_ = true
[node name="Coin5" parent="Coins" instance=ExtResource("11_0vqln")]
position = Vector2(212, 60)
metadata/_edit_group_ = true
[node name="Coin2" parent="Coins" instance=ExtResource("11_0vqln")]
position = Vector2(517, 59)
metadata/_edit_group_ = true
[node name="BadGuys" type="Node" parent="."]
[node name="BadGuy" parent="BadGuys" instance=ExtResource("12_hwoa7")]
position = Vector2(390, 91)
metadata/_edit_group_ = true
[node name="BadGuy2" parent="BadGuys" instance=ExtResource("12_hwoa7")]
position = Vector2(40, 23)
metadata/_edit_group_ = true
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="Control" parent="CanvasLayer" instance=ExtResource("13_7qh3f")]
[connection signal="body_entered" from="Area2D" to="Area2D" method="_on_body_entered"]

50
fabigame/scenes/ui.tscn Normal file
View File

@ -0,0 +1,50 @@
[gd_scene load_steps=2 format=3 uid="uid://bj4sdxqrlfr02"]
[ext_resource type="Script" path="res://scripts/ui.gd" id="1_xocjg"]
[node name="Control" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_xocjg")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
grow_horizontal = 2
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
layout_mode = 2
[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="Health" type="Label" parent="VBoxContainer/HBoxContainer/MarginContainer"]
texture_filter = 1
layout_mode = 2
text = "Health: 100"
[node name="MarginContainer3" type="MarginContainer" parent="VBoxContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="Timer" type="Label" parent="VBoxContainer/HBoxContainer/MarginContainer3"]
texture_filter = 1
layout_mode = 2
text = "Timer: "
horizontal_alignment = 1
[node name="MarginContainer2" type="MarginContainer" parent="VBoxContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="Coins" type="Label" parent="VBoxContainer/HBoxContainer/MarginContainer2"]
texture_filter = 1
layout_mode = 2
text = "Coins: 0"
horizontal_alignment = 2

View File

@ -9,6 +9,8 @@ const PUSHFORCE = 750
@onready var right_ray: RayCast2D = $RightRay @onready var right_ray: RayCast2D = $RightRay
@onready var left_ray: RayCast2D = $LeftRay @onready var left_ray: RayCast2D = $LeftRay
@onready var playerSprite: AnimatedSprite2D = $AnimatedSprite2D @onready var playerSprite: AnimatedSprite2D = $AnimatedSprite2D
@onready var key: Sprite2D = $Key
var faceLeft = false var faceLeft = false
@ -25,8 +27,10 @@ signal playerDead
@onready var right_target: Node2D = $RightTarget @onready var right_target: Node2D = $RightTarget
@onready var left_target: Node2D = $LeftTarget @onready var left_target: Node2D = $LeftTarget
func _ready() -> void:
keyDrop()
func hurtPlayer(amt): func hurtPlayer(amt):
print("Character knows it should be hurt")
animPlaying = "hurt" animPlaying = "hurt"
playerSprite.play("Hurt") playerSprite.play("Hurt")
@ -37,6 +41,10 @@ func killPlayer():
animPlaying = "dead" animPlaying = "dead"
playerSprite.play("Dead") playerSprite.play("Dead")
func keyCollected():
print("Player knows key")
key.visible = true
func _physics_process(delta: float) -> void: func _physics_process(delta: float) -> void:
if living and not animPlaying =="hurt": if living and not animPlaying =="hurt":
# Add the gravity. # Add the gravity.
@ -96,24 +104,20 @@ func _physics_process(delta: float) -> void:
move_and_slide() move_and_slide()
if right_ray.is_colliding(): if right_ray.is_colliding():
print("Something is on my right")
if not faceLeft: if not faceLeft:
var collider = right_ray.get_collider() var collider = right_ray.get_collider()
if collider is Node: if collider is Node:
if collider.is_in_group("box"): if collider.is_in_group("box"):
print("This is a pushable box")
pushTarget = collider pushTarget = collider
pushRightEnabled = true pushRightEnabled = true
else: else:
pushRightEnabled = false pushRightEnabled = false
if left_ray.is_colliding(): if left_ray.is_colliding():
print("Something is on my left")
if faceLeft: if faceLeft:
var collider = left_ray.get_collider() var collider = left_ray.get_collider()
if collider is Node: if collider is Node:
if collider.is_in_group("box"): if collider.is_in_group("box"):
print("I can shove this box")
pushTarget = collider pushTarget = collider
pushLefEnabled = true pushLefEnabled = true
else: else:

View File

@ -2,22 +2,50 @@ extends Node
var coinsCollected:int = 0 var coinsCollected:int = 0
var player:Resource var player:Resource
var totalCoinsLevel: = 0
var levels = ["res://scenes/game.tscn","res://scenes/game_level2.tscn"]
var timers = [5, 10]
var currentLevel = 0
var gameSeconds = 0
var gotKey = false
signal playerHurt() signal playerHurt()
signal playerDeath() signal playerDeath()
signal coinsUpdate(amt, total)
signal levelComplete(level)
signal tick(seconds)
signal playerOptions(key)
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready() -> void: func _ready() -> void:
player = load("res://scripts/res/dudestats.tres") player = load("res://scripts/res/dudestats.tres")
func setTotalCoins(amt):
totalCoinsLevel = amt
coinsUpdate.emit(coinsCollected, totalCoinsLevel)
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void: func _process(delta: float) -> void:
pass pass
func keyCollected():
print("GameController knows player has key")
func coinCollected(): func coinCollected():
coinsCollected +=1 coinsCollected +=1
print("Total coins collected "+str(coinsCollected) ) print("Total coins collected "+str(coinsCollected) )
coinsUpdate.emit(coinsCollected, totalCoinsLevel)
#did you complete the level?
if coinsCollected >= totalCoinsLevel:
#level complete
currentLevel +=1
if currentLevel < levels.size():
levelComplete.emit(levels[currentLevel])
else:
currentLevel = 0
levelComplete.emit(levels[currentLevel])
func playerDamage(): func playerDamage():
if player.health > 0: if player.health > 0:
@ -27,8 +55,18 @@ func playerDamage():
playerDeath.emit() playerDeath.emit()
else: else:
##damage him ##damage him
playerHurt.emit(20) playerHurt.emit(player.health)
func reset(): func reset():
gameSeconds = 0
player.health = player.max_health player.health = player.max_health
coinsCollected = 0 coinsCollected = 0
func timeOut():
gameSeconds +=1
if gameSeconds >= timers[currentLevel]:
playerDeath.emit()
tick.emit(timers[currentLevel] - gameSeconds)
func sendOptions():
playerOptions.emit(gotKey)

View File

@ -3,31 +3,55 @@ extends Node
var bulletsFiredTotal := 0 var bulletsFiredTotal := 0
var bulletsMadeTotal := 0 var bulletsMadeTotal := 0
var bulletArray:Array = [] var bulletArray:Array = []
var timer:= Timer.new()
@onready var coins: Node = $"../Coins" @onready var coins: Node = $"../Coins"
@onready var bad_guys: Node = $"../BadGuys" @onready var bad_guys: Node = $"../BadGuys"
@onready var player: CharacterBody2D = $"../CharacterBody2D" @onready var player: CharacterBody2D = $"../CharacterBody2D"
@onready var ui: Control = $"../CanvasLayer/Control"
@onready var key_trigger: Area2D = $"../KeyTrigger"
var bullet = preload("res://scenes/bullet.tscn") var bullet = preload("res://scenes/bullet.tscn")
func _ready() -> void: func _ready() -> void:
add_child(timer)
timer.wait_time = 1
timer.one_shot = false
timer.connect("timeout", GameController.timeOut)
timer.start()
var totalCoins = 0
var totalEnemies = 0
### coins loop ### coins loop
for n in coins.get_children(): for n in coins.get_children():
print("coin found") totalCoins +=1
n.coinCollected.connect(GameController.coinCollected) n.coinCollected.connect(GameController.coinCollected)
### enemies loop ### enemies loop
for n in bad_guys.get_children(): for n in bad_guys.get_children():
print("enemy found") totalEnemies +=1
n.playerDamage.connect(GameController.playerDamage) n.playerDamage.connect(GameController.playerDamage)
### wire up GameController signals to Player ### wire up GameController signals to Player
GameController.playerHurt.connect(hurtPlayer) GameController.playerHurt.connect(hurtPlayer)
GameController.playerHurt.connect(ui.healthUpdate)
GameController.playerDeath.connect(killPlayer) GameController.playerDeath.connect(killPlayer)
GameController.levelComplete.connect(changeLevel)
GameController.tick.connect(ui.timerUpdate)
GameController.playerOptions.connect(showKey)
key_trigger.keyCollect.connect(GameController.keyCollected)
key_trigger.keyCollect.connect(player.keyCollected)
player.playerDead.connect(deadPlayer) player.playerDead.connect(deadPlayer)
GameController.coinsUpdate.connect(ui.coinsUpdate)
GameController.setTotalCoins(totalCoins)
GameController.sendOptions()
func bulletFactory(): func bulletFactory():
print("Make a bullet at the factory") print("Make a bullet at the factory")
@ -62,3 +86,13 @@ func deadPlayer():
GameController.reset() GameController.reset()
get_tree().reload_current_scene() get_tree().reload_current_scene()
func showKey(key):
if key == true:
player.keyCollected()
else:
player.keyDrop()
func changeLevel(level):
print("Scene manager should change level")
GameController.reset()
get_tree().change_scene_to_file(level)

View File

@ -0,0 +1,20 @@
extends Area2D
signal keyCollect
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func _on_body_entered(body: Node2D) -> void:
print("Triggered!")
if body.is_in_group("player"):
print("player entered area")
keyCollect.emit()

20
fabigame/scripts/ui.gd Normal file
View File

@ -0,0 +1,20 @@
extends Control
@onready var health: Label = $VBoxContainer/HBoxContainer/MarginContainer/Health
@onready var coins: Label = $VBoxContainer/HBoxContainer/MarginContainer2/Coins
@onready var timer: Label = $VBoxContainer/HBoxContainer/MarginContainer3/Timer
var tempCoinCount
var tempCoinTotal
func timerUpdate(amt):
timer.text = str(timer) + " s"
func healthUpdate(amt):
health.text=("Health: "+str(amt) )
func coinsUpdate(amt, total):
tempCoinCount = amt
tempCoinTotal = total
if coins:
coins.text = ("Coins: "+str(amt)+" / "+str(total) )
func _ready() -> void:
coins.text="Coins: "+str(tempCoinCount)+" / "+str(tempCoinTotal)