diff --git a/februarygodotgame/assets/graphics/objects/crate.png b/februarygodotgame/assets/graphics/objects/crate.png new file mode 100644 index 0000000..2b8bdcd Binary files /dev/null and b/februarygodotgame/assets/graphics/objects/crate.png differ diff --git a/februarygodotgame/assets/graphics/objects/crate.png.import b/februarygodotgame/assets/graphics/objects/crate.png.import new file mode 100644 index 0000000..c9d73f1 --- /dev/null +++ b/februarygodotgame/assets/graphics/objects/crate.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://di215h0o7ybli" +path="res://.godot/imported/crate.png-b286bd97caa3cbc59746f2db7de46191.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/graphics/objects/crate.png" +dest_files=["res://.godot/imported/crate.png-b286bd97caa3cbc59746f2db7de46191.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/februarygodotgame/assets/graphics/player/idle/Player Idle 48x48.png b/februarygodotgame/assets/graphics/player/idle/Player Idle 48x48.png new file mode 100644 index 0000000..b618511 Binary files /dev/null and b/februarygodotgame/assets/graphics/player/idle/Player Idle 48x48.png differ diff --git a/februarygodotgame/assets/graphics/player/idle/Player Idle 48x48.png.import b/februarygodotgame/assets/graphics/player/idle/Player Idle 48x48.png.import new file mode 100644 index 0000000..80a4748 --- /dev/null +++ b/februarygodotgame/assets/graphics/player/idle/Player Idle 48x48.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://d6cdeej48ryk" +path="res://.godot/imported/Player Idle 48x48.png-9f43f14976963a2821a06ddf8579a76a.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/graphics/player/idle/Player Idle 48x48.png" +dest_files=["res://.godot/imported/Player Idle 48x48.png-9f43f14976963a2821a06ddf8579a76a.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/februarygodotgame/assets/graphics/player/jump/player jump 48x48.png b/februarygodotgame/assets/graphics/player/jump/player jump 48x48.png new file mode 100644 index 0000000..dff105c Binary files /dev/null and b/februarygodotgame/assets/graphics/player/jump/player jump 48x48.png differ diff --git a/februarygodotgame/assets/graphics/player/jump/player jump 48x48.png.import b/februarygodotgame/assets/graphics/player/jump/player jump 48x48.png.import new file mode 100644 index 0000000..12c7ca9 --- /dev/null +++ b/februarygodotgame/assets/graphics/player/jump/player jump 48x48.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bo4lwotnk3cs" +path="res://.godot/imported/player jump 48x48.png-1ccba0c36041038682bf917e1f6cf991.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/graphics/player/jump/player jump 48x48.png" +dest_files=["res://.godot/imported/player jump 48x48.png-1ccba0c36041038682bf917e1f6cf991.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/februarygodotgame/assets/graphics/player/run/player run 48x48.png b/februarygodotgame/assets/graphics/player/run/player run 48x48.png new file mode 100644 index 0000000..aca5b55 Binary files /dev/null and b/februarygodotgame/assets/graphics/player/run/player run 48x48.png differ diff --git a/februarygodotgame/assets/graphics/player/run/player run 48x48.png.import b/februarygodotgame/assets/graphics/player/run/player run 48x48.png.import new file mode 100644 index 0000000..ba9c0e5 --- /dev/null +++ b/februarygodotgame/assets/graphics/player/run/player run 48x48.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dny0tvbhrt1jh" +path="res://.godot/imported/player run 48x48.png-6d66612d48bfa4c8721495ba557ab7c6.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/graphics/player/run/player run 48x48.png" +dest_files=["res://.godot/imported/player run 48x48.png-6d66612d48bfa4c8721495ba557ab7c6.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/februarygodotgame/assets/graphics/projectiles/pixel_bullet.png b/februarygodotgame/assets/graphics/projectiles/pixel_bullet.png new file mode 100644 index 0000000..900d030 Binary files /dev/null and b/februarygodotgame/assets/graphics/projectiles/pixel_bullet.png differ diff --git a/februarygodotgame/assets/graphics/projectiles/pixel_bullet.png.import b/februarygodotgame/assets/graphics/projectiles/pixel_bullet.png.import new file mode 100644 index 0000000..14a8baa --- /dev/null +++ b/februarygodotgame/assets/graphics/projectiles/pixel_bullet.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bq0yaqauut372" +path="res://.godot/imported/pixel_bullet.png-30d6d1e8b5e1332f8b2e2cee72a9e790.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/graphics/projectiles/pixel_bullet.png" +dest_files=["res://.godot/imported/pixel_bullet.png-30d6d1e8b5e1332f8b2e2cee72a9e790.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/februarygodotgame/project.godot b/februarygodotgame/project.godot index da1f61b..e57c21b 100644 --- a/februarygodotgame/project.godot +++ b/februarygodotgame/project.godot @@ -15,6 +15,14 @@ run/main_scene="res://scenes/game.tscn" config/features=PackedStringArray("4.3", "Forward Plus") config/icon="res://icon.svg" +[display] + +window/size/viewport_width=320 +window/size/viewport_height=180 +window/size/window_width_override=960 +window/size/window_height_override=540 +window/stretch/mode="viewport" + [file_customization] folder_colors={ diff --git a/februarygodotgame/scenes/bullet.tscn b/februarygodotgame/scenes/bullet.tscn index 1b00981..fa29570 100644 --- a/februarygodotgame/scenes/bullet.tscn +++ b/februarygodotgame/scenes/bullet.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=3 format=3 uid="uid://b1jq6yi0dh3c0"] +[gd_scene load_steps=4 format=3 uid="uid://b1jq6yi0dh3c0"] [ext_resource type="Script" path="res://scripts/bullet.gd" id="1_okq17"] +[ext_resource type="Texture2D" uid="uid://bq0yaqauut372" path="res://assets/graphics/projectiles/pixel_bullet.png" id="2_ig66t"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_va0yp"] size = Vector2(10, 4) @@ -12,4 +13,9 @@ script = ExtResource("1_okq17") shape = SubResource("RectangleShape2D_va0yp") debug_color = Color(0.952024, 0.180224, 0.327437, 0.42) +[node name="Sprite2D" type="Sprite2D" parent="."] +position = Vector2(-3, 2) +scale = Vector2(-0.0800002, 0.0769233) +texture = ExtResource("2_ig66t") + [connection signal="body_entered" from="." to="." method="_on_body_entered"] diff --git a/februarygodotgame/scenes/crate.tscn b/februarygodotgame/scenes/crate.tscn new file mode 100644 index 0000000..ac6b303 --- /dev/null +++ b/februarygodotgame/scenes/crate.tscn @@ -0,0 +1,19 @@ +[gd_scene load_steps=3 format=3 uid="uid://celwbq1syhdoa"] + +[ext_resource type="Texture2D" uid="uid://di215h0o7ybli" path="res://assets/graphics/objects/crate.png" id="1_2vv2l"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_0u5k2"] +size = Vector2(34, 36) + +[node name="crate1" type="RigidBody2D"] +metadata/_edit_group_ = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("RectangleShape2D_0u5k2") +debug_color = Color(0.868673, 0.347634, 0.15033, 0.42) + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture_filter = 1 +position = Vector2(0, 3) +scale = Vector2(0.13, 0.13) +texture = ExtResource("1_2vv2l") diff --git a/februarygodotgame/scenes/game.tscn b/februarygodotgame/scenes/game.tscn index 300c257..4e52209 100644 --- a/februarygodotgame/scenes/game.tscn +++ b/februarygodotgame/scenes/game.tscn @@ -1,21 +1,22 @@ -[gd_scene load_steps=10 format=3 uid="uid://bt6uaac8wfn8k"] +[gd_scene load_steps=12 format=3 uid="uid://bt6uaac8wfn8k"] -[ext_resource type="Script" path="res://scripts/trigger.gd" id="1_8ewqq"] [ext_resource type="Script" path="res://scripts/gamecontroller.gd" id="1_wwyby"] +[ext_resource type="PackedScene" uid="uid://bibqnht5dooss" path="res://scenes/trigger.tscn" id="2_psv8k"] [ext_resource type="PackedScene" uid="uid://cjvyslsoa7olc" path="res://scenes/player.tscn" id="3_771dm"] +[ext_resource type="PackedScene" uid="uid://celwbq1syhdoa" path="res://scenes/crate.tscn" id="3_ek1d4"] +[ext_resource type="Script" path="res://scripts/crate.gd" id="4_5sp5n"] [ext_resource type="PackedScene" uid="uid://b1jq6yi0dh3c0" path="res://scenes/bullet.tscn" id="4_a2pol"] [ext_resource type="Script" path="res://scripts/scene_manager.gd" id="5_xhw0f"] [sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_gmy8j"] -[sub_resource type="CircleShape2D" id="CircleShape2D_civmy"] -radius = 21.0238 - [sub_resource type="RectangleShape2D" id="RectangleShape2D_ggdp1"] size = Vector2(72, 20) -[sub_resource type="RectangleShape2D" id="RectangleShape2D_0u5k2"] -size = Vector2(34, 36) +[sub_resource type="CircleShape2D" id="CircleShape2D_opmvx"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_1ymsv"] +size = Vector2(20, 40) [node name="Game" type="Node2D"] script = ExtResource("1_wwyby") @@ -27,15 +28,6 @@ metadata/_edit_group_ = true [node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"] shape = SubResource("WorldBoundaryShape2D_gmy8j") -[node name="Trigger" type="Area2D" parent="."] -position = Vector2(700, 476) -script = ExtResource("1_8ewqq") -metadata/_edit_group_ = true - -[node name="CollisionShape2D" type="CollisionShape2D" parent="Trigger"] -shape = SubResource("CircleShape2D_civmy") -debug_color = Color(0.611909, 0.392035, 0.935088, 0.42) - [node name="level" type="Node2D" parent="."] [node name="Brick" type="StaticBody2D" parent="level"] @@ -69,43 +61,24 @@ shape = SubResource("RectangleShape2D_ggdp1") [node name="crates" type="Node2D" parent="."] -[node name="crate1" type="RigidBody2D" parent="crates"] -position = Vector2(446, 462) -rotation = -0.516507 -metadata/_edit_group_ = true +[node name="crate1" parent="crates" instance=ExtResource("3_ek1d4")] +position = Vector2(481, 369) +script = ExtResource("4_5sp5n") -[node name="CollisionShape2D" type="CollisionShape2D" parent="crates/crate1"] -shape = SubResource("RectangleShape2D_0u5k2") -debug_color = Color(0.868673, 0.347634, 0.15033, 0.42) +[node name="crate2" parent="crates" instance=ExtResource("3_ek1d4")] +position = Vector2(534, 397) +rotation = 0.380482 +script = ExtResource("4_5sp5n") -[node name="crate3" type="RigidBody2D" parent="crates"] -position = Vector2(376, 466) -rotation = -0.516507 -metadata/_edit_group_ = true +[node name="crate4" parent="crates" instance=ExtResource("3_ek1d4")] +position = Vector2(628, 345) +rotation = 0.380482 +script = ExtResource("4_5sp5n") -[node name="CollisionShape2D" type="CollisionShape2D" parent="crates/crate3"] -shape = SubResource("RectangleShape2D_0u5k2") -debug_color = Color(0.868673, 0.347634, 0.15033, 0.42) - -[node name="crate2" type="RigidBody2D" parent="crates"] -position = Vector2(920, 473) -rotation = -1.2792 -scale = Vector2(1, 1) -metadata/_edit_group_ = true - -[node name="CollisionShape2D" type="CollisionShape2D" parent="crates/crate2"] -shape = SubResource("RectangleShape2D_0u5k2") -debug_color = Color(0.868673, 0.347634, 0.15033, 0.42) - -[node name="crate4" type="RigidBody2D" parent="crates"] -position = Vector2(868, 476) -rotation = -1.2792 -scale = Vector2(1, 1) -metadata/_edit_group_ = true - -[node name="CollisionShape2D" type="CollisionShape2D" parent="crates/crate4"] -shape = SubResource("RectangleShape2D_0u5k2") -debug_color = Color(0.868673, 0.347634, 0.15033, 0.42) +[node name="crate3" parent="crates" instance=ExtResource("3_ek1d4")] +position = Vector2(695, 332) +rotation = -0.760964 +script = ExtResource("4_5sp5n") [node name="CharacterBody2D" parent="." instance=ExtResource("3_771dm")] position = Vector2(461, 282) @@ -117,5 +90,20 @@ position = Vector2(284, 341) unique_name_in_owner = true script = ExtResource("5_xhw0f") -[connection signal="areaTrigger" from="Trigger" to="." method="_on_trigger_area_trigger"] -[connection signal="body_entered" from="Trigger" to="Trigger" method="_on_body_entered"] +[node name="triggers" type="Node2D" parent="."] + +[node name="Trigger" parent="triggers" instance=ExtResource("2_psv8k")] +effect = "destroy" + +[node name="CollisionShape2D" type="CollisionShape2D" parent="triggers/Trigger"] +shape = SubResource("CircleShape2D_opmvx") +debug_color = Color(0.731092, 0.294274, 0.91724, 0.42) + +[node name="powerup" parent="triggers" instance=ExtResource("2_psv8k")] +position = Vector2(791, 407) +effect = "powerup" + +[node name="CollisionShape2D" type="CollisionShape2D" parent="triggers/powerup"] +position = Vector2(0, -10) +shape = SubResource("RectangleShape2D_1ymsv") +debug_color = Color(0.156093, 0.622347, 0.484765, 0.42) diff --git a/februarygodotgame/scenes/player.tscn b/februarygodotgame/scenes/player.tscn index 3bc970f..d8a6eb0 100644 --- a/februarygodotgame/scenes/player.tscn +++ b/februarygodotgame/scenes/player.tscn @@ -1,9 +1,177 @@ -[gd_scene load_steps=3 format=3 uid="uid://cjvyslsoa7olc"] +[gd_scene load_steps=28 format=3 uid="uid://cjvyslsoa7olc"] [ext_resource type="Script" path="res://scripts/player.gd" id="1_ffdhb"] +[ext_resource type="Texture2D" uid="uid://d6cdeej48ryk" path="res://assets/graphics/player/idle/Player Idle 48x48.png" id="2_ekybh"] +[ext_resource type="Texture2D" uid="uid://bo4lwotnk3cs" path="res://assets/graphics/player/jump/player jump 48x48.png" id="3_fab18"] +[ext_resource type="Texture2D" uid="uid://dny0tvbhrt1jh" path="res://assets/graphics/player/run/player run 48x48.png" id="3_q7el6"] [sub_resource type="CircleShape2D" id="CircleShape2D_q23dn"] +[sub_resource type="AtlasTexture" id="AtlasTexture_3ufnv"] +atlas = ExtResource("2_ekybh") +region = Rect2(0, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_y70bw"] +atlas = ExtResource("2_ekybh") +region = Rect2(48, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_tl2bv"] +atlas = ExtResource("2_ekybh") +region = Rect2(96, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_tkkjs"] +atlas = ExtResource("2_ekybh") +region = Rect2(144, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_0fgmq"] +atlas = ExtResource("2_ekybh") +region = Rect2(192, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_vjujd"] +atlas = ExtResource("2_ekybh") +region = Rect2(240, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_307af"] +atlas = ExtResource("2_ekybh") +region = Rect2(288, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_nn3sj"] +atlas = ExtResource("2_ekybh") +region = Rect2(336, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_coouw"] +atlas = ExtResource("2_ekybh") +region = Rect2(384, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_w02ps"] +atlas = ExtResource("2_ekybh") +region = Rect2(432, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_u2bek"] +atlas = ExtResource("3_fab18") +region = Rect2(0, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_wly4a"] +atlas = ExtResource("3_fab18") +region = Rect2(48, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_p6fm4"] +atlas = ExtResource("3_fab18") +region = Rect2(96, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_q2tlv"] +atlas = ExtResource("3_q7el6") +region = Rect2(0, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_a5a0q"] +atlas = ExtResource("3_q7el6") +region = Rect2(48, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_qajev"] +atlas = ExtResource("3_q7el6") +region = Rect2(96, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_pkvyv"] +atlas = ExtResource("3_q7el6") +region = Rect2(144, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_d0umq"] +atlas = ExtResource("3_q7el6") +region = Rect2(192, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_cso7h"] +atlas = ExtResource("3_q7el6") +region = Rect2(240, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_08m43"] +atlas = ExtResource("3_q7el6") +region = Rect2(288, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_wuxnh"] +atlas = ExtResource("3_q7el6") +region = Rect2(336, 0, 48, 48) + +[sub_resource type="SpriteFrames" id="SpriteFrames_ok1w6"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_3ufnv") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_y70bw") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_tl2bv") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_tkkjs") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_0fgmq") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_vjujd") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_307af") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_nn3sj") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_coouw") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_w02ps") +}], +"loop": true, +"name": &"idle", +"speed": 12.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_u2bek") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_wly4a") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_p6fm4") +}], +"loop": false, +"name": &"jump", +"speed": 9.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_q2tlv") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_a5a0q") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_qajev") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_pkvyv") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_d0umq") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_cso7h") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_08m43") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_wuxnh") +}], +"loop": true, +"name": &"run", +"speed": 12.0 +}] + [node name="CharacterBody2D" type="CharacterBody2D"] script = ExtResource("1_ffdhb") metadata/_edit_group_ = true @@ -23,3 +191,12 @@ position = Vector2(18, -15) [node name="leftTarget" type="Node2D" parent="."] position = Vector2(-19, -15) + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] +texture_filter = 1 +position = Vector2(0, -7) +sprite_frames = SubResource("SpriteFrames_ok1w6") +animation = &"jump" +autoplay = "jump" + +[node name="Camera2D" type="Camera2D" parent="."] diff --git a/februarygodotgame/scenes/trigger.tscn b/februarygodotgame/scenes/trigger.tscn new file mode 100644 index 0000000..a3d6c3d --- /dev/null +++ b/februarygodotgame/scenes/trigger.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=2 format=3 uid="uid://bibqnht5dooss"] + +[ext_resource type="Script" path="res://scripts/trigger.gd" id="1_x8vqb"] + +[node name="Trigger" type="Area2D"] +position = Vector2(700, 476) +script = ExtResource("1_x8vqb") +metadata/_edit_group_ = true + +[connection signal="body_entered" from="." to="." method="_on_body_entered"] diff --git a/februarygodotgame/scripts/bullet.gd b/februarygodotgame/scripts/bullet.gd index 284e220..d540ce6 100644 --- a/februarygodotgame/scripts/bullet.gd +++ b/februarygodotgame/scripts/bullet.gd @@ -1,4 +1,5 @@ class_name Bullet extends Area2D +@onready var bulletGraphic: Sprite2D = $Sprite2D var speed = 750 @@ -6,6 +7,10 @@ signal hit(bullet, body) func setSpeed(value): speed = value + if speed <0: + bulletGraphic.flip_h = true + if speed >0: + bulletGraphic.flip_h = false #animation func _physics_process(delta: float) -> void: @@ -14,4 +19,5 @@ func _physics_process(delta: float) -> void: func _on_body_entered(body: Node2D) -> void: print("bullet collision") - hit.emit(self, body) + if not body is Player: + hit.emit(self, body) diff --git a/februarygodotgame/scripts/crate.gd b/februarygodotgame/scripts/crate.gd new file mode 100644 index 0000000..7f42195 --- /dev/null +++ b/februarygodotgame/scripts/crate.gd @@ -0,0 +1 @@ +class_name Crate extends RigidBody2D diff --git a/februarygodotgame/scripts/gamecontroller.gd b/februarygodotgame/scripts/gamecontroller.gd index 827f293..8719c49 100644 --- a/februarygodotgame/scripts/gamecontroller.gd +++ b/februarygodotgame/scripts/gamecontroller.gd @@ -1,4 +1,4 @@ -extends Node2D +class_name GameController extends Node2D # Game Data var totalCrates = 4 @@ -14,11 +14,26 @@ func _process(delta: float) -> void: pass -func _on_trigger_area_trigger(body) -> void: - print("Game controller knows about crate destruction") - cratesDestroyed +=1 - totalCrates -=1 - # kill em - body.queue_free() - if totalCrates <=0: - print("you won!!!") +func _on_trigger_area_trigger(effect, body) -> void: + print("Do effect "+effect) + match effect: + "destroy": + #write code to destroy + if body is Crate: + %SceneManager.destroy(body) + cratesDestroyed +=1 + "powerup": + if body is Player: + print("power up the player") + +func bulletHit(body): + print("Gamecontroller knows bullet hit") + if body is Crate: + print("You hit a crate") + cratesDestroyed +=1 + %SceneManager.destroy(body) + print("Crates Remaining :: "+str(totalCrates - cratesDestroyed)) + +func numberOfCrates(value): + totalCrates = value + print("Game Controller knows crates "+str(totalCrates) ) diff --git a/februarygodotgame/scripts/player.gd b/februarygodotgame/scripts/player.gd index f511d7b..ff5986a 100644 --- a/februarygodotgame/scripts/player.gd +++ b/februarygodotgame/scripts/player.gd @@ -1,4 +1,5 @@ -extends CharacterBody2D +class_name Player extends CharacterBody2D +@onready var playerGraphic: AnimatedSprite2D = $AnimatedSprite2D const SPEED = 300.0 @@ -9,6 +10,7 @@ var faceLeft = false var pushRightEnabled = false var pushLeftEnabled = false var pushTarget +var isJumping = false @onready var right_cast: RayCast2D = $rightCast @onready var left_cast: RayCast2D = $leftCast @@ -21,11 +23,16 @@ func _physics_process(delta: float) -> void: # Add the gravity. if not is_on_floor(): velocity += get_gravity() * delta + else: + isJumping = false + # Handle jump. if Input.is_action_just_pressed("ui_accept") and is_on_floor(): velocity.y = JUMP_VELOCITY - + isJumping = true + playerGraphic.play("jump") + # 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("left", "right") @@ -47,11 +54,19 @@ func _physics_process(delta: float) -> void: velocity.x = direction * SPEED else: velocity.x = move_toward(velocity.x, 0, SPEED) + if direction: + if not isJumping: + playerGraphic.play("run") + if direction ==0: + if not isJumping: + playerGraphic.play("idle") if direction <0: faceLeft = true + playerGraphic.flip_h = true if direction >0: faceLeft = false + playerGraphic.flip_h = false move_and_slide() diff --git a/februarygodotgame/scripts/scene_manager.gd b/februarygodotgame/scripts/scene_manager.gd index ac1eda1..5229bd6 100644 --- a/februarygodotgame/scripts/scene_manager.gd +++ b/februarygodotgame/scripts/scene_manager.gd @@ -1,4 +1,7 @@ extends Node +@onready var gameController: GameController = $".." +@onready var crates: Node2D = $"../crates" +@onready var triggers: Node2D = $"../triggers" var bulletsFiredTotal = 0 var bulletsMadeTotal = 0 @@ -30,3 +33,26 @@ func makeBullet(position, speed): func bulletHit(bullet, body): print("Tell the game controller a bullet hit something") + gameController.bulletHit(body) + bullet.setSpeed(0) + bullet.position = Vector2(-100,-100) + +func destroy(body): + body.queue_free() + +func buildLevel(): + #how many crates? + var totalCrates = 0 + for obj in crates.get_children(): + if obj is Crate: + totalCrates +=1 + gameController.numberOfCrates(totalCrates) + + #wire up the triggers + for obj in triggers.get_children(): + if obj is Trigger: + # wire up to GC + obj.areaTrigger.connect(gameController._on_trigger_area_trigger) + +func _ready() -> void: + buildLevel() diff --git a/februarygodotgame/scripts/trigger.gd b/februarygodotgame/scripts/trigger.gd index dc25afb..8eff92d 100644 --- a/februarygodotgame/scripts/trigger.gd +++ b/februarygodotgame/scripts/trigger.gd @@ -1,6 +1,7 @@ -extends Area2D +class_name Trigger extends Area2D +@export var effect="alert" -signal areaTrigger(Object) +signal areaTrigger(effect, Object) # Called when the node enters the scene tree for the first time. func _ready() -> void: print("Trigger is here") @@ -13,4 +14,4 @@ func _process(delta: float) -> void: func _on_body_entered(body: Node2D) -> void: print("Body collision in trigger") - areaTrigger.emit(body) + areaTrigger.emit(effect, body)