Compare commits

...
3 Commits
Author SHA1 Message Date
MarkYabut c1486f3e55 week3 2026-10-13 20:58:42 -04:00
MarkYabut 3607e63548 fin 2026-10-06 20:58:01 -04:00
MarkYabut 8768909429 halfway 2026-10-06 19:44:18 -04:00
23 changed files with 721 additions and 77 deletions

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

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

@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://xg78j2xrx5uh"
path="res://.godot/imported/player jump 48x48.png-bb6ba8ccf76c9bd3765199af95f48c3c.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/graphics/player/jump_fall/player jump 48x48.png"
dest_files=["res://.godot/imported/player jump 48x48.png-bb6ba8ccf76c9bd3765199af95f48c3c.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: 3.1 KiB

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

@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cjjer1w77c3g3"
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/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
+13
View File
@@ -27,6 +27,19 @@ folder_colors={
"res://scripts/": "red" "res://scripts/": "red"
} }
[input]
shove={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":76,"key_label":0,"unicode":108,"location":0,"echo":false,"script":null)
]
}
shoot={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":88,"key_label":0,"unicode":120,"location":0,"echo":false,"script":null)
]
}
[physics] [physics]
3d/physics_engine="Jolt Physics" 3d/physics_engine="Jolt Physics"
+24
View File
@@ -0,0 +1,24 @@
[gd_scene format=3 uid="uid://bdd87ih2rf4yk"]
[ext_resource type="Script" uid="uid://ryrc3a88d0nh" path="res://scripts/bullet.gd" id="1_v7oki"]
[ext_resource type="Texture2D" uid="uid://cjjer1w77c3g3" path="res://assets/graphics/projectiles/pixel_bullet.png" id="2_y25gk"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_rk402"]
size = Vector2(48, 6)
[node name="Bullet" type="Area2D" unique_id=1365507081]
scale = Vector2(1, 0.88)
script = ExtResource("1_v7oki")
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=789397651]
shape = SubResource("RectangleShape2D_rk402")
debug_color = Color(0.8214046, 0, 0.03968804, 0.41960785)
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=2036585762]
texture_filter = 1
position = Vector2(15.000001, 3.4090908)
scale = Vector2(0.3763514, 0.15654685)
texture = ExtResource("2_y25gk")
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
+13
View File
@@ -0,0 +1,13 @@
[gd_scene format=3 uid="uid://5xgx7qarkj3o"]
[ext_resource type="Script" uid="uid://rp1f47ytyerd" path="res://scripts/crate.gd" id="1_b66cd"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_3udav"]
[node name="Crate" type="RigidBody2D" unique_id=643245962]
script = ExtResource("1_b66cd")
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=712768436]
shape = SubResource("RectangleShape2D_3udav")
debug_color = Color(0.8750005, 0.33663103, 0.2080481, 0.41960785)
+24 -63
View File
@@ -1,24 +1,22 @@
[gd_scene format=3 uid="uid://cexci4ob8r45g"] [gd_scene format=3 uid="uid://cexci4ob8r45g"]
[ext_resource type="Script" uid="uid://ct51411gsine2" path="res://scripts/gamecontroller.gd" id="1_lnu2h"] [ext_resource type="Script" uid="uid://ct51411gsine2" path="res://scripts/gamecontroller.gd" id="1_lnu2h"]
[ext_resource type="Script" uid="uid://ct34rf6jscqmo" path="res://scripts/player.gd" id="1_uwrxv"] [ext_resource type="Script" uid="uid://dv2q4p6jb8h4s" path="res://scripts/scene_manager.gd" id="2_lbhrr"]
[ext_resource type="Script" uid="uid://ck2uw1e2b0646" path="res://scripts/trigger.gd" id="1_yqjtg"] [ext_resource type="PackedScene" uid="uid://b22qsgmtr231s" path="res://scenes/trigger.tscn" id="2_lnu2h"]
[ext_resource type="PackedScene" uid="uid://5xgx7qarkj3o" path="res://scenes/crate.tscn" id="3_iywne"]
[ext_resource type="PackedScene" uid="uid://dtegcgc8xcxfg" path="res://scenes/player.tscn" id="4_iywne"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_rk402"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_rk402"]
size = Vector2(336, 20) size = Vector2(336, 20)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_3udav"]
[sub_resource type="CircleShape2D" id="CircleShape2D_rk402"]
radius = 21.0
[sub_resource type="CircleShape2D" id="CircleShape2D_3udav"]
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_rk402"] [sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_rk402"]
[node name="Game" type="Node2D" unique_id=55511178] [node name="Game" type="Node2D" unique_id=55511178]
script = ExtResource("1_lnu2h") script = ExtResource("1_lnu2h")
[node name="SceneManager" type="Node2D" parent="." unique_id=1159498670]
script = ExtResource("2_lbhrr")
[node name="StaticBody2D" type="StaticBody2D" parent="." unique_id=704028978] [node name="StaticBody2D" type="StaticBody2D" parent="." unique_id=704028978]
position = Vector2(512, 413) position = Vector2(512, 413)
metadata/_edit_group_ = true metadata/_edit_group_ = true
@@ -27,59 +25,11 @@ metadata/_edit_group_ = true
position = Vector2(134, 0) position = Vector2(134, 0)
shape = SubResource("RectangleShape2D_rk402") shape = SubResource("RectangleShape2D_rk402")
[node name="RigidBody2D" type="RigidBody2D" parent="." unique_id=1467136223] [node name="Crate2" parent="." unique_id=643245962 instance=ExtResource("3_iywne")]
position = Vector2(520, -51) position = Vector2(565, 386)
rotation = -0.5400262
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D" unique_id=2111742955] [node name="Player" parent="." unique_id=196049189 instance=ExtResource("4_iywne")]
shape = SubResource("RectangleShape2D_3udav") position = Vector2(649, 388)
debug_color = Color(0.8750005, 0.33663103, 0.2080481, 0.41960785)
[node name="RigidBody2D2" type="RigidBody2D" parent="." unique_id=375764923]
position = Vector2(512, 309)
rotation = -0.5400262
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D2" unique_id=1689937601]
shape = SubResource("RectangleShape2D_3udav")
debug_color = Color(0.8750005, 0.33663103, 0.2080481, 0.41960785)
[node name="RigidBody2D3" type="RigidBody2D" parent="." unique_id=1851225816]
position = Vector2(513, 269)
rotation = -0.5400262
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D3" unique_id=1720572197]
shape = SubResource("RectangleShape2D_3udav")
debug_color = Color(0.8750005, 0.33663103, 0.2080481, 0.41960785)
[node name="RigidBody2D4" type="RigidBody2D" parent="." unique_id=190350635]
position = Vector2(507, 236.99997)
rotation = -0.5400262
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D4" unique_id=938737972]
shape = SubResource("RectangleShape2D_3udav")
debug_color = Color(0.8750005, 0.33663103, 0.2080481, 0.41960785)
[node name="Trigger" type="Area2D" parent="." unique_id=644670290]
position = Vector2(442, 424)
script = ExtResource("1_yqjtg")
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Trigger" unique_id=258207955]
shape = SubResource("CircleShape2D_rk402")
debug_color = Color(0.7183221, 0.30049416, 0.93278134, 0.41960785)
[node name="CharacterBody2D" type="CharacterBody2D" parent="." unique_id=1639753258]
position = Vector2(743, 389)
script = ExtResource("1_uwrxv")
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D" unique_id=1073881258]
shape = SubResource("CircleShape2D_3udav")
debug_color = Color(0.3147444, 0.626224, 7.70092e-07, 0.41960785)
[node name="StaticBody2D2" type="StaticBody2D" parent="." unique_id=220630225] [node name="StaticBody2D2" type="StaticBody2D" parent="." unique_id=220630225]
position = Vector2(622, 483) position = Vector2(622, 483)
@@ -96,5 +46,16 @@ metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D3" unique_id=1824150982] [node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D3" unique_id=1824150982]
shape = SubResource("WorldBoundaryShape2D_rk402") shape = SubResource("WorldBoundaryShape2D_rk402")
[connection signal="areaTriggered" from="Trigger" to="." method="_on_trigger"] [node name="Triggers" type="Node2D" parent="." unique_id=262196455]
[connection signal="body_entered" from="Trigger" to="Trigger" method="_on_body_entered"]
[node name="Trigger" parent="Triggers" unique_id=976913827 instance=ExtResource("2_lnu2h")]
position = Vector2(421, 379)
effect = "teleport"
[node name="Trigger2" parent="Triggers" unique_id=1872559968 instance=ExtResource("2_lnu2h")]
position = Vector2(868, 384)
[node name="Crate" parent="." unique_id=329828405 instance=ExtResource("3_iywne")]
position = Vector2(742, 388)
[connection signal="areaTriggered" from="Triggers/Trigger" to="." method="_on_trigger"]
+207
View File
@@ -0,0 +1,207 @@
[gd_scene format=3 uid="uid://dtegcgc8xcxfg"]
[ext_resource type="Script" uid="uid://ct34rf6jscqmo" path="res://scripts/player.gd" id="1_3vyb7"]
[ext_resource type="Texture2D" uid="uid://xg78j2xrx5uh" path="res://assets/graphics/player/jump_fall/player jump 48x48.png" id="2_dqkch"]
[ext_resource type="Texture2D" uid="uid://cv1an7bix4lg4" path="res://assets/graphics/player/idle/Player Idle 48x48.png" id="2_g2els"]
[ext_resource type="Texture2D" uid="uid://rdkrvqncrci5" path="res://assets/graphics/player/run/player run 48x48.png" id="3_qhqgy"]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_3udav"]
[sub_resource type="AtlasTexture" id="AtlasTexture_i4ail"]
atlas = ExtResource("2_dqkch")
region = Rect2(96, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_qhqgy"]
atlas = ExtResource("2_g2els")
region = Rect2(0, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_dqkch"]
atlas = ExtResource("2_g2els")
region = Rect2(48, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_qlg0r"]
atlas = ExtResource("2_g2els")
region = Rect2(96, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_tuyoq"]
atlas = ExtResource("2_g2els")
region = Rect2(144, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_fjrip"]
atlas = ExtResource("2_g2els")
region = Rect2(192, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_smehm"]
atlas = ExtResource("2_g2els")
region = Rect2(240, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_ur7pv"]
atlas = ExtResource("2_g2els")
region = Rect2(288, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_y4r1p"]
atlas = ExtResource("2_g2els")
region = Rect2(336, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_d2wvv"]
atlas = ExtResource("2_g2els")
region = Rect2(384, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_3v2ag"]
atlas = ExtResource("2_g2els")
region = Rect2(432, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_a38lo"]
atlas = ExtResource("2_dqkch")
region = Rect2(0, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_4ni07"]
atlas = ExtResource("2_dqkch")
region = Rect2(48, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_jej6c"]
atlas = ExtResource("3_qhqgy")
region = Rect2(0, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_f1ej7"]
atlas = ExtResource("3_qhqgy")
region = Rect2(48, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_oprun"]
atlas = ExtResource("3_qhqgy")
region = Rect2(96, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_a8ls1"]
atlas = ExtResource("3_qhqgy")
region = Rect2(144, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_qfm1y"]
atlas = ExtResource("3_qhqgy")
region = Rect2(192, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_fulsm"]
atlas = ExtResource("3_qhqgy")
region = Rect2(240, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_4r5pv"]
atlas = ExtResource("3_qhqgy")
region = Rect2(288, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_60mlk"]
atlas = ExtResource("3_qhqgy")
region = Rect2(336, 0, 48, 48)
[sub_resource type="SpriteFrames" id="SpriteFrames_rk402"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_i4ail")
}],
"loop": 0,
"name": &"fall",
"speed": 12.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_qhqgy")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_dqkch")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_qlg0r")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_tuyoq")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_fjrip")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_smehm")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ur7pv")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_y4r1p")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_d2wvv")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_3v2ag")
}],
"loop": 1,
"name": &"idle",
"speed": 12.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_a38lo")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_4ni07")
}],
"loop": 0,
"name": &"jump",
"speed": 12.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_jej6c")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_f1ej7")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_oprun")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_a8ls1")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_qfm1y")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_fulsm")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_4r5pv")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_60mlk")
}],
"loop": 1,
"name": &"run",
"speed": 12.0
}]
[node name="Player" type="CharacterBody2D" unique_id=196049189]
script = ExtResource("1_3vyb7")
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=2119336955]
shape = SubResource("CapsuleShape2D_3udav")
debug_color = Color(0.3147444, 0.626224, 7.70092e-07, 0.41960785)
[node name="RightCast" type="RayCast2D" parent="." unique_id=2094112178]
target_position = Vector2(21, 0)
[node name="LeftCast" type="RayCast2D" parent="." unique_id=696595381]
target_position = Vector2(-22, 0)
[node name="RightSpawn" type="Marker2D" parent="." unique_id=1840944729]
position = Vector2(14, -6)
[node name="LeftSpawn" type="Marker2D" parent="." unique_id=441180819]
position = Vector2(-13, -6)
[node name="PlayerGraphic" type="AnimatedSprite2D" parent="." unique_id=630800083]
texture_filter = 1
position = Vector2(1, -2)
sprite_frames = SubResource("SpriteFrames_rk402")
animation = &"run"
autoplay = "idle"
[connection signal="animation_finished" from="PlayerGraphic" to="." method="_on_animation_finished"]
+16
View File
@@ -0,0 +1,16 @@
[gd_scene format=3 uid="uid://b22qsgmtr231s"]
[ext_resource type="Script" uid="uid://ck2uw1e2b0646" path="res://scripts/trigger.gd" id="1_du5ex"]
[sub_resource type="CircleShape2D" id="CircleShape2D_rk402"]
radius = 21.0
[node name="Trigger" type="Area2D" unique_id=976913827]
script = ExtResource("1_du5ex")
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1617755137]
shape = SubResource("CircleShape2D_rk402")
debug_color = Color(0.7183221, 0.30049416, 0.93278134, 0.41960785)
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
+20
View File
@@ -0,0 +1,20 @@
class_name Bullet extends Area2D
var speed := 700
signal bulletDamageSignal(body, bullet)
# 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:
position += transform.x * speed * delta
func _on_body_entered(body: Node2D) -> void:
print("Bullet hit something " + body.to_string())
bulletDamageSignal.emit(body, self)
func setSpeed(value)-> void:
speed = value
+1
View File
@@ -0,0 +1 @@
uid://ryrc3a88d0nh
+21
View File
@@ -0,0 +1,21 @@
class_name Crate extends RigidBody2D
var teleport_target: Vector2 = Vector2.ZERO
var should_teleport: bool = false
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func teleport_to(position: Vector2):
teleport_target = position
should_teleport = true
func _integrate_forces(state: PhysicsDirectBodyState2D) -> void:
if should_teleport:
state.transform = Transform2D.IDENTITY.translated(teleport_target)
should_teleport = false
+1
View File
@@ -0,0 +1 @@
uid://rp1f47ytyerd
+19 -5
View File
@@ -1,5 +1,7 @@
extends Node2D class_name GameController extends Node2D
signal teleportSignal(body:RigidBody2D)
signal destroySignal(body)
# 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:
@@ -12,7 +14,19 @@ func _process(delta: float) -> void:
func _on_trigger(effect: Variant, Object: Variant) -> void: func _on_trigger(effect: Variant, Object: Variant) -> void:
print("GC knows about trigger") print("GC knows about trigger: " + effect)
if effect == "destroy": match effect:
if not Object is Player: "destroy":
Object.queue_free() if not Object is Player:
destroySignal.emit(Object)
"teleport":
print("Trigger wants to teleport")
if Object is Crate:
teleportSignal.emit(Object)
func _on_bullet_hit(body, bullet) -> void:
print("GC knows bullet hit")
if body is Crate:
destroySignal.emit(body)
destroySignal.emit(bullet)
+121 -7
View File
@@ -1,30 +1,144 @@
class_name Player extends CharacterBody2D class_name Player extends CharacterBody2D
@onready var right_cast: RayCast2D = $RightCast
@onready var left_cast: RayCast2D = $LeftCast
@onready var right_spawn: Marker2D = $RightSpawn
@onready var left_spawn: Marker2D = $LeftSpawn
@onready var player_graphic: AnimatedSprite2D = $PlayerGraphic
@export var shove_power:= 800
@export var bump_power:= 50
var direction
signal bulletSignal(pos, speed)
enum FaceDirection {LEFT, RIGHT}
enum PlayerStates {IDLE, RUNNING, JUMPING, FALLING}
var facing: FaceDirection = FaceDirection.RIGHT
var current_player_state: PlayerStates = PlayerStates.IDLE
var upJump:bool = false
var pushRightEnabled = false
var pushLeftEnabled = false
var pushTarget:Crate
const SPEED = 300.0 const SPEED = 300.0
const JUMP_VELOCITY = -400.0 const JUMP_VELOCITY = -400.0
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
# Handle jump. handle_input()
handle_movement()
handle_states()
handle_animations()
move_and_slide()
handle_collisions()
func handle_input()-> void:
#Handle shoot
if Input.is_action_just_pressed("shoot"):
print ("player wants to shoot")
#send a bullet signal
if facing==FaceDirection.RIGHT:
bulletSignal.emit(right_spawn.global_transform, 800)
if facing==FaceDirection.LEFT:
bulletSignal.emit(left_spawn.global_transform, -800)
player_graphic.flip_h = true
# Handle shove.
if Input.is_action_just_pressed("shove"):
print("Player shove!")
if pushRightEnabled and facing==FaceDirection.RIGHT:
# shove it right
pushTarget.apply_central_impulse(Vector2(1,0) * shove_power)
if pushLeftEnabled and facing==FaceDirection.LEFT:
# shove it left
pushTarget.apply_central_impulse(Vector2(-1,0) * shove_power)
# 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
current_player_state=PlayerStates.JUMPING
upJump = true
# 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.
var direction := Input.get_axis("ui_left", "ui_right") direction = Input.get_axis("ui_left", "ui_right")
func handle_movement()-> void:
if direction: if direction:
velocity.x = direction * SPEED velocity.x = direction * SPEED
# set player direction
if direction < 0:
facing = FaceDirection.LEFT
player_graphic.flip_h = true
if direction > 0:
facing = FaceDirection.RIGHT
player_graphic.flip_h = false
else: else:
velocity.x = move_toward(velocity.x, 0, SPEED) velocity.x = move_toward(velocity.x, 0, SPEED)
move_and_slide() func handle_collisions()-> void:
# find all things my player collided with # find all things my player collided with
for i in get_slide_collision_count(): for i in get_slide_collision_count():
var c = get_slide_collision(i) var c = get_slide_collision(i)
if c.get_collider() is RigidBody2D: if c.get_collider() is RigidBody2D:
c.get_collider().apply_central_impulse(-c.get_normal() * 200) c.get_collider().apply_central_impulse(-c.get_normal() * bump_power)
if right_cast.is_colliding():
print("Something on my right")
# get the thing i can shove
var collider = right_cast.get_collider()
if collider is Node:
pushRightEnabled = true
pushTarget = collider
else:
pushRightEnabled = false
if left_cast.is_colliding():
print("Something on my left")
# get the thing i can shove
var collider = left_cast.get_collider()
if collider is Node:
pushLeftEnabled = true
pushTarget = collider
else:
pushLeftEnabled = false
func handle_states()-> void:
match current_player_state:
PlayerStates.IDLE when velocity.x !=0:
current_player_state = PlayerStates.RUNNING
PlayerStates.RUNNING when velocity.x==0:
current_player_state = PlayerStates.IDLE
PlayerStates.JUMPING when velocity.y>0:
#you falling
current_player_state = PlayerStates.FALLING
PlayerStates.FALLING when is_on_floor():
if velocity.x ==0:
current_player_state = PlayerStates.IDLE
else:
current_player_state = PlayerStates.RUNNING
func handle_animations()-> void:
match current_player_state:
PlayerStates.RUNNING:
player_graphic.play("run")
PlayerStates.IDLE:
player_graphic.play("idle")
PlayerStates.JUMPING:
if upJump:
player_graphic.play("jump")
PlayerStates.FALLING:
player_graphic.play("fall")
func _on_animation_finished() -> void:
match current_player_state:
PlayerStates.JUMPING:
upJump = false
+78
View File
@@ -0,0 +1,78 @@
class_name SceneManager extends Node2D
@onready var triggers: Node2D = $"../Triggers"
@onready var game: GameController = $".."
#@onready var bullet: Bullet = $"../Bullet"
@onready var player: Player = $"../Player"
var bullet = preload("res://scenes/bullet.tscn")
var totalAllowedBullets:int = 7
#collection
var bulletArray:Array[Bullet] = []
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
buildLevel()
game.teleportSignal.connect(teleport)
game.destroySignal.connect(destroy)
player.bulletSignal.connect(makeBullet)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func buildLevel() -> void:
if triggers:
for obj in triggers.get_children():
if obj is Trigger:
if not obj.areaTriggered.is_connected(game._on_trigger):
obj.areaTriggered.connect(game._on_trigger)
func teleport(body, _bodyposition = null) -> void:
if body is Crate:
var viewport_size = get_viewport().get_visible_rect().size
var random_x = randf_range(0, viewport_size.x)
var random_y = randf_range(0, viewport_size.y)
var newPosition = Vector2(random_x, random_y)
body.teleport_to(newPosition)
#order desk (for bullets)
func makeBullet(pos, speed)-> void:
#ask for a bullet from....the factory
print("make a bullet")
var myBullet:Bullet = bulletFactory()
myBullet.transform = pos
myBullet.setSpeed(speed)
myBullet.set_process(true)
func bulletFactory()-> Bullet:
var myBullet:Bullet
#how many bullets have been created?
if bulletArray.size() <= totalAllowedBullets:
myBullet = bullet.instantiate()
add_sibling(myBullet)
#have to wire up signal after
if not myBullet.bulletDamageSignal.is_connected(game._on_bullet_hit):
myBullet.bulletDamageSignal.connect(game._on_bullet_hit)
else:
#recycle bullet
print("recycling!")
myBullet = bulletArray.pop_back()
#put the bullet in my collection
bulletArray.push_front(myBullet)
return myBullet
func destroy(target)-> void:
if target is Bullet:
stash(target)
if target is Crate:
target.queue_free()
func stash(target:Bullet)-> void:
print("stash a bullet")
#hide the bullet off-screen
var stashPosition:Vector2 = Vector2(10,10)
target.position = stashPosition
target.setSpeed(0)
target.set_process(false)
+1
View File
@@ -0,0 +1 @@
uid://dv2q4p6jb8h4s
+2 -2
View File
@@ -1,6 +1,6 @@
extends Area2D class_name Trigger extends Area2D
var effect="destroy" @export var effect:String = "destroy"
signal areaTriggered(effect, Object) signal areaTriggered(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: