diff --git a/novembergame/assets/graphics/enemies/slime_green.png b/novembergame/assets/graphics/enemies/slime_green.png new file mode 100644 index 0000000..a21cb6f Binary files /dev/null and b/novembergame/assets/graphics/enemies/slime_green.png differ diff --git a/novembergame/assets/graphics/enemies/slime_green.png.import b/novembergame/assets/graphics/enemies/slime_green.png.import new file mode 100644 index 0000000..2c776eb --- /dev/null +++ b/novembergame/assets/graphics/enemies/slime_green.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://da7ap0kxh23js" +path="res://.godot/imported/slime_green.png-5261ffd1254c816fe62b35227a9aa11d.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/graphics/enemies/slime_green.png" +dest_files=["res://.godot/imported/slime_green.png-5261ffd1254c816fe62b35227a9aa11d.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 diff --git a/novembergame/assets/graphics/pickups/coin.png b/novembergame/assets/graphics/pickups/coin.png new file mode 100644 index 0000000..01ae33d Binary files /dev/null and b/novembergame/assets/graphics/pickups/coin.png differ diff --git a/novembergame/assets/graphics/pickups/coin.png.import b/novembergame/assets/graphics/pickups/coin.png.import new file mode 100644 index 0000000..365df96 --- /dev/null +++ b/novembergame/assets/graphics/pickups/coin.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dexybjngcxs3g" +path="res://.godot/imported/coin.png-f0b33289d8d72c34d5a0c76da4c0f19c.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/graphics/pickups/coin.png" +dest_files=["res://.godot/imported/coin.png-f0b33289d8d72c34d5a0c76da4c0f19c.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 diff --git a/novembergame/assets/graphics/player/death/Player Death 64x64.png b/novembergame/assets/graphics/player/death/Player Death 64x64.png new file mode 100644 index 0000000..2e6a1ae Binary files /dev/null and b/novembergame/assets/graphics/player/death/Player Death 64x64.png differ diff --git a/novembergame/assets/graphics/player/death/Player Death 64x64.png.import b/novembergame/assets/graphics/player/death/Player Death 64x64.png.import new file mode 100644 index 0000000..84cfa1a --- /dev/null +++ b/novembergame/assets/graphics/player/death/Player Death 64x64.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://1h4aupwklktd" +path="res://.godot/imported/Player Death 64x64.png-0c6ff54e7d9aad74b66dce47376541f8.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/graphics/player/death/Player Death 64x64.png" +dest_files=["res://.godot/imported/Player Death 64x64.png-0c6ff54e7d9aad74b66dce47376541f8.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 diff --git a/novembergame/assets/graphics/player/hurt/Player Hurt 48x48.png b/novembergame/assets/graphics/player/hurt/Player Hurt 48x48.png new file mode 100644 index 0000000..57d8783 Binary files /dev/null and b/novembergame/assets/graphics/player/hurt/Player Hurt 48x48.png differ diff --git a/novembergame/assets/graphics/player/hurt/Player Hurt 48x48.png.import b/novembergame/assets/graphics/player/hurt/Player Hurt 48x48.png.import new file mode 100644 index 0000000..a947c07 --- /dev/null +++ b/novembergame/assets/graphics/player/hurt/Player Hurt 48x48.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://chrp31s6hw6fp" +path="res://.godot/imported/Player Hurt 48x48.png-a720e51cb19103e76b22ab6c1b81302d.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/graphics/player/hurt/Player Hurt 48x48.png" +dest_files=["res://.godot/imported/Player Hurt 48x48.png-a720e51cb19103e76b22ab6c1b81302d.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 diff --git a/novembergame/project.godot b/novembergame/project.godot index 0982448..ca1c694 100644 --- a/novembergame/project.godot +++ b/novembergame/project.godot @@ -15,6 +15,10 @@ run/main_scene="res://scenes/game.tscn" config/features=PackedStringArray("4.3", "Forward Plus") config/icon="res://icon.svg" +[autoload] + +GameController="*res://scripts/game_controller.gd" + [display] window/size/viewport_width=320 diff --git a/novembergame/scenes/badguy.tscn b/novembergame/scenes/badguy.tscn new file mode 100644 index 0000000..8e5a3b8 --- /dev/null +++ b/novembergame/scenes/badguy.tscn @@ -0,0 +1,74 @@ +[gd_scene load_steps=9 format=3 uid="uid://do41rhebtm7vw"] + +[ext_resource type="Script" path="res://scripts/badguy.gd" id="1_3gg16"] +[ext_resource type="Texture2D" uid="uid://da7ap0kxh23js" path="res://assets/graphics/enemies/slime_green.png" id="1_oxuep"] + +[sub_resource type="AtlasTexture" id="AtlasTexture_wxa5t"] +atlas = ExtResource("1_oxuep") +region = Rect2(0, 24, 24, 24) + +[sub_resource type="AtlasTexture" id="AtlasTexture_et71u"] +atlas = ExtResource("1_oxuep") +region = Rect2(24, 24, 24, 24) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ms1qp"] +atlas = ExtResource("1_oxuep") +region = Rect2(48, 24, 24, 24) + +[sub_resource type="AtlasTexture" id="AtlasTexture_cui8n"] +atlas = ExtResource("1_oxuep") +region = Rect2(72, 24, 24, 24) + +[sub_resource type="SpriteFrames" id="SpriteFrames_0d1bt"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_wxa5t") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_et71u") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ms1qp") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_cui8n") +}], +"loop": true, +"name": &"idle", +"speed": 12.0 +}] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_yg3ku"] +size = Vector2(16.6667, 20) + +[node name="Area2D" type="Area2D"] +script = ExtResource("1_3gg16") + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] +texture_filter = 1 +sprite_frames = SubResource("SpriteFrames_0d1bt") +animation = &"idle" +autoplay = "idle" +frame_progress = 0.711712 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(0, 4) +scale = Vector2(0.840001, 0.8) +shape = SubResource("RectangleShape2D_yg3ku") + +[node name="CastRight" type="RayCast2D" parent="."] +target_position = Vector2(14, 0) + +[node name="CastLeft" type="RayCast2D" parent="."] +target_position = Vector2(-14, 0) + +[node name="CastFloorRight" type="RayCast2D" parent="."] +position = Vector2(9, 5) +target_position = Vector2(0, 9) + +[node name="CastFloorLeft" type="RayCast2D" parent="."] +position = Vector2(-9, 5) +target_position = Vector2(0, 10) + +[connection signal="body_entered" from="." to="." method="_on_body_entered"] diff --git a/novembergame/scenes/character.tscn b/novembergame/scenes/character.tscn index 691ab71..eb16fd5 100644 --- a/novembergame/scenes/character.tscn +++ b/novembergame/scenes/character.tscn @@ -1,13 +1,71 @@ -[gd_scene load_steps=28 format=3 uid="uid://cjqhmd3158nb7"] +[gd_scene load_steps=44 format=3 uid="uid://cjqhmd3158nb7"] [ext_resource type="Script" path="res://scripts/dudecontroller.gd" id="1_u27sl"] +[ext_resource type="Texture2D" uid="uid://1h4aupwklktd" path="res://assets/graphics/player/death/Player Death 64x64.png" id="2_puyd6"] [ext_resource type="Texture2D" uid="uid://cjuaglcx1l8mq" path="res://assets/graphics/player/idle/Player Idle 48x48.png" id="2_s31uh"] +[ext_resource type="Texture2D" uid="uid://chrp31s6hw6fp" path="res://assets/graphics/player/hurt/Player Hurt 48x48.png" id="2_t63lx"] [ext_resource type="Texture2D" uid="uid://b82ecqnclroum" path="res://assets/graphics/player/jump/player jump 48x48.png" id="3_5pc3d"] [ext_resource type="Texture2D" uid="uid://bddwju2m8xvbj" path="res://assets/graphics/player/run/player run 48x48.png" id="3_pvg6g"] [sub_resource type="CircleShape2D" id="CircleShape2D_pg3nc"] radius = 18.1108 +[sub_resource type="AtlasTexture" id="AtlasTexture_lewcv"] +atlas = ExtResource("2_puyd6") +region = Rect2(0, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_7vgrw"] +atlas = ExtResource("2_puyd6") +region = Rect2(48, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ax0dy"] +atlas = ExtResource("2_puyd6") +region = Rect2(96, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_h3um1"] +atlas = ExtResource("2_puyd6") +region = Rect2(144, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_xpfml"] +atlas = ExtResource("2_puyd6") +region = Rect2(192, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_crvik"] +atlas = ExtResource("2_puyd6") +region = Rect2(240, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_l42x7"] +atlas = ExtResource("2_puyd6") +region = Rect2(288, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ux8dt"] +atlas = ExtResource("2_puyd6") +region = Rect2(336, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_7w8ul"] +atlas = ExtResource("2_puyd6") +region = Rect2(384, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_js8u6"] +atlas = ExtResource("2_puyd6") +region = Rect2(432, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_li3qm"] +atlas = ExtResource("2_t63lx") +region = Rect2(0, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_h1vht"] +atlas = ExtResource("2_t63lx") +region = Rect2(48, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_hrho2"] +atlas = ExtResource("2_t63lx") +region = Rect2(96, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ur1h8"] +atlas = ExtResource("2_t63lx") +region = Rect2(144, 0, 48, 48) + [sub_resource type="AtlasTexture" id="AtlasTexture_mirx3"] atlas = ExtResource("2_s31uh") region = Rect2(0, 0, 48, 48) @@ -96,6 +154,58 @@ region = Rect2(336, 0, 48, 48) animations = [{ "frames": [{ "duration": 1.0, +"texture": SubResource("AtlasTexture_lewcv") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_7vgrw") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ax0dy") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_h3um1") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_xpfml") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_crvik") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_l42x7") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ux8dt") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_7w8ul") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_js8u6") +}], +"loop": false, +"name": &"death", +"speed": 12.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_li3qm") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_h1vht") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_hrho2") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ur1h8") +}], +"loop": false, +"name": &"hurt", +"speed": 12.0 +}, { +"frames": [{ +"duration": 1.0, "texture": SubResource("AtlasTexture_mirx3") }, { "duration": 1.0, @@ -198,9 +308,13 @@ position = Vector2(-18, -5) [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] texture_filter = 1 sprite_frames = SubResource("SpriteFrames_p5ykk") -animation = &"idle" +animation = &"death" autoplay = "run" +frame = 9 +frame_progress = 1.0 [node name="Camera2D" type="Camera2D" parent="."] position = Vector2(-1, 0) offset = Vector2(0, -40) + +[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animation_finished"] diff --git a/novembergame/scenes/coin.tscn b/novembergame/scenes/coin.tscn new file mode 100644 index 0000000..782653b --- /dev/null +++ b/novembergame/scenes/coin.tscn @@ -0,0 +1,112 @@ +[gd_scene load_steps=17 format=3 uid="uid://0e20afji7t11"] + +[ext_resource type="Script" path="res://scripts/coin.gd" id="1_7lr2g"] +[ext_resource type="Texture2D" uid="uid://dexybjngcxs3g" path="res://assets/graphics/pickups/coin.png" id="1_o2b12"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_5x4sn"] + +[sub_resource type="AtlasTexture" id="AtlasTexture_1h4vi"] +atlas = ExtResource("1_o2b12") +region = Rect2(0, 0, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_eeq2t"] +atlas = ExtResource("1_o2b12") +region = Rect2(16, 0, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_be0hj"] +atlas = ExtResource("1_o2b12") +region = Rect2(32, 0, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_tlsoj"] +atlas = ExtResource("1_o2b12") +region = Rect2(48, 0, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_f0lcn"] +atlas = ExtResource("1_o2b12") +region = Rect2(64, 0, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_7f8i4"] +atlas = ExtResource("1_o2b12") +region = Rect2(80, 0, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_myst1"] +atlas = ExtResource("1_o2b12") +region = Rect2(96, 0, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_rwemh"] +atlas = ExtResource("1_o2b12") +region = Rect2(112, 0, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_8djgs"] +atlas = ExtResource("1_o2b12") +region = Rect2(128, 0, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ldsox"] +atlas = ExtResource("1_o2b12") +region = Rect2(144, 0, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_4ljys"] +atlas = ExtResource("1_o2b12") +region = Rect2(160, 0, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_mq67e"] +atlas = ExtResource("1_o2b12") +region = Rect2(176, 0, 16, 16) + +[sub_resource type="SpriteFrames" id="SpriteFrames_eujox"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_1h4vi") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_eeq2t") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_be0hj") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_tlsoj") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_f0lcn") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_7f8i4") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_myst1") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_rwemh") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_8djgs") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ldsox") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_4ljys") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_mq67e") +}], +"loop": true, +"name": &"default", +"speed": 12.0 +}] + +[node name="Area2D" type="Area2D"] +script = ExtResource("1_7lr2g") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +scale = Vector2(0.48, 0.520001) +shape = SubResource("CircleShape2D_5x4sn") + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] +texture_filter = 1 +sprite_frames = SubResource("SpriteFrames_eujox") +autoplay = "default" + +[connection signal="body_entered" from="." to="." method="_on_body_entered"] diff --git a/novembergame/scenes/game.tscn b/novembergame/scenes/game.tscn index 89211c7..3f9da3e 100644 --- a/novembergame/scenes/game.tscn +++ b/novembergame/scenes/game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=14 format=4 uid="uid://cmh68gsfunmwa"] +[gd_scene load_steps=16 format=4 uid="uid://cmh68gsfunmwa"] [ext_resource type="Texture2D" uid="uid://vwe7rit3r0ho" path="res://assets/graphics/environment/background/forestbackground.png" id="1_6g8gi"] [ext_resource type="Texture2D" uid="uid://bvbxh8nxgekny" path="res://assets/graphics/environment/terrain/Terrain (32x32).png" id="1_n0y6d"] @@ -8,6 +8,8 @@ [ext_resource type="Texture2D" uid="uid://ceoscwflxdsej" path="res://assets/graphics/environment/background/midground.png" id="2_nbj6c"] [ext_resource type="Script" path="res://scripts/trigger.gd" id="2_tsnf5"] [ext_resource type="PackedScene" uid="uid://dm71h7adhhf8u" path="res://scenes/box.tscn" id="3_pi0u1"] +[ext_resource type="PackedScene" uid="uid://0e20afji7t11" path="res://scenes/coin.tscn" id="9_6tlsy"] +[ext_resource type="PackedScene" uid="uid://do41rhebtm7vw" path="res://scenes/badguy.tscn" id="10_rpj3s"] [sub_resource type="TileMapPattern" id="TileMapPattern_mkieg"] tile_data = PackedInt32Array(0, 262144, 0, 65536, 262144, 1, 131072, 262144, 1, 196608, 262144, 2) @@ -404,7 +406,7 @@ position = Vector2(160, 90) texture = ExtResource("2_nbj6c") [node name="TileMapLayer" type="TileMapLayer" parent="."] -tile_map_data = PackedByteArray("AAAAAAUAAAAAAAQAAAABAAUAAAABAAQAAAACAAUAAAABAAQAAAADAAUAAAABAAQAAAAEAAUAAAABAAQAAAAFAAUAAAABAAQAAAAGAAUAAAABAAQAAAAHAAUAAAABAAQAAAAIAAUAAAABAAQAAAAJAAUAAAABAAQAAAAKAAUAAAABAAQAAAALAAUAAAABAAQAAAAMAAUAAAABAAQAAAANAAUAAAABAAQAAAAOAAUAAAABAAQAAAAPAAUAAAABAAQAAAAQAAUAAAABAAQAAAARAAUAAAABAAQAAAASAAUAAAABAAQAAAATAAUAAAABAAQAAAAUAAUAAAABAAQAAAAVAAUAAAACAAQAAAAGAAMAAAAEAAQAAAAIAAIAAAAEAAQAAAAAAAMAAAAEAAIAAAAAAAIAAAAEAAEAAAAAAAEAAAAEAAAAAAALAAIAAAAAAAAAAAAMAAIAAAABAAAAAAANAAIAAAABAAAAAAAOAAIAAAACAAAAAAAOAAMAAAACAAIAAAANAAMAAAABAAIAAAAMAAMAAAABAAIAAAALAAMAAAAAAAIAAAAKAAAAAAAAAAQAAAALAAAAAAABAAQAAAAMAAAAAAAQAAQAAAAMAP//AAAEAAAAAAAOAP7/AAAEAAQAAAA=") +tile_map_data = PackedByteArray("AAAAAAUAAAAAAAQAAAABAAUAAAABAAQAAAACAAUAAAABAAQAAAADAAUAAAABAAQAAAAEAAUAAAABAAQAAAAFAAUAAAABAAQAAAAGAAUAAAABAAQAAAAHAAUAAAABAAQAAAAIAAUAAAABAAQAAAAJAAUAAAABAAQAAAAKAAUAAAABAAQAAAALAAUAAAABAAQAAAAMAAUAAAABAAQAAAANAAUAAAABAAQAAAAOAAUAAAABAAQAAAAPAAUAAAABAAQAAAAQAAUAAAABAAQAAAARAAUAAAABAAQAAAASAAUAAAABAAQAAAATAAUAAAABAAQAAAAUAAUAAAABAAQAAAAVAAUAAAACAAQAAAAGAAMAAAAEAAQAAAAIAAIAAAAEAAQAAAAAAAMAAAAEAAIAAAAAAAIAAAAEAAEAAAAAAAEAAAAEAAAAAAALAAIAAAAAAAAAAAAMAAIAAAABAAAAAAANAAIAAAABAAAAAAAOAAIAAAAHAAQAAAAOAAMAAAACAAIAAAANAAMAAAABAAIAAAAMAAMAAAABAAIAAAALAAMAAAAAAAIAAAAKAAAAAAAAAAQAAAALAAAAAAABAAQAAAAMAAAAAAAQAAQAAAAMAP//AAAEAAAAAAAOAP7/AAAEAAQAAAAOAAEAAAAEAAAAAAA=") tile_set = SubResource("TileSet_wyq3g") [node name="SceneManager" type="Node" parent="."] @@ -441,14 +443,21 @@ metadata/_edit_group_ = true [node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"] shape = SubResource("WorldBoundaryShape2D_c5gsu") -[node name="Parallax2D" type="Parallax2D" parent="."] -scroll_scale = Vector2(2, 1) -repeat_size = Vector2(320, 0) +[node name="coins" type="Node" parent="."] -[node name="Sprite2D" type="Sprite2D" parent="Parallax2D"] -texture_filter = 1 -position = Vector2(160, 150) -scale = Vector2(1, 0.3) -texture = ExtResource("2_nbj6c") +[node name="Coin" parent="coins" instance=ExtResource("9_6tlsy")] +position = Vector2(208, 90) + +[node name="Coin2" parent="coins" instance=ExtResource("9_6tlsy")] +position = Vector2(273, 58) + +[node name="Coin3" parent="coins" instance=ExtResource("9_6tlsy")] +position = Vector2(422, 58) + +[node name="enemies" type="Node" parent="."] + +[node name="Area2D2" parent="enemies" instance=ExtResource("10_rpj3s")] +position = Vector2(386, 51) +metadata/_edit_group_ = true [connection signal="body_entered" from="Area2D" to="Area2D" method="_on_body_entered"] diff --git a/novembergame/scripts/badguy.gd b/novembergame/scripts/badguy.gd new file mode 100644 index 0000000..239e032 --- /dev/null +++ b/novembergame/scripts/badguy.gd @@ -0,0 +1,39 @@ +class_name BadGuy extends Area2D + +signal playerDamage +var direction = 1 +const speed =60 +@onready var sprite: AnimatedSprite2D = $AnimatedSprite2D +@onready var cast_right: RayCast2D = $CastRight +@onready var cast_left: RayCast2D = $CastLeft +@onready var cast_floor_right: RayCast2D = $CastFloorRight +@onready var cast_floor_left: RayCast2D = $CastFloorLeft + +# 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: + if cast_right.is_colliding(): + if not cast_right.get_collider().is_in_group("player"): + direction = -1 + sprite.flip_h = true + if cast_left.is_colliding(): + if not cast_left.get_collider().is_in_group("player"): + direction = 1 + sprite.flip_h = false + if not cast_floor_right.is_colliding(): + direction =-1 + sprite.flip_h = true + if not cast_floor_left.is_colliding(): + direction = 1 + sprite.flip_h = false + + position.x += direction * speed * delta + + +func _on_body_entered(body: Node2D) -> void: + if body.is_in_group("player"): + playerDamage.emit() diff --git a/novembergame/scripts/coin.gd b/novembergame/scripts/coin.gd new file mode 100644 index 0000000..182bc62 --- /dev/null +++ b/novembergame/scripts/coin.gd @@ -0,0 +1,12 @@ +class_name Coin extends Area2D + +signal coinCollected + + + + +func _on_body_entered(body: Node2D) -> void: + if body.is_in_group("player"): + coinCollected.emit() + queue_free() + diff --git a/novembergame/scripts/dudecontroller.gd b/novembergame/scripts/dudecontroller.gd index 32f5225..12b43df 100644 --- a/novembergame/scripts/dudecontroller.gd +++ b/novembergame/scripts/dudecontroller.gd @@ -17,93 +17,117 @@ var pushLeftEnabled = false var pushRightEnabled = false var isJumping = false +var animPlaying = "idle" +var living = true + +signal playerDead + @onready var right_target: Node2D = $RightTarget @onready var left_target: Node2D = $LeftTarget +func hurtPlayer(amt): + print("Character knows it should be hurt") + animPlaying = "hurt" + playerSprite.play("hurt") +func killPlayer(): + if living: + living = false + animPlaying = "death" + playerSprite.play(animPlaying) + func _physics_process(delta: float) -> void: - # Add the gravity. - if not is_on_floor(): - velocity += get_gravity() * delta + if living and not animPlaying =="hurt": + # Add the gravity. + if not is_on_floor(): + velocity += get_gravity() * delta - # Handle jump. - if Input.is_action_just_pressed("ui_accept") and is_on_floor(): - velocity.y = JUMP_VELOCITY + # Handle jump. + if Input.is_action_just_pressed("ui_accept") and is_on_floor(): + velocity.y = JUMP_VELOCITY - # Get the input direction and handle the movement/deceleration. - # As good practice, you should replace UI actions with custom gameplay actions. - var direction := Input.get_axis("ui_left", "ui_right") - if Input.is_action_just_pressed("shove") && pushRightEnabled && faceLeft == false: - print("Shove a box") - pushTarget.apply_central_impulse(Vector2(1,0) * PUSHFORCE * 2 ) - pushRightEnabled = false - - if Input.is_action_just_pressed("shove") && faceLeft == true && pushLeftEnabled == true: - pushTarget.apply_central_impulse(Vector2(-1,0) * PUSHFORCE *2 ) - pushLeftEnabled = false - - if Input.is_action_just_pressed("shoot"): - print("Shoot a bullet") - var myBullet = %SceneManager.bulletFactory() - if not faceLeft: - myBullet.transform = right_target.global_transform - myBullet.setSpeed(700) - if faceLeft ==true: - myBullet.transform = left_target.global_transform - myBullet.setSpeed(-700) - - if direction: - velocity.x = direction * SPEED - if direction >0: - faceLeft = false - if direction < 0: - faceLeft = true - else:#TODO: implement jump - pass - velocity.x = move_toward(velocity.x, 0, SPEED) - - if faceLeft: - playerSprite.flip_h = true - else: - playerSprite.flip_h = false - - if is_on_floor(): - isJumping = false - if direction == 0: - playerSprite.play("idle") - else: - playerSprite.play("run") - else: - if not isJumping: - playerSprite.play("jump") - isJumping = true - - move_and_slide() - if right_ray.is_colliding(): - print("Something is on my right") - if not faceLeft: - var collider = right_ray.get_collider() - if collider is Node: - if collider.is_in_group("box"): - print("This is a pushable box") - pushTarget = collider - pushRightEnabled = true - else: - pushRightEnabled = false - - if left_ray.is_colliding(): - if faceLeft: - var collider = left_ray.get_collider() - if collider is Node: - if collider.is_in_group("box"): - pushTarget = collider - pushLeftEnabled = true - else: - pushLeftEnabled = false + # Get the input direction and handle the movement/deceleration. + # As good practice, you should replace UI actions with custom gameplay actions. + var direction := Input.get_axis("ui_left", "ui_right") + if Input.is_action_just_pressed("shove") && pushRightEnabled && faceLeft == false: + print("Shove a box") + pushTarget.apply_central_impulse(Vector2(1,0) * PUSHFORCE * 2 ) + pushRightEnabled = false + if Input.is_action_just_pressed("shove") && faceLeft == true && pushLeftEnabled == true: + pushTarget.apply_central_impulse(Vector2(-1,0) * PUSHFORCE *2 ) + pushLeftEnabled = false + if Input.is_action_just_pressed("shoot"): + print("Shoot a bullet") + var myBullet = %SceneManager.bulletFactory() + if not faceLeft: + myBullet.transform = right_target.global_transform + myBullet.setSpeed(700) + if faceLeft ==true: + myBullet.transform = left_target.global_transform + myBullet.setSpeed(-700) + + if direction: + velocity.x = direction * SPEED + if direction >0: + faceLeft = false + if direction < 0: + faceLeft = true + else:#TODO: implement jump + pass + velocity.x = move_toward(velocity.x, 0, SPEED) - for i in get_slide_collision_count(): - var c = get_slide_collision(i) - if c.get_collider() is RigidBody2D: - c.get_collider().apply_central_impulse(-c.get_normal() * BUMPFORCE) + if faceLeft: + playerSprite.flip_h = true + else: + playerSprite.flip_h = false + + if is_on_floor(): + isJumping = false + if direction == 0: + playerSprite.play("idle") + else: + playerSprite.play("run") + else: + if not isJumping: + playerSprite.play("jump") + isJumping = true + + move_and_slide() + if right_ray.is_colliding(): + print("Something is on my right") + if not faceLeft: + var collider = right_ray.get_collider() + if collider is Node: + if collider.is_in_group("box"): + print("This is a pushable box") + pushTarget = collider + pushRightEnabled = true + else: + pushRightEnabled = false + + if left_ray.is_colliding(): + if faceLeft: + var collider = left_ray.get_collider() + if collider is Node: + if collider.is_in_group("box"): + pushTarget = collider + pushLeftEnabled = true + else: + pushLeftEnabled = false + + + + for i in get_slide_collision_count(): + var c = get_slide_collision(i) + if c.get_collider() is RigidBody2D: + c.get_collider().apply_central_impulse(-c.get_normal() * BUMPFORCE) + + +func _on_animation_finished() -> void: + if animPlaying == "hurt": + animPlaying ="idle" + if animPlaying=="death": + ## emit a custom signal + playerDead.emit() diff --git a/novembergame/scripts/game_controller.gd b/novembergame/scripts/game_controller.gd new file mode 100644 index 0000000..6c3e6b3 --- /dev/null +++ b/novembergame/scripts/game_controller.gd @@ -0,0 +1,34 @@ +extends Node + +var coinsCollected:int = 0 +var player:Resource + +signal playerHurt(amt) +signal playerDeath() + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + player = load("res://scripts/res/playerstats.tres") + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass + +func coinCollected(): + coinsCollected +=1 + print("Total coins collected "+str(coinsCollected) ) + +func playerDamage(): + if player.health > 0: + player.health -= 20 + if player.health <=0: + ## kill him + playerDeath.emit() + else: + ## damage him + playerHurt.emit(20) +func reset(): + player.health = player.max_health + coinsCollected = 0 + diff --git a/novembergame/scripts/res/characterstats.gd b/novembergame/scripts/res/characterstats.gd new file mode 100644 index 0000000..4fa7691 --- /dev/null +++ b/novembergame/scripts/res/characterstats.gd @@ -0,0 +1,6 @@ +class_name CharacterStats extends Resource + + +@export var max_health:int = 100 +@export var starting_health: int = 100 +@export var health: int = 100 diff --git a/novembergame/scripts/res/enemystats.tres b/novembergame/scripts/res/enemystats.tres new file mode 100644 index 0000000..da597df --- /dev/null +++ b/novembergame/scripts/res/enemystats.tres @@ -0,0 +1,9 @@ +[gd_resource type="Resource" script_class="CharacterStats" load_steps=2 format=3 uid="uid://dlllgnb2qyb2p"] + +[ext_resource type="Script" path="res://scripts/res/characterstats.gd" id="1_yv8hh"] + +[resource] +script = ExtResource("1_yv8hh") +max_health = 50 +starting_health = 50 +health = 50 diff --git a/novembergame/scripts/res/playerstats.tres b/novembergame/scripts/res/playerstats.tres new file mode 100644 index 0000000..1dba6b6 --- /dev/null +++ b/novembergame/scripts/res/playerstats.tres @@ -0,0 +1,9 @@ +[gd_resource type="Resource" script_class="CharacterStats" load_steps=2 format=3 uid="uid://bqbgmfbankxvw"] + +[ext_resource type="Script" path="res://scripts/res/characterstats.gd" id="1_8phuw"] + +[resource] +script = ExtResource("1_8phuw") +max_health = 100 +starting_health = 100 +health = 100 diff --git a/novembergame/scripts/scene_manager.gd b/novembergame/scripts/scene_manager.gd index 5837143..5cb2ba2 100644 --- a/novembergame/scripts/scene_manager.gd +++ b/novembergame/scripts/scene_manager.gd @@ -3,9 +3,29 @@ extends Node var bulletsFiredTotal :=0 var bulletsMadeTotal :=0 var bulletArray:Array = [] +@onready var coins: Node = $"../coins" +@onready var enemies: Node = $"../enemies" + +@onready var player: CharacterBody2D = $"../CharacterBody2D" var bullet = preload("res://scenes/bullet.tscn") +func _ready() -> void: + ### coins loop + for n in coins.get_children(): + print("coin found") + n.coinCollected.connect(GameController.coinCollected) + ### enemies loop + for n in enemies.get_children(): + print("enemy found") + n.playerDamage.connect(GameController.playerDamage) + + ## wire up GameController signals to Player + GameController.playerHurt.connect(hurtPlayer) + GameController.playerDeath.connect(killPlayer) + + player.playerDead.connect(deadPlayer) + func bulletFactory(): print("Make a bullet at the factory") var mybullet @@ -28,3 +48,14 @@ func onBulletHit(bullet, body): if body.is_in_group("shootable"): print("explode this thing") body.queue_free() + +func hurtPlayer(amt): + player.hurtPlayer(amt) + +func killPlayer(): + player.killPlayer() + +func deadPlayer(): + GameController.reset() + get_tree().reload_current_scene() +