Add coins, enemy slime, and level reset.

This commit is contained in:
catherinehoang44 2026-07-27 21:13:29 -04:00
parent 8f29753f2e
commit 0c52a8d411
36 changed files with 970 additions and 41 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dm8y5y1wgcatm"
path="res://.godot/imported/slime_purple.png-05342f028a3ed4787f049c56662dff25.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/Enemy/Slime/slime_purple.png"
dest_files=["res://.godot/imported/slime_purple.png-05342f028a3ed4787f049c56662dff25.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b73qg48wsqvai"
path="res://.godot/imported/foreground.png-d037a775d391d8a623162bf3c34b45fd.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/Environment/BG/foreground.png"
dest_files=["res://.godot/imported/foreground.png-d037a775d391d8a623162bf3c34b45fd.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cg22tty2vuet8"
path="res://.godot/imported/midground.png-b73bfa7973b29ce70529610c0fcee36a.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/Environment/BG/midground.png"
dest_files=["res://.godot/imported/midground.png-b73bfa7973b29ce70529610c0fcee36a.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dca0bekdpu84"
path="res://.godot/imported/sky.png-04be5dec4115e2a8c1565aa6453b467f.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/Environment/BG/sky.png"
dest_files=["res://.godot/imported/sky.png-04be5dec4115e2a8c1565aa6453b467f.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dl14otm4thnq2"
path="res://.godot/imported/mushroom_32x64.png-e8c947fe836480d74eafa4339d8b25e2.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/Environment/Veges/mushroom_32x64.png"
dest_files=["res://.godot/imported/mushroom_32x64.png-e8c947fe836480d74eafa4339d8b25e2.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 675 B

View File

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c7bikbpg5swtd"
path="res://.godot/imported/veg_32x32.png-33598d1a116938a361ee88ef51853556.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/Environment/Veges/veg_32x32.png"
dest_files=["res://.godot/imported/veg_32x32.png-33598d1a116938a361ee88ef51853556.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

BIN
Assets/Pickups/coin.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

View File

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cwwd4so0n5pvj"
path="res://.godot/imported/coin.png-68afc91fbe73f1b68f19b37608cb950d.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/Pickups/coin.png"
dest_files=["res://.godot/imported/coin.png-68afc91fbe73f1b68f19b37608cb950d.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dv3636ow2ps4y"
path="res://.godot/imported/Player Death 64x64.png-1d0c7aaeaff12f048994ed26b4b99e61.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/Player/Dead/Player Death 64x64.png"
dest_files=["res://.godot/imported/Player Death 64x64.png-1d0c7aaeaff12f048994ed26b4b99e61.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://4xlu4usnkkhq"
path="res://.godot/imported/Player Hurt 48x48.png-b7d8d4a9d50a3c32f0eed604c9bb8a60.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/Player/Hurt/Player Hurt 48x48.png"
dest_files=["res://.godot/imported/Player Hurt 48x48.png-b7d8d4a9d50a3c32f0eed604c9bb8a60.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

@ -20,3 +20,5 @@ position = Vector2(-2.9999998, -1.9999999)
rotation = 3.1415927 rotation = 3.1415927
scale = Vector2(0.08, 0.08) scale = Vector2(0.08, 0.08)
texture = ExtResource("2_oduel") texture = ExtResource("2_oduel")
[connection signal="area_entered" from="." to="." method="_on_body_entered"]

7
Scenes/coin.gd Normal file
View File

@ -0,0 +1,7 @@
class_name Coin extends Area2D
signal coinCollectedSignal(body,coin)
func _on_body_entered(body: Node2D):
if body is Player:
print("player hit coin")
coinCollectedSignal.emit(body,self)

1
Scenes/coin.gd.uid Normal file
View File

@ -0,0 +1 @@
uid://ckjfv5xy1he2u

116
Scenes/coin.tscn Normal file
View File

@ -0,0 +1,116 @@
[gd_scene format=3 uid="uid://0d4qe2gqj0g7"]
[ext_resource type="Script" uid="uid://ckjfv5xy1he2u" path="res://Scenes/coin.gd" id="1_2qo34"]
[ext_resource type="Texture2D" uid="uid://cwwd4so0n5pvj" path="res://Assets/Pickups/coin.png" id="2_jgi06"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_sgwqp"]
size = Vector2(10, 4)
[sub_resource type="AtlasTexture" id="AtlasTexture_g537i"]
atlas = ExtResource("2_jgi06")
region = Rect2(0, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_h2p6v"]
atlas = ExtResource("2_jgi06")
region = Rect2(16, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_ffmqm"]
atlas = ExtResource("2_jgi06")
region = Rect2(32, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_81h6x"]
atlas = ExtResource("2_jgi06")
region = Rect2(48, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_qbp07"]
atlas = ExtResource("2_jgi06")
region = Rect2(64, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_2l7mo"]
atlas = ExtResource("2_jgi06")
region = Rect2(80, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_q30xt"]
atlas = ExtResource("2_jgi06")
region = Rect2(96, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_7w2r2"]
atlas = ExtResource("2_jgi06")
region = Rect2(112, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_tthw5"]
atlas = ExtResource("2_jgi06")
region = Rect2(128, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_6pu15"]
atlas = ExtResource("2_jgi06")
region = Rect2(144, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_vgc30"]
atlas = ExtResource("2_jgi06")
region = Rect2(160, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_qtgto"]
atlas = ExtResource("2_jgi06")
region = Rect2(176, 0, 16, 16)
[sub_resource type="SpriteFrames" id="SpriteFrames_oov8j"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_g537i")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_h2p6v")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ffmqm")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_81h6x")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_qbp07")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_2l7mo")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_q30xt")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_7w2r2")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_tthw5")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_6pu15")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_vgc30")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_qtgto")
}],
"loop": 1,
"name": &"coin_twirl",
"speed": 12.0
}]
[node name="coin" type="Area2D" unique_id=1463876970]
script = ExtResource("1_2qo34")
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=282956551]
scale = Vector2(-1.0499984, 2.3999982)
shape = SubResource("RectangleShape2D_sgwqp")
debug_color = Color(0.9064841, 0.22817236, 0.5106338, 0.41960785)
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." unique_id=1656877505]
texture_filter = 1
scale = Vector2(1.0200001, 0.9375)
sprite_frames = SubResource("SpriteFrames_oov8j")
animation = &"coin_twirl"
autoplay = "coin_twirl"
[connection signal="body_entered" from="." to="." method="_on_body_entered"]

View File

@ -1,11 +1,17 @@
[gd_scene format=4 uid="uid://bportqr2j3d7s"] [gd_scene format=4 uid="uid://bportqr2j3d7s"]
[ext_resource type="Script" uid="uid://cvrssvw6p8myl" path="res://Scripts/game.gd" id="1_wrm1d"]
[ext_resource type="Script" uid="uid://bfh1ec3bb5oki" path="res://Scripts/scene_manager.gd" id="2_3dryh"] [ext_resource type="Script" uid="uid://bfh1ec3bb5oki" path="res://Scripts/scene_manager.gd" id="2_3dryh"]
[ext_resource type="Texture2D" uid="uid://dca0bekdpu84" path="res://Assets/Environment/BG/sky.png" id="2_h4fw4"]
[ext_resource type="Texture2D" uid="uid://fdttdiukun15" path="res://Assets/Environment/Terrain (32x32).png" id="2_i6g32"] [ext_resource type="Texture2D" uid="uid://fdttdiukun15" path="res://Assets/Environment/Terrain (32x32).png" id="2_i6g32"]
[ext_resource type="PackedScene" uid="uid://dyb6tnhpivflf" path="res://Scenes/trigger.tscn" id="3_i6g32"] [ext_resource type="PackedScene" uid="uid://dyb6tnhpivflf" path="res://Scenes/trigger.tscn" id="3_i6g32"]
[ext_resource type="Texture2D" uid="uid://cg22tty2vuet8" path="res://Assets/Environment/BG/midground.png" id="3_ldgsr"]
[ext_resource type="Texture2D" uid="uid://c7bikbpg5swtd" path="res://Assets/Environment/Veges/veg_32x32.png" id="3_v158k"]
[ext_resource type="PackedScene" uid="uid://b5y6rb2t0eaqr" path="res://Scenes/crate.tscn" id="3_wowpa"] [ext_resource type="PackedScene" uid="uid://b5y6rb2t0eaqr" path="res://Scenes/crate.tscn" id="3_wowpa"]
[ext_resource type="Texture2D" uid="uid://dl14otm4thnq2" path="res://Assets/Environment/Veges/mushroom_32x64.png" id="4_h4fw4"]
[ext_resource type="Texture2D" uid="uid://b73qg48wsqvai" path="res://Assets/Environment/BG/foreground.png" id="4_o5yvi"]
[ext_resource type="PackedScene" uid="uid://en40721f6qwj" path="res://Scenes/player.tscn" id="4_wowpa"] [ext_resource type="PackedScene" uid="uid://en40721f6qwj" path="res://Scenes/player.tscn" id="4_wowpa"]
[ext_resource type="PackedScene" uid="uid://0d4qe2gqj0g7" path="res://Scenes/coin.tscn" id="12_rku1e"]
[ext_resource type="PackedScene" uid="uid://cirhfajnm0tgv" path="res://Scenes/slime.tscn" id="13_rfjv2"]
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_1l0tm"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_1l0tm"]
texture = ExtResource("2_i6g32") texture = ExtResource("2_i6g32")
@ -356,28 +362,79 @@ texture_region_size = Vector2i(32, 32)
16:4/0/terrains_peering_bit/left_side = 0 16:4/0/terrains_peering_bit/left_side = 0
16:4/0/terrains_peering_bit/top_side = 0 16:4/0/terrains_peering_bit/top_side = 0
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_ldgsr"]
texture = ExtResource("3_v158k")
texture_region_size = Vector2i(32, 32)
0:0/0 = 0
0:0/0/terrain_set = 0
0:0/0/terrain = 1
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_o5yvi"]
texture = ExtResource("4_h4fw4")
texture_region_size = Vector2i(32, 32)
0:0/0 = 0
0:0/0/terrain_set = 0
0:0/0/terrains_peering_bit/bottom_side = 1
0:1/0 = 0
0:1/0/terrain_set = 0
0:1/0/terrain = 1
0:1/0/terrains_peering_bit/top_side = 1
[sub_resource type="TileSet" id="TileSet_v158k"] [sub_resource type="TileSet" id="TileSet_v158k"]
tile_size = Vector2i(32, 32) tile_size = Vector2i(32, 32)
physics_layer_0/collision_layer = 1 physics_layer_0/collision_layer = 1
terrain_set_0/mode = 0 terrain_set_0/mode = 0
terrain_set_0/terrain_0/name = "LeafyGreen" terrain_set_0/terrain_0/name = "LeafyGreen"
terrain_set_0/terrain_0/color = Color(0.5, 0.34375, 0.25, 1) terrain_set_0/terrain_0/color = Color(0.5, 0.34375, 0.25, 1)
terrain_set_0/terrain_1/name = "Veg"
terrain_set_0/terrain_1/color = Color(0.5, 0.4375, 0.25, 1)
sources/0 = SubResource("TileSetAtlasSource_1l0tm") sources/0 = SubResource("TileSetAtlasSource_1l0tm")
sources/1 = SubResource("TileSetAtlasSource_ldgsr")
sources/2 = SubResource("TileSetAtlasSource_o5yvi")
[sub_resource type="RectangleShape2D" id="RectangleShape2D_2poj3"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_2poj3"]
[node name="Game" type="Node2D" unique_id=1651082265] [node name="Game" type="Node2D" unique_id=1651082265]
script = ExtResource("1_wrm1d")
[node name="bg" type="Node2D" parent="." unique_id=511849296]
[node name="sky" type="Parallax2D" parent="bg" unique_id=377970151]
repeat_size = Vector2(480, 270)
[node name="Sprite2D" type="Sprite2D" parent="bg/sky" unique_id=41190636]
texture = ExtResource("2_h4fw4")
offset = Vector2(240, 135)
[node name="midground" type="Parallax2D" parent="bg" unique_id=727091655]
texture_filter = 1
scroll_scale = Vector2(1.05, 1)
repeat_size = Vector2(420, 0)
[node name="Sprite2D" type="Sprite2D" parent="bg/midground" unique_id=348870820]
texture = ExtResource("3_ldgsr")
offset = Vector2(240, 200)
[node name="foreground" type="Parallax2D" parent="bg" unique_id=1915745737]
texture_filter = 1
scroll_scale = Vector2(1.5, 1)
repeat_size = Vector2(480, 0)
[node name="Sprite2D" type="Sprite2D" parent="bg/foreground" unique_id=814408590]
texture = ExtResource("4_o5yvi")
offset = Vector2(240, 260)
[node name="TileMapLayer" type="TileMapLayer" parent="." unique_id=1853393222] [node name="TileMapLayer" type="TileMapLayer" parent="." unique_id=1853393222]
tile_map_data = PackedByteArray("AAAOAA4AAAAPAAQAAAAPAA4AAAABAAQAAAAQAA4AAAABAAQAAAARAA4AAAABAAQAAAASAA4AAAAQAAQAAAANABEAAAABAAAAAAAOABEAAAABAAAAAAANABIAAAAHAAAAAAAOABIAAAAGAAAAAAAPABIAAAAGAAAAAAAPABEAAAABAAAAAAALAA8AAAACAAAAAAALABAAAAAGAAEAAAAMABAAAAACAAAAAAAQABEAAAACAAAAAAAQABIAAAAGAAEAAAARABIAAAACAAAAAAATABMAAAAEAAQAAAAVABIAAAAAAAAAAAAWABIAAAAHAAEAAAAWABEAAAAAAAAAAAAVAA4AAAAPAAQAAAAWAA4AAAAKAAQAAAAWAA0AAAAAAAAAAAAXAA0AAAAJAAMAAAAYAA0AAAAQAAQAAAAXAA4AAAACAAIAAAAXABEAAAABAAAAAAAXABIAAAAGAAAAAAAVABMAAAAAAAIAAAAWABMAAAABAAIAAAAXABMAAAABAAIAAAAYABMAAAACAAIAAAAYABIAAAACAAEAAAAYABEAAAAJAAMAAAAZABAAAAAAAAAAAAAaABAAAAAGAAAAAAAZABEAAAAKAAQAAAAaABEAAAACAAIAAAAaAA8AAAAAAAAAAAAbAA8AAAACAAAAAAAbABAAAAACAAIAAAARABMAAAACAAIAAAAQABMAAAABAAIAAAAPABMAAAABAAIAAAAOABMAAAABAAIAAAALABEAAAABAAIAAAAMABEAAAAQAAEAAAAMABIAAAAAAAIAAAANABMAAAAAAAIAAAAKABAAAAAHAAAAAAAKABEAAAAAAAIAAAAJABAAAAAAAAIAAAAKAA8AAAABAAAAAAAJAA8AAAAAAAAAAAA=") texture_filter = 1
position = Vector2(-191, -185)
tile_map_data = PackedByteArray("AAAOAA4AAAAPAAQAAAAPAA4AAAABAAQAAAAQAA4AAAABAAQAAAARAA4AAAABAAQAAAASAA4AAAAQAAQAAAANABEAAAABAAAAAAAOABEAAAABAAAAAAANABIAAAAHAAAAAAAOABIAAAAGAAAAAAAPABIAAAAGAAAAAAAPABEAAAABAAAAAAALAA8AAAACAAAAAAALABAAAAAGAAEAAAAMABAAAAACAAAAAAAQABEAAAACAAAAAAAQABIAAAAGAAEAAAARABIAAAACAAAAAAATABMAAAAEAAQAAAAVABIAAAAAAAAAAAAWABIAAAAHAAEAAAAWABEAAAAAAAAAAAAVAA4AAAAPAAQAAAAWAA4AAAAKAAQAAAAWAA0AAAAAAAAAAAAXAA0AAAAJAAMAAAAYAA0AAAAQAAQAAAAXAA4AAAACAAIAAAAXABEAAAABAAAAAAAXABIAAAAGAAAAAAAVABMAAAAAAAIAAAAWABMAAAABAAIAAAAXABMAAAABAAIAAAAYABMAAAACAAIAAAAYABIAAAACAAEAAAAYABEAAAAJAAMAAAAZABAAAAAAAAAAAAAaABAAAAAGAAAAAAAZABEAAAAKAAQAAAAaABEAAAACAAIAAAAaAA8AAAAAAAAAAAAbAA8AAAACAAAAAAAbABAAAAACAAIAAAARABMAAAACAAIAAAAQABMAAAABAAIAAAAPABMAAAABAAIAAAAOABMAAAABAAIAAAALABEAAAABAAIAAAAMABEAAAAQAAEAAAAMABIAAAAAAAIAAAANABMAAAAAAAIAAAAKABAAAAAHAAAAAAAKABEAAAAAAAIAAAAJABAAAAAAAAIAAAAKAA8AAAABAAAAAAAJAA8AAAAAAAAAAAAYAAwAAQAAAAAAAAAPABAAAgAAAAEAAAAKAA4AAQAAAAAAAAAPAA8AAgAAAAAAAAATABIAAQAAAAAAAAA=")
tile_set = SubResource("TileSet_v158k") tile_set = SubResource("TileSet_v158k")
[node name="SceneManager" type="Node2D" parent="." unique_id=1701867043] [node name="SceneManager" type="Node2D" parent="." unique_id=1701867043]
position = Vector2(-191, -185)
script = ExtResource("2_3dryh") script = ExtResource("2_3dryh")
[node name="Floor" type="StaticBody2D" parent="." unique_id=1930890804] [node name="Floor" type="StaticBody2D" parent="." unique_id=1930890804]
position = Vector2(510, 308) position = Vector2(319, 123)
scale = Vector2(3.880005, 1) scale = Vector2(3.880005, 1)
metadata/_edit_group_ = true metadata/_edit_group_ = true
@ -385,7 +442,7 @@ metadata/_edit_group_ = true
shape = SubResource("RectangleShape2D_2poj3") shape = SubResource("RectangleShape2D_2poj3")
[node name="Floor4" type="StaticBody2D" parent="." unique_id=41291254] [node name="Floor4" type="StaticBody2D" parent="." unique_id=41291254]
position = Vector2(630, 305) position = Vector2(439, 120)
scale = Vector2(3.880005, 1) scale = Vector2(3.880005, 1)
metadata/_edit_group_ = true metadata/_edit_group_ = true
@ -393,7 +450,7 @@ metadata/_edit_group_ = true
shape = SubResource("RectangleShape2D_2poj3") shape = SubResource("RectangleShape2D_2poj3")
[node name="Floor2" type="StaticBody2D" parent="." unique_id=1987202329] [node name="Floor2" type="StaticBody2D" parent="." unique_id=1987202329]
position = Vector2(818.00006, 256) position = Vector2(627.00006, 71)
scale = Vector2(3.880005, 1) scale = Vector2(3.880005, 1)
metadata/_edit_group_ = true metadata/_edit_group_ = true
@ -401,7 +458,7 @@ metadata/_edit_group_ = true
shape = SubResource("RectangleShape2D_2poj3") shape = SubResource("RectangleShape2D_2poj3")
[node name="Floor3" type="StaticBody2D" parent="." unique_id=1726195228] [node name="Floor3" type="StaticBody2D" parent="." unique_id=1726195228]
position = Vector2(753.99994, 279) position = Vector2(562.99994, 94)
rotation = -0.69889295 rotation = -0.69889295
scale = Vector2(3.880005, 1) scale = Vector2(3.880005, 1)
metadata/_edit_group_ = true metadata/_edit_group_ = true
@ -410,12 +467,16 @@ metadata/_edit_group_ = true
shape = SubResource("RectangleShape2D_2poj3") shape = SubResource("RectangleShape2D_2poj3")
[node name="Trigger" parent="." unique_id=1055766094 instance=ExtResource("3_i6g32")] [node name="Trigger" parent="." unique_id=1055766094 instance=ExtResource("3_i6g32")]
position = Vector2(634, 534) position = Vector2(449, 311)
[node name="Player" parent="." unique_id=478864706 instance=ExtResource("4_wowpa")] [node name="Player" parent="." unique_id=478864706 instance=ExtResource("4_wowpa")]
position = Vector2(538.00006, 420) position = Vector2(347.00006, 235)
[node name="Camera2D" type="Camera2D" parent="Player" unique_id=1158692498]
offset = Vector2(0, -60)
[node name="Crates" type="Node2D" parent="." unique_id=799685623] [node name="Crates" type="Node2D" parent="." unique_id=799685623]
position = Vector2(-191, -185)
[node name="Crate" parent="Crates" unique_id=38246509 instance=ExtResource("3_wowpa")] [node name="Crate" parent="Crates" unique_id=38246509 instance=ExtResource("3_wowpa")]
position = Vector2(643, 387) position = Vector2(643, 387)
@ -424,6 +485,28 @@ position = Vector2(643, 387)
position = Vector2(716, 382) position = Vector2(716, 382)
[node name="Crate" parent="." unique_id=990352720 instance=ExtResource("3_wowpa")] [node name="Crate" parent="." unique_id=990352720 instance=ExtResource("3_wowpa")]
position = Vector2(585, 432) position = Vector2(394, 247)
[node name="Coins" type="Node2D" parent="." unique_id=218739547]
[node name="coin" parent="Coins" unique_id=1463876970 instance=ExtResource("12_rku1e")]
position = Vector2(284, 257)
[node name="coin2" parent="Coins" unique_id=572764533 instance=ExtResource("12_rku1e")]
position = Vector2(569, 219)
[node name="coin3" parent="Coins" unique_id=947271598 instance=ExtResource("12_rku1e")]
position = Vector2(534, 350)
[node name="Enemies" type="Node2D" parent="." unique_id=1647071497]
[node name="slime" parent="Enemies" unique_id=469808451 instance=ExtResource("13_rfjv2")]
position = Vector2(304, 250)
[node name="slime2" parent="Enemies" unique_id=1262992036 instance=ExtResource("13_rfjv2")]
position = Vector2(551, 219)
[node name="slime3" parent="Enemies" unique_id=1319056782 instance=ExtResource("13_rfjv2")]
position = Vector2(554, 348)
[connection signal="areaTriggerSignal" from="Trigger" to="." method="_on_trigger"] [connection signal="areaTriggerSignal" from="Trigger" to="." method="_on_trigger"]

View File

@ -3,8 +3,10 @@
[ext_resource type="Script" uid="uid://cq2vf132xjtli" path="res://Scripts/player.gd" id="1_v0iea"] [ext_resource type="Script" uid="uid://cq2vf132xjtli" path="res://Scripts/player.gd" id="1_v0iea"]
[ext_resource type="Texture2D" uid="uid://dr3u0hb58tj6x" path="res://Assets/Player/Idle/Player Idle 48x48.png" id="2_cvnsp"] [ext_resource type="Texture2D" uid="uid://dr3u0hb58tj6x" path="res://Assets/Player/Idle/Player Idle 48x48.png" id="2_cvnsp"]
[ext_resource type="Texture2D" uid="uid://edtnvpru6i3b" path="res://Assets/Player/Charging/Player Punch 64x64.png" id="2_fkybt"] [ext_resource type="Texture2D" uid="uid://edtnvpru6i3b" path="res://Assets/Player/Charging/Player Punch 64x64.png" id="2_fkybt"]
[ext_resource type="Texture2D" uid="uid://dv3636ow2ps4y" path="res://Assets/Player/Dead/Player Death 64x64.png" id="3_3smsa"]
[ext_resource type="Texture2D" uid="uid://cl4as81xv56wq" path="res://Assets/Player/Run/player run 48x48.png" id="3_6t5aa"] [ext_resource type="Texture2D" uid="uid://cl4as81xv56wq" path="res://Assets/Player/Run/player run 48x48.png" id="3_6t5aa"]
[ext_resource type="Texture2D" uid="uid://itpuf1wcu10i" path="res://Assets/Player/Jump_Fall/player jump 48x48.png" id="3_vgqql"] [ext_resource type="Texture2D" uid="uid://itpuf1wcu10i" path="res://Assets/Player/Jump_Fall/player jump 48x48.png" id="3_vgqql"]
[ext_resource type="Texture2D" uid="uid://4xlu4usnkkhq" path="res://Assets/Player/Hurt/Player Hurt 48x48.png" id="5_8erm5"]
[sub_resource type="CircleShape2D" id="CircleShape2D_ebmjs"] [sub_resource type="CircleShape2D" id="CircleShape2D_ebmjs"]
@ -12,10 +14,66 @@
atlas = ExtResource("2_fkybt") atlas = ExtResource("2_fkybt")
region = Rect2(128, 0, 64, 64) region = Rect2(128, 0, 64, 64)
[sub_resource type="AtlasTexture" id="AtlasTexture_y6uwr"]
atlas = ExtResource("3_3smsa")
region = Rect2(0, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_83xs0"]
atlas = ExtResource("3_3smsa")
region = Rect2(48, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_ypfnu"]
atlas = ExtResource("3_3smsa")
region = Rect2(96, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_xuaoq"]
atlas = ExtResource("3_3smsa")
region = Rect2(144, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_wohnl"]
atlas = ExtResource("3_3smsa")
region = Rect2(192, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_36dho"]
atlas = ExtResource("3_3smsa")
region = Rect2(240, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_yh6i2"]
atlas = ExtResource("3_3smsa")
region = Rect2(288, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_nv4vc"]
atlas = ExtResource("3_3smsa")
region = Rect2(336, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_8gxox"]
atlas = ExtResource("3_3smsa")
region = Rect2(384, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_11gg7"]
atlas = ExtResource("3_3smsa")
region = Rect2(432, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_bi64h"] [sub_resource type="AtlasTexture" id="AtlasTexture_bi64h"]
atlas = ExtResource("3_vgqql") atlas = ExtResource("3_vgqql")
region = Rect2(96, 0, 48, 48) region = Rect2(96, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_qpa8y"]
atlas = ExtResource("5_8erm5")
region = Rect2(0, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_sbwqj"]
atlas = ExtResource("5_8erm5")
region = Rect2(48, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_xwi16"]
atlas = ExtResource("5_8erm5")
region = Rect2(96, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_sweqm"]
atlas = ExtResource("5_8erm5")
region = Rect2(144, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_6t5aa"] [sub_resource type="AtlasTexture" id="AtlasTexture_6t5aa"]
atlas = ExtResource("2_cvnsp") atlas = ExtResource("2_cvnsp")
region = Rect2(0, 0, 48, 48) region = Rect2(0, 0, 48, 48)
@ -114,20 +172,72 @@ animations = [{
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_2ijsl") "texture": SubResource("AtlasTexture_2ijsl")
}], }],
"loop": false, "loop": 0,
"name": &"charging", "name": &"charging",
"speed": 12.0 "speed": 12.0
}, { }, {
"frames": [{ "frames": [{
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_y6uwr")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_83xs0")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ypfnu")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_xuaoq")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_wohnl")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_36dho")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_yh6i2")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_nv4vc")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_8gxox")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_11gg7")
}],
"loop": 0,
"name": &"dead",
"speed": 12.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_bi64h") "texture": SubResource("AtlasTexture_bi64h")
}], }],
"loop": false, "loop": 0,
"name": &"falling", "name": &"falling",
"speed": 12.0 "speed": 12.0
}, { }, {
"frames": [{ "frames": [{
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_qpa8y")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_sbwqj")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_xwi16")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_sweqm")
}],
"loop": 0,
"name": &"hurt",
"speed": 12.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_6t5aa") "texture": SubResource("AtlasTexture_6t5aa")
}, { }, {
"duration": 1.0, "duration": 1.0,
@ -157,7 +267,7 @@ animations = [{
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_pu2lt") "texture": SubResource("AtlasTexture_pu2lt")
}], }],
"loop": true, "loop": 1,
"name": &"idle", "name": &"idle",
"speed": 12.0 "speed": 12.0
}, { }, {
@ -168,7 +278,7 @@ animations = [{
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_wpjfl") "texture": SubResource("AtlasTexture_wpjfl")
}], }],
"loop": false, "loop": 0,
"name": &"jumping", "name": &"jumping",
"speed": 12.0 "speed": 12.0
}, { }, {
@ -197,7 +307,7 @@ animations = [{
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_l6n3p") "texture": SubResource("AtlasTexture_l6n3p")
}], }],
"loop": true, "loop": 1,
"name": &"running", "name": &"running",
"speed": 12.0 "speed": 12.0
}, { }, {
@ -211,7 +321,7 @@ animations = [{
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_vfarp") "texture": SubResource("AtlasTexture_vfarp")
}], }],
"loop": false, "loop": 0,
"name": &"shoving", "name": &"shoving",
"speed": 12.0 "speed": 12.0
}] }]
@ -232,18 +342,16 @@ target_position = Vector2(17.073172, 0)
target_position = Vector2(-17.073172, 0) target_position = Vector2(-17.073172, 0)
[node name="RightSpawn" type="Marker2D" parent="." unique_id=1358832037] [node name="RightSpawn" type="Marker2D" parent="." unique_id=1358832037]
position = Vector2(11.585366, -8.536586) position = Vector2(11.585366, -1.5853653)
[node name="LeftSpawn" type="Marker2D" parent="." unique_id=1880777693] [node name="LeftSpawn" type="Marker2D" parent="." unique_id=1880777693]
position = Vector2(-12.195123, -8.536585) position = Vector2(-12.195123, -1.5853643)
[node name="PlayerGraphic" type="AnimatedSprite2D" parent="." unique_id=411274624] [node name="PlayerGraphic" type="AnimatedSprite2D" parent="." unique_id=411274624]
texture_filter = 1 texture_filter = 1
position = Vector2(0, -6.0975614) position = Vector2(0, -6.0975614)
sprite_frames = SubResource("SpriteFrames_ukyrk") sprite_frames = SubResource("SpriteFrames_ukyrk")
animation = &"shoving" animation = &"dead"
autoplay = "idle" autoplay = "idle"
frame = 2
frame_progress = 1.0
[connection signal="animation_finished" from="PlayerGraphic" to="." method="_on_animation_finished"] [connection signal="animation_finished" from="PlayerGraphic" to="." method="_on_animation_finished"]

74
Scenes/slime.tscn Normal file
View File

@ -0,0 +1,74 @@
[gd_scene format=3 uid="uid://cirhfajnm0tgv"]
[ext_resource type="Texture2D" uid="uid://dm8y5y1wgcatm" path="res://Assets/Enemy/Slime/slime_purple.png" id="1_jokqx"]
[ext_resource type="Script" uid="uid://0upi64wxvgdi" path="res://Scripts/slime.gd" id="1_swwnm"]
[sub_resource type="CircleShape2D" id="CircleShape2D_oov8j"]
[sub_resource type="AtlasTexture" id="AtlasTexture_swwnm"]
atlas = ExtResource("1_jokqx")
region = Rect2(0, 24, 24, 24)
[sub_resource type="AtlasTexture" id="AtlasTexture_aiwxb"]
atlas = ExtResource("1_jokqx")
region = Rect2(24, 24, 24, 24)
[sub_resource type="AtlasTexture" id="AtlasTexture_paq7w"]
atlas = ExtResource("1_jokqx")
region = Rect2(48, 24, 24, 24)
[sub_resource type="AtlasTexture" id="AtlasTexture_f4si1"]
atlas = ExtResource("1_jokqx")
region = Rect2(72, 24, 24, 24)
[sub_resource type="SpriteFrames" id="SpriteFrames_65ky4"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_swwnm")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_aiwxb")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_paq7w")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_f4si1")
}],
"loop": 1,
"name": &"idle",
"speed": 12.0
}]
[node name="slime" type="Area2D" unique_id=469808451 groups=["shootable"]]
script = ExtResource("1_swwnm")
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1923400761]
shape = SubResource("CircleShape2D_oov8j")
debug_color = Color(0.98289496, 0, 0.36229762, 0.41960785)
[node name="slimeGraphic" type="AnimatedSprite2D" parent="." unique_id=1897637737]
texture_filter = 1
position = Vector2(0, -2)
sprite_frames = SubResource("SpriteFrames_65ky4")
animation = &"idle"
autoplay = "idle"
frame = 1
frame_progress = 0.5775934
[node name="rightCast" type="RayCast2D" parent="." unique_id=543027424]
target_position = Vector2(15, 0)
[node name="rightDownCast" type="RayCast2D" parent="." unique_id=2087514097]
position = Vector2(9, 0)
target_position = Vector2(0, 15)
[node name="leftDownCast" type="RayCast2D" parent="." unique_id=1074540411]
position = Vector2(-9, 0)
target_position = Vector2(0, 15)
[node name="leftCast" type="RayCast2D" parent="." unique_id=994735907]
target_position = Vector2(-15, 0)
[connection signal="body_entered" from="." to="." method="_on_body_entered"]

View File

@ -9,5 +9,5 @@ func _process(delta: float) -> void:
position += transform.x * speed * delta position += transform.x * speed * delta
func _on_body_entered(body: Node2D) -> void: func _on_body_entered(body: Node2D) -> void:
if body is Crate: if body.is_in_group("shootable"):
bulletHitSignal.emit(body,self) bulletHitSignal.emit(body,self)

View File

@ -1,13 +1,27 @@
class_name GameController extends Node2D class_name GameController extends Node2D
signal destroySignal(body) signal destroySignal(body)
signal playerHurtSignal(playerHealth,maxHealth)
signal playerDeadSignal
var numberOfCrates = 2 var numberOfCrates = 2
var totalCoinsCollected = 0
var timer = Timer.new() var timer = Timer.new()
var timeAvailable = 50 var timeAvailable = 50
var currentPlayerHealth = 100
var startingHealth = 100
var enemiesDict = {}
var enemy:CharacterStats
var player:CharacterStats
# 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:
get_window().grab_focus() get_window().grab_focus()
player = load("res://Scripts/rscs/playerStats.tres")
enemy = load("res://Scripts/rscs/slimeStats.tres")
add_child(timer) add_child(timer)
# time based on seconds # time based on seconds
timer.wait_time = 1 timer.wait_time = 1
@ -16,12 +30,15 @@ func _ready() -> void:
timer.connect("timeout", countdown) timer.connect("timeout", countdown)
timer.start() timer.start()
func reset()->void:
currentPlayerHealth = player.startingHealth
func countdown() -> void: func countdown() -> void:
# Reduce time left # Reduce time left
timeAvailable -= 1 timeAvailable -= 1
if timeAvailable <= 0 and numberOfCrates > 0: if timeAvailable <= 0 and numberOfCrates > 0:
print("LOSER") print("LOSER")
get_tree().reload_current_scene() playerDeadSignal.emit()
# 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:
@ -32,7 +49,8 @@ func _on_trigger(body: Variant, trigger: Variant, intent:String) -> void:
print("Game controller knows trigger fired") print("Game controller knows trigger fired")
match intent: match intent:
"destroy": "destroy":
destroySignal.emit(body) if body is RigidBody2D:
destroySignal.emit(body)
func crateTotal(howMany): func crateTotal(howMany):
numberOfCrates = howMany numberOfCrates = howMany
@ -41,8 +59,45 @@ func crateTotal(howMany):
print("YOU WON!!!") print("YOU WON!!!")
get_tree().reload_current_scene() get_tree().reload_current_scene()
func coinCollected(body,coin)->void:
print("GC knows coin collected")
totalCoinsCollected +=1
destroySignal.emit(coin)
func coinTotal(totalAmount)->void:
print("GC knows total coins "+str(totalAmount))
func totalEnemies(numberOfEnemies)->void:
print("GC knows total bad guys "+str(numberOfEnemies))
func slimeAttack(body,slime)->void:
print("GC knows slime attack "+str(enemiesDict[slime]["damage"]))
currentPlayerHealth -= enemiesDict[slime]["damage"]
if currentPlayerHealth > 0:
print("ouch")
playerHurtSignal.emit(currentPlayerHealth,startingHealth)
else:
print("ded")
playerDeadSignal.emit()
func bulletDamage(body, _bullet)->void: func bulletDamage(body, _bullet)->void:
if body.is_in_group("shootable"): if body.is_in_group("shootable"):
destroySignal.emit(body) if body is Crate:
destroySignal.emit(_bullet) destroySignal.emit(body)
destroySignal.emit(_bullet)
if body is Slime:
enemiesDict[body]["health"]-=player.rangeDamage
if enemiesDict[body]["health"] <=0:
enemiesDict.erase(body)
destroySignal.emit(body)
destroySignal.emit(_bullet)
func levelChange()->void:
get_tree().reload_current_scene()
func addEnemyToLevel(slime)->void:
var stats = {
"health": enemy.startingHealth+randi_range(0,20),
"damage": enemy.meleeDamage+randi_range(0,10)
}
enemiesDict[slime]=stats

View File

@ -1,6 +1,7 @@
class_name Player extends CharacterBody2D class_name Player extends CharacterBody2D
signal pushSignal(body, direction) signal pushSignal(body, direction)
signal shootSignal(markerPosition, speed) signal shootSignal(markerPosition, speed)
signal deathAnimationCompleteSignal
const SPEED = 300.0 const SPEED = 300.0
const JUMP_VELOCITY = -400.0 const JUMP_VELOCITY = -400.0
@ -18,18 +19,25 @@ var pushTimer = 0
enum FaceDirection {RIGHT,LEFT} enum FaceDirection {RIGHT,LEFT}
var facing:FaceDirection = FaceDirection.RIGHT var facing:FaceDirection = FaceDirection.RIGHT
enum playerStates {IDLE, RUNNING, JUMPING, FALLING, CHARGING, SHOVING} enum playerStates {IDLE, RUNNING, JUMPING, FALLING, CHARGING, SHOVING, HURT, DEAD}
var current_player_state:playerStates = playerStates.IDLE var current_player_state:playerStates = playerStates.IDLE
var upJump = false var upJump = false
func _physics_process(delta: float) -> void: func _physics_process(delta: float) -> void:
if current_player_state != playerStates.DEAD:
handle_input()
handle_movement(delta) handle_movement(delta)
handle_input()
handle_states() handle_states()
handle_animation() handle_animation()
move_and_slide() move_and_slide()
handle_collisions() handle_collisions()
func hurt(playerHealth, maxHealth)->void:
current_player_state = playerStates.HURT
func kill()->void:
current_player_state = playerStates.DEAD
func handle_input()->void: func handle_input()->void:
# Handle jump. # Handle jump.
if Input.is_action_just_pressed("ui_accept") and is_on_floor(): if Input.is_action_just_pressed("ui_accept") and is_on_floor():
@ -38,7 +46,6 @@ func handle_input()->void:
upJump = true upJump = true
#Handle shove target #Handle shove target
if Input.is_action_just_pressed("shove"): if Input.is_action_just_pressed("shove"):
print("I want to shove")
if pushRightEnabled && facing==FaceDirection.RIGHT: if pushRightEnabled && facing==FaceDirection.RIGHT:
current_player_state = playerStates.CHARGING current_player_state = playerStates.CHARGING
pushTimer = Time.get_ticks_msec() pushTimer = Time.get_ticks_msec()
@ -59,7 +66,6 @@ func handle_input()->void:
#Handle Shoot Bullet #Handle Shoot Bullet
if Input.is_action_just_pressed("shoot"): if Input.is_action_just_pressed("shoot"):
print("Ima shoot a bullet")
#marker postion, speed #marker postion, speed
match facing: match facing:
FaceDirection.RIGHT: FaceDirection.RIGHT:
@ -88,7 +94,6 @@ func handle_movement(delta)->void:
func handle_collisions()->void: func handle_collisions()->void:
if right_cast.is_colliding(): if right_cast.is_colliding():
print("Right raycast collision")
var collider = right_cast.get_collider() var collider = right_cast.get_collider()
if collider is Node: if collider is Node:
pushRightEnabled = true pushRightEnabled = true
@ -97,7 +102,6 @@ func handle_collisions()->void:
pushRightEnabled = false pushRightEnabled = false
if left_cast.is_colliding(): if left_cast.is_colliding():
print("Left raycast collision")
var collider = left_cast.get_collider() var collider = left_cast.get_collider()
if collider is Node: if collider is Node:
pushLeftEnabled = true pushLeftEnabled = true
@ -115,7 +119,6 @@ func handle_collisions()->void:
func handle_states()->void: func handle_states()->void:
match current_player_state: match current_player_state:
playerStates.IDLE when velocity.x != 0: playerStates.IDLE when velocity.x != 0:
print("I run")
current_player_state = playerStates.RUNNING current_player_state = playerStates.RUNNING
playerStates.RUNNING when velocity.x == 0: playerStates.RUNNING when velocity.x == 0:
current_player_state = playerStates.IDLE current_player_state = playerStates.IDLE
@ -142,6 +145,10 @@ func handle_animation()->void:
player_graphic.play("charging") player_graphic.play("charging")
playerStates.SHOVING: playerStates.SHOVING:
player_graphic.play("shoving") player_graphic.play("shoving")
playerStates.HURT:
player_graphic.play("hurt")
playerStates.DEAD:
player_graphic.play("dead")
func _on_animation_finished() -> void: func _on_animation_finished() -> void:
@ -150,3 +157,7 @@ func _on_animation_finished() -> void:
upJump = false upJump = false
playerStates.SHOVING: playerStates.SHOVING:
current_player_state = playerStates.IDLE current_player_state = playerStates.IDLE
playerStates.HURT:
current_player_state = playerStates.IDLE
playerStates.DEAD:
deathAnimationCompleteSignal.emit()

View File

@ -0,0 +1,10 @@
class_name CharacterStats extends Resource
#health
@export var currentHealth:int = 100
@export var maxHealth := 150
@export var startingHealth := 100
#damage
@export var meleeDamage := 20
@export var rangeDamage := 15

View File

@ -0,0 +1 @@
uid://b184uwt12pcwt

View File

@ -0,0 +1,10 @@
[gd_resource type="Resource" script_class="CharacterStats" format=3 uid="uid://be2pt870o5sfl"]
[ext_resource type="Script" uid="uid://b184uwt12pcwt" path="res://Scripts/rscs/characterstats.gd" id="1_eiyfu"]
[resource]
script = ExtResource("1_eiyfu")
maxHealth = 200
meleeDamage = 30
rangeDamage = 20
metadata/_custom_type_script = "uid://b184uwt12pcwt"

View File

@ -0,0 +1,11 @@
[gd_resource type="Resource" script_class="CharacterStats" format=3 uid="uid://bv3403ln5bjch"]
[ext_resource type="Script" uid="uid://b184uwt12pcwt" path="res://Scripts/rscs/characterstats.gd" id="1_g41dv"]
[resource]
script = ExtResource("1_g41dv")
currentHealth = 60
maxHealth = 80
startingHealth = 60
rangeDamage = 0
metadata/_custom_type_script = "uid://b184uwt12pcwt"

View File

@ -1,29 +1,42 @@
extends Node2D extends Node2D
# hold control and drag + drop # hold control and drag + drop
@onready var game:GameController = $".."
@onready var crates: Node2D = $"../Crates" @onready var crates: Node2D = $"../Crates"
@onready var player: Player = $"../Player" @onready var player: Player = $"../Player"
@onready var coins: Node2D = $"../Coins"
@onready var enemies: Node2D = $"../Enemies"
var bullet = preload("res://Scenes/bullet.tscn") var bullet = preload("res://Scenes/bullet.tscn")
var bulletArray:Array[Bullet] = [] var bulletArray:Array[Bullet] = []
var totalAllowedBullets:int = 7 var totalAllowedBullets:int = 7
var coin
# 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:
Gamecontroller.reset()
player.pushSignal.connect(pushTarget) player.pushSignal.connect(pushTarget)
player.shootSignal.connect(makeBullet) player.shootSignal.connect(makeBullet)
player.deathAnimationCompleteSignal.connect(Gamecontroller.levelChange)
#signals from the GameController #signals from the GameController
game.destroySignal.connect(destroy) Gamecontroller.destroySignal.connect(destroy)
Gamecontroller.playerHurtSignal.connect(player.hurt)
Gamecontroller.playerDeadSignal.connect(player.kill)
#signals from pickups
#coin.coinCollectedSignal.connect(Gamecontroller.coinCollected)
buildLevel() buildLevel()
# 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 buildLevel() -> void: func buildLevel() -> void:
#tell GC how many crates... #tell GC how many crates...
updateCrates() updateCrates()
updateCoins()
updateEnemies()
func updateCrates()->void: func updateCrates()->void:
var totalCrates = 0 var totalCrates = 0
if crates: if crates:
@ -33,7 +46,31 @@ func updateCrates()->void:
obj.tree_exited.connect(updateCrates) obj.tree_exited.connect(updateCrates)
totalCrates +=1 totalCrates +=1
game.crateTotal(totalCrates) Gamecontroller.crateTotal(totalCrates)
func updateCoins()->void:
var totalCoins = 0
if coins:
print("updateCoins called")
for obj in coins.get_children():
if obj is Coin:
if not obj.tree_exited.is_connected(updateCoins):
obj.tree_exited.connect(updateCoins)
if not obj.coinCollectedSignal.is_connected(Gamecontroller.coinCollected):
obj.coinCollectedSignal.connect(Gamecontroller.coinCollected)
totalCoins +=1
Gamecontroller.coinTotal(totalCoins)
func updateEnemies()->void:
var totalEnemies = 0
if enemies:
for obj in enemies.get_children():
if obj is Slime:
Gamecontroller.addEnemyToLevel(obj)
obj.slimeDamageSignal.connect(Gamecontroller.slimeAttack)
totalEnemies += 1
Gamecontroller.totalEnemies(totalEnemies)
func pushTarget(body,pushDirection)->void: func pushTarget(body,pushDirection)->void:
if body is RigidBody2D: if body is RigidBody2D:
body.apply_central_impulse(pushDirection) body.apply_central_impulse(pushDirection)
@ -61,8 +98,8 @@ func bulletFactory()->Bullet:
#make a new bullet #make a new bullet
myBullet = bullet.instantiate() myBullet = bullet.instantiate()
add_sibling(myBullet) add_sibling(myBullet)
if not myBullet.bulletHitSignal.is_connected(game.bulletDamage): if not myBullet.bulletHitSignal.is_connected(Gamecontroller.bulletDamage):
myBullet.bulletHitSignal.connect(game.bulletDamage) myBullet.bulletHitSignal.connect(Gamecontroller.bulletDamage)
else: else:
# gets oldest one - pop_back # gets oldest one - pop_back
myBullet = bulletArray.pop_back() myBullet = bulletArray.pop_back()

30
Scripts/slime.gd Normal file
View File

@ -0,0 +1,30 @@
class_name Slime extends Area2D
@onready var right_cast: RayCast2D = $rightCast
@onready var right_down_cast: RayCast2D = $rightDownCast
@onready var left_down_cast: RayCast2D = $leftDownCast
@onready var left_cast: RayCast2D = $leftCast
@onready var slime_graphic: AnimatedSprite2D = $slimeGraphic
signal slimeDamageSignal(body,slime)
@export var speed:int = 100
var direction = 1
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
if not right_down_cast.is_colliding():
direction = -1
slime_graphic.flip_h = true
if not left_down_cast.is_colliding():
direction = 1
slime_graphic.flip_h = false
if right_cast.is_colliding() && not right_cast.get_collider() is Player:
direction = -1
slime_graphic.flip_h = true
if left_cast.is_colliding() && not left_cast.get_collider() is Player:
direction = 1
slime_graphic.flip_h = false
position.x += direction*speed*delta
func _on_body_entered(body: Node2D) -> void:
slimeDamageSignal.emit(body,self)

1
Scripts/slime.gd.uid Normal file
View File

@ -0,0 +1 @@
uid://0upi64wxvgdi

View File

@ -12,9 +12,21 @@ config_version=5
config/name="CatGame" config/name="CatGame"
run/main_scene="uid://bportqr2j3d7s" run/main_scene="uid://bportqr2j3d7s"
config/features=PackedStringArray("4.6", "Forward Plus") config/features=PackedStringArray("4.7", "Forward Plus")
config/icon="res://icon.svg" config/icon="res://icon.svg"
[autoload]
Gamecontroller="*uid://cvrssvw6p8myl"
[display]
window/size/viewport_width=480
window/size/viewport_height=270
window/size/window_width_override=960
window/size/window_height_override=540
window/stretch/mode="viewport"
[input] [input]
shove={ shove={