player animations, variable triggers, working bullets

This commit is contained in:
AliJaffar 2025-03-10 21:05:26 -04:00
parent adf15b6014
commit 6be8837687
22 changed files with 534 additions and 59 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://clmv1sjkccjts"
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://70imyp6vsgvv"
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1021 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://5ger8sg6iqqm"
path="res://.godot/imported/player jump 48x48(1).png-fa7880cd69f0b548526679985442ae31.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/graphics/player/jump/player jump 48x48(1).png"
dest_files=["res://.godot/imported/player jump 48x48(1).png-fa7880cd69f0b548526679985442ae31.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://crd320y5xhgwf"
path="res://.godot/imported/player run 48x48(1).png-eadbacc6e08d791a092ddb9cb1f96f0d.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/graphics/player/run/player run 48x48(1).png"
dest_files=["res://.godot/imported/player run 48x48(1).png-eadbacc6e08d791a092ddb9cb1f96f0d.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bsskoq57i4q43"
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

View File

@ -15,6 +15,14 @@ run/main_scene="res://scenes/game.tscn"
config/features=PackedStringArray("4.3", "Forward Plus") config/features=PackedStringArray("4.3", "Forward Plus")
config/icon="res://icon.svg" 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] [file_customization]
folder_colors={ folder_colors={

View File

@ -1,6 +1,7 @@
[gd_scene load_steps=3 format=3 uid="uid://dwy0c50ndnu8k"] [gd_scene load_steps=4 format=3 uid="uid://dwy0c50ndnu8k"]
[ext_resource type="Script" path="res://scripts/bullet.gd" id="1_v85g0"] [ext_resource type="Script" path="res://scripts/bullet.gd" id="1_v85g0"]
[ext_resource type="Texture2D" uid="uid://bsskoq57i4q43" path="res://assets/graphics/projectiles/pixel_bullet.png" id="2_ri5lc"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_pwf7j"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_pwf7j"]
size = Vector2(20, 4) size = Vector2(20, 4)
@ -12,4 +13,9 @@ script = ExtResource("1_v85g0")
shape = SubResource("RectangleShape2D_pwf7j") shape = SubResource("RectangleShape2D_pwf7j")
debug_color = Color(0.932915, 0.177129, 0.479323, 0.42) debug_color = Color(0.932915, 0.177129, 0.479323, 0.42)
[node name="Sprite2D" type="Sprite2D" parent="."]
position = Vector2(-6, -2)
scale = Vector2(-0.148858, -0.156823)
texture = ExtResource("2_ri5lc")
[connection signal="body_entered" from="." to="." method="_on_body_entered"] [connection signal="body_entered" from="." to="." method="_on_body_entered"]

View File

@ -0,0 +1,24 @@
[gd_scene load_steps=3 format=3 uid="uid://blcbdwowx2gr0"]
[ext_resource type="Texture2D" uid="uid://clmv1sjkccjts" path="res://assets/graphics/objects/crate.png" id="1_7dn7o"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_oospb"]
size = Vector2(23.4985, 66.016)
[node name="crate1" type="RigidBody2D"]
rotation = 1.0074
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0.791419, -3.05451)
rotation = -1.01686
scale = Vector2(2.89246, 1)
shape = SubResource("RectangleShape2D_oospb")
debug_color = Color(0.907205, 0.191988, 0.583153, 0.42)
[node name="Sprite2D" type="Sprite2D" parent="."]
texture_filter = 1
position = Vector2(-1.37951, 0.311383)
rotation = 0.560473
scale = Vector2(0.228016, 0.220525)
texture = ExtResource("1_7dn7o")

View File

@ -1,38 +1,31 @@
[gd_scene load_steps=10 format=3 uid="uid://dhopuj38ic6dp"] [gd_scene load_steps=12 format=3 uid="uid://dhopuj38ic6dp"]
[ext_resource type="Script" path="res://scripts/trigger.gd" id="1_7cb3s"]
[ext_resource type="Script" path="res://scripts/gamecontroller.gd" id="1_dasmg"] [ext_resource type="Script" path="res://scripts/gamecontroller.gd" id="1_dasmg"]
[ext_resource type="PackedScene" uid="uid://dgos05617rcuq" path="res://scenes/trigger.tscn" id="2_070us"]
[ext_resource type="PackedScene" uid="uid://blcbdwowx2gr0" path="res://scenes/crate.tscn" id="3_4f2of"]
[ext_resource type="PackedScene" uid="uid://du8aftivw4k25" path="res://scenes/player.tscn" id="3_glxkt"] [ext_resource type="PackedScene" uid="uid://du8aftivw4k25" path="res://scenes/player.tscn" id="3_glxkt"]
[ext_resource type="PackedScene" uid="uid://dwy0c50ndnu8k" path="res://scenes/bullet.tscn" id="4_2bgno"] [ext_resource type="PackedScene" uid="uid://dwy0c50ndnu8k" path="res://scenes/bullet.tscn" id="4_2bgno"]
[ext_resource type="Script" path="res://scripts/crate.gd" id="4_4n32v"]
[ext_resource type="Script" path="res://scripts/scene_manager.gd" id="5_6wvkt"] [ext_resource type="Script" path="res://scripts/scene_manager.gd" id="5_6wvkt"]
[sub_resource type="CircleShape2D" id="CircleShape2D_ox8o7"]
radius = 31.0161
[sub_resource type="RectangleShape2D" id="RectangleShape2D_uopew"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_uopew"]
size = Vector2(70, 26) size = Vector2(70, 26)
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_igau3"] [sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_igau3"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_oospb"] [sub_resource type="CircleShape2D" id="CircleShape2D_8p7pp"]
size = Vector2(43.1503, 26)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ape5f"]
size = Vector2(20, 46)
[node name="Game" type="Node2D"] [node name="Game" type="Node2D"]
script = ExtResource("1_dasmg") script = ExtResource("1_dasmg")
[node name="Trigger" type="Area2D" parent="."]
position = Vector2(570, 452)
script = ExtResource("1_7cb3s")
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Trigger"]
shape = SubResource("CircleShape2D_ox8o7")
debug_color = Color(0.448323, 0.465614, 0.961841, 0.42)
[node name="Level" type="Node2D" parent="."] [node name="Level" type="Node2D" parent="."]
position = Vector2(-12, -3)
[node name="StaticBody2D" type="StaticBody2D" parent="Level"] [node name="StaticBody2D" type="StaticBody2D" parent="Level"]
position = Vector2(525, 412) position = Vector2(479, 385)
metadata/_edit_group_ = true metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Level/StaticBody2D"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Level/StaticBody2D"]
@ -40,16 +33,25 @@ position = Vector2(-26, 3)
shape = SubResource("RectangleShape2D_uopew") shape = SubResource("RectangleShape2D_uopew")
[node name="StaticBody2D3" type="StaticBody2D" parent="Level"] [node name="StaticBody2D3" type="StaticBody2D" parent="Level"]
position = Vector2(525, 412) position = Vector2(588, 494)
rotation = 2.16668 rotation = 3.16193
metadata/_edit_group_ = true metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Level/StaticBody2D3"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Level/StaticBody2D3"]
position = Vector2(-26, 3) position = Vector2(-26, 3)
shape = SubResource("RectangleShape2D_uopew") shape = SubResource("RectangleShape2D_uopew")
[node name="StaticBody2D4" type="StaticBody2D" parent="Level"]
position = Vector2(345, 490)
rotation = 3.16193
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Level/StaticBody2D4"]
position = Vector2(-26, 3)
shape = SubResource("RectangleShape2D_uopew")
[node name="StaticBody2D2" type="StaticBody2D" parent="Level"] [node name="StaticBody2D2" type="StaticBody2D" parent="Level"]
position = Vector2(11, 464) position = Vector2(10, 528)
metadata/_edit_group_ = true metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Level/StaticBody2D2"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Level/StaticBody2D2"]
@ -57,28 +59,23 @@ position = Vector2(518, 20)
shape = SubResource("WorldBoundaryShape2D_igau3") shape = SubResource("WorldBoundaryShape2D_igau3")
[node name="crates" type="Node2D" parent="."] [node name="crates" type="Node2D" parent="."]
position = Vector2(13, 53)
[node name="crate2" type="RigidBody2D" parent="crates"] [node name="crate1" parent="crates" instance=ExtResource("3_4f2of")]
position = Vector2(616, 580) position = Vector2(141, 371)
rotation = -0.385715 script = ExtResource("4_4n32v")
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="crates/crate2"] [node name="crate2" parent="crates" instance=ExtResource("3_4f2of")]
position = Vector2(107.026, -85.1608) position = Vector2(699, 397)
shape = SubResource("RectangleShape2D_oospb") script = ExtResource("4_4n32v")
debug_color = Color(0.907205, 0.191988, 0.583153, 0.42)
[node name="crate1" type="RigidBody2D" parent="crates"] [node name="crate3" parent="crates" instance=ExtResource("3_4f2of")]
position = Vector2(193, 264) position = Vector2(575, 177)
rotation = 0.807772 script = ExtResource("4_4n32v")
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="crates/crate1"] [node name="crate4" parent="crates" instance=ExtResource("3_4f2of")]
position = Vector2(23.712, 8.64544) position = Vector2(217, 230)
rotation = -1.01686 script = ExtResource("4_4n32v")
scale = Vector2(2.89246, 1)
shape = SubResource("RectangleShape2D_oospb")
debug_color = Color(0.907205, 0.191988, 0.583153, 0.42)
[node name="CharacterBody2D" parent="." instance=ExtResource("3_glxkt")] [node name="CharacterBody2D" parent="." instance=ExtResource("3_glxkt")]
position = Vector2(338, 226) position = Vector2(338, 226)
@ -90,5 +87,23 @@ position = Vector2(330, 271)
unique_name_in_owner = true unique_name_in_owner = true
script = ExtResource("5_6wvkt") script = ExtResource("5_6wvkt")
[connection signal="areaTrigger" from="Trigger" to="." method="_on_trigger_area_trigger"] [node name="triggers" type="Node2D" parent="."]
[connection signal="body_entered" from="Trigger" to="Trigger" method="_on_body_entered"] rotation = -0.0128695
[node name="Trigger" parent="triggers" instance=ExtResource("2_070us")]
position = Vector2(509.188, 532.597)
rotation = -1.90254
effect = "destroy"
[node name="CollisionShape2D" type="CollisionShape2D" parent="triggers/Trigger"]
shape = SubResource("CircleShape2D_8p7pp")
debug_color = Color(0.622849, 0.37564, 0.95389, 0.42)
[node name="powerup" parent="triggers" instance=ExtResource("2_070us")]
position = Vector2(597.12, 460.723)
effect = "powerup"
[node name="CollisionShape2D" type="CollisionShape2D" parent="triggers/powerup"]
position = Vector2(0, -13)
shape = SubResource("RectangleShape2D_ape5f")
debug_color = Color(0.644817, 0.359472, 0.952285, 0.42)

View File

@ -1,9 +1,177 @@
[gd_scene load_steps=3 format=3 uid="uid://du8aftivw4k25"] [gd_scene load_steps=28 format=3 uid="uid://du8aftivw4k25"]
[ext_resource type="Script" path="res://scripts/player.gd" id="1_p8gev"] [ext_resource type="Script" path="res://scripts/player.gd" id="1_p8gev"]
[ext_resource type="Texture2D" uid="uid://70imyp6vsgvv" path="res://assets/graphics/player/idle/Player Idle 48x48.png" id="2_vqtu4"]
[ext_resource type="Texture2D" uid="uid://5ger8sg6iqqm" path="res://assets/graphics/player/jump/player jump 48x48(1).png" id="3_k55ht"]
[ext_resource type="Texture2D" uid="uid://crd320y5xhgwf" path="res://assets/graphics/player/run/player run 48x48(1).png" id="3_olacu"]
[sub_resource type="CircleShape2D" id="CircleShape2D_a75m4"] [sub_resource type="CircleShape2D" id="CircleShape2D_a75m4"]
[sub_resource type="AtlasTexture" id="AtlasTexture_lxsaf"]
atlas = ExtResource("2_vqtu4")
region = Rect2(0, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_nc8f5"]
atlas = ExtResource("2_vqtu4")
region = Rect2(48, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_8t17o"]
atlas = ExtResource("2_vqtu4")
region = Rect2(96, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_un46h"]
atlas = ExtResource("2_vqtu4")
region = Rect2(144, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_yyi6q"]
atlas = ExtResource("2_vqtu4")
region = Rect2(192, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_e17dv"]
atlas = ExtResource("2_vqtu4")
region = Rect2(240, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_4i4mp"]
atlas = ExtResource("2_vqtu4")
region = Rect2(288, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_g1pat"]
atlas = ExtResource("2_vqtu4")
region = Rect2(336, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_udrwm"]
atlas = ExtResource("2_vqtu4")
region = Rect2(384, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_64ecg"]
atlas = ExtResource("2_vqtu4")
region = Rect2(432, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_0w8hc"]
atlas = ExtResource("3_k55ht")
region = Rect2(0, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_gnkqd"]
atlas = ExtResource("3_k55ht")
region = Rect2(48, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_xblxa"]
atlas = ExtResource("3_k55ht")
region = Rect2(96, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_14w4b"]
atlas = ExtResource("3_olacu")
region = Rect2(0, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_ed7pw"]
atlas = ExtResource("3_olacu")
region = Rect2(48, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_bf8mn"]
atlas = ExtResource("3_olacu")
region = Rect2(96, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_3jaw1"]
atlas = ExtResource("3_olacu")
region = Rect2(144, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_nfpx8"]
atlas = ExtResource("3_olacu")
region = Rect2(192, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_vv4dg"]
atlas = ExtResource("3_olacu")
region = Rect2(240, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_pevx6"]
atlas = ExtResource("3_olacu")
region = Rect2(288, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_ytupl"]
atlas = ExtResource("3_olacu")
region = Rect2(336, 0, 48, 48)
[sub_resource type="SpriteFrames" id="SpriteFrames_upnp5"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_lxsaf")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_nc8f5")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_8t17o")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_un46h")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_yyi6q")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_e17dv")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_4i4mp")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_g1pat")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_udrwm")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_64ecg")
}],
"loop": true,
"name": &"idle",
"speed": 12.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_0w8hc")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_gnkqd")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_xblxa")
}],
"loop": false,
"name": &"jump",
"speed": 9.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_14w4b")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ed7pw")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_bf8mn")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_3jaw1")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_nfpx8")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_vv4dg")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_pevx6")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ytupl")
}],
"loop": true,
"name": &"run",
"speed": 12.0
}]
[node name="CharacterBody2D" type="CharacterBody2D"] [node name="CharacterBody2D" type="CharacterBody2D"]
script = ExtResource("1_p8gev") script = ExtResource("1_p8gev")
metadata/_edit_group_ = true metadata/_edit_group_ = true
@ -23,3 +191,14 @@ position = Vector2(11, -10)
[node name="leftTarget" type="Node2D" parent="."] [node name="leftTarget" type="Node2D" parent="."]
position = Vector2(-15, -10) position = Vector2(-15, -10)
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
texture_filter = 1
position = Vector2(0, -7)
sprite_frames = SubResource("SpriteFrames_upnp5")
animation = &"jump"
autoplay = "jump"
frame = 2
frame_progress = 1.0
[node name="Camera2D" type="Camera2D" parent="."]

View File

@ -0,0 +1,9 @@
[gd_scene load_steps=2 format=3 uid="uid://dgos05617rcuq"]
[ext_resource type="Script" path="res://scripts/trigger.gd" id="1_3piuk"]
[node name="Trigger" type="Area2D"]
script = ExtResource("1_3piuk")
metadata/_edit_group_ = true
[connection signal="body_entered" from="." to="." method="_on_body_entered"]

View File

@ -1,4 +1,5 @@
class_name Bullet extends Area2D class_name Bullet extends Area2D
@onready var bulletGraphic: Sprite2D = $Sprite2D
var speed = 750 var speed = 750
@ -6,7 +7,10 @@ signal hit(bullet, body)
func setSpeed(value): func setSpeed(value):
speed = value speed = value
if speed<0:
bulletGraphic.flip_h = true
if speed>0:
bulletGraphic.flip_h = false
#animation #animation
func _physics_process(delta: float) -> void: func _physics_process(delta: float) -> void:
position += transform.x * speed * delta position += transform.x * speed * delta
@ -14,4 +18,5 @@ func _physics_process(delta: float) -> void:
func _on_body_entered(body: Node2D) -> void: func _on_body_entered(body: Node2D) -> void:
print ("bullet collision") print ("bullet collision")
if not body is Player:
hit.emit(self, body) hit.emit(self, body)

View File

@ -0,0 +1 @@
class_name Crate extends RigidBody2D

View File

@ -1,4 +1,4 @@
extends Node2D class_name GameController extends Node2D
#Game Data #Game Data
var totalCrates = 2 var totalCrates = 2
@ -14,12 +14,27 @@ func _process(delta: float) -> void:
pass pass
func _on_trigger_area_trigger(body) -> void: func _on_trigger_area_trigger(effect, body) -> void:
print("Game controller knows about crate destruction") print("Do effect "+effect)
match effect:
"destroy":
#write code to destroy
if body is Crate:
%SceneManager.destroy(body)
cratesDestroyed +=1 cratesDestroyed +=1
totalCrates -=1 "powerup":
# kill em if body is Player:
body.queue_free() print("power up the player")
if totalCrates <=0:
print("you won")
func bulletHit(body):
print("Game controller 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))

View File

@ -1,4 +1,5 @@
extends CharacterBody2D class_name Player extends CharacterBody2D
@onready var playerGraphic: AnimatedSprite2D = $AnimatedSprite2D
const SPEED = 300.0 const SPEED = 300.0
@ -9,21 +10,25 @@ var faceLeft = false
var pushRightEnabled = false var pushRightEnabled = false
var pushLeftEnabled = false var pushLeftEnabled = false
var pushTarget var pushTarget
var isJumping = false
@onready var rightcast: RayCast2D = $rightcast @onready var rightcast: RayCast2D = $rightcast
@onready var leftcast: RayCast2D = $leftcast @onready var leftcast: RayCast2D = $leftcast
@onready var right_target: Node2D = $rightTarget @onready var right_target: Node2D = $rightTarget
@onready var left_target: Node2D = $leftTarget @onready var left_target: Node2D = $leftTarget
func _physics_process(delta: float) -> void: func _physics_process(delta: float) -> void:
# Add the gravity. # Add the gravity.
if not is_on_floor(): if not is_on_floor():
velocity += get_gravity() * delta velocity += get_gravity() * delta
else:
isJumping = false
# 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():
velocity.y = JUMP_VELOCITY velocity.y = JUMP_VELOCITY
isJumping = true
playerGraphic.play("jump")
# Get the input direction and handle the movement/deceleration. # Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions. # As good practice, you should replace UI actions with custom gameplay actions.
@ -46,10 +51,19 @@ func _physics_process(delta: float) -> void:
velocity.x = direction * SPEED velocity.x = direction * SPEED
else: else:
velocity.x = move_toward(velocity.x, 0, SPEED) 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: if direction <0:
faceLeft = true faceLeft = true
playerGraphic.flip_h = true
if direction >0: if direction >0:
faceLeft = false faceLeft = false
playerGraphic.flip_h = false
move_and_slide() move_and_slide()
if rightcast.is_colliding(): if rightcast.is_colliding():

View File

@ -1,4 +1,8 @@
extends Node extends Node
@onready var gameController: Node2D = $".."
@onready var crates: Node2D = $"../crates"
@onready var triggers: Node2D = $"../triggers"
var bulletsFiredTotal = 0 var bulletsFiredTotal = 0
var bulletsMadeTotal = 0 var bulletsMadeTotal = 0
@ -26,5 +30,29 @@ func makeBullet(position,speed):
owner.add_child(newBullet) owner.add_child(newBullet)
newBullet.setSpeed(speed) newBullet.setSpeed(speed)
newBullet.transform = position newBullet.transform = position
func bulletHit(bullet, body): func bulletHit(bullet, body):
print("Tell the game controller a bullet hit something") 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()

View File

@ -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. # Called when the node enters the scene tree for the first time.
func _ready() -> void: func _ready() -> void:
print("Trigger is here") print("Trigger is here")
@ -13,4 +14,4 @@ func _process(delta: float) -> void:
func _on_body_entered(body: Node2D) -> void: func _on_body_entered(body: Node2D) -> void:
print("body collision in trigger") print("body collision in trigger")
areaTrigger.emit(body) areaTrigger.emit(effect, body)