tilemaps sprite sheets animated sprites

This commit is contained in:
OddlyTimbot 2024-12-02 20:49:31 -05:00
parent 7ee32c14d2
commit bdd6b790cf
19 changed files with 518 additions and 26 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://cihsatv28adsv"
path="res://.godot/imported/crate.png-a8589d0a814f9d7cb0facb9c1c1d5fda.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/graphics/crate.png"
dest_files=["res://.godot/imported/crate.png-a8589d0a814f9d7cb0facb9c1c1d5fda.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: 12 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bvbxh8nxgekny"
path="res://.godot/imported/Terrain (32x32).png-81a713b69add642b2640197ae95d1555.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/graphics/environment/terrain/Terrain (32x32).png"
dest_files=["res://.godot/imported/Terrain (32x32).png-81a713b69add642b2640197ae95d1555.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://cjuaglcx1l8mq"
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://b82ecqnclroum"
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ye4pj0vptmk5"
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,9 +15,18 @@ 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={
"res://assets/": "yellow",
"res://scripts/": "green" "res://scripts/": "green"
} }

View File

@ -1,13 +1,19 @@
[gd_scene load_steps=2 format=3 uid="uid://dm71h7adhhf8u"] [gd_scene load_steps=3 format=3 uid="uid://dm71h7adhhf8u"]
[ext_resource type="Texture2D" uid="uid://cihsatv28adsv" path="res://assets/graphics/crate.png" id="1_itkgh"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_dbirr"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_dbirr"]
size = Vector2(30, 32) size = Vector2(16, 17)
[node name="RigidBody2D" type="RigidBody2D" groups=["box", "shootable"]] [node name="RigidBody2D" type="RigidBody2D" groups=["box", "shootable"]]
position = Vector2(531, 339)
rotation = 2.64233
metadata/_edit_group_ = true metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, -0.5)
shape = SubResource("RectangleShape2D_dbirr") shape = SubResource("RectangleShape2D_dbirr")
debug_color = Color(0.747094, 0.350436, 0.149052, 0.42) debug_color = Color(0.747094, 0.350436, 0.149052, 0.42)
[node name="Sprite2D" type="Sprite2D" parent="."]
texture_filter = 1
scale = Vector2(0.06, 0.06)
texture = ExtResource("1_itkgh")

View File

@ -1,16 +1,24 @@
[gd_scene load_steps=3 format=3 uid="uid://02fr3rb7e6s2"] [gd_scene load_steps=4 format=3 uid="uid://02fr3rb7e6s2"]
[ext_resource type="Script" path="res://scripts/bullet.gd" id="1_kc7iu"] [ext_resource type="Script" path="res://scripts/bullet.gd" id="1_kc7iu"]
[ext_resource type="Texture2D" uid="uid://ye4pj0vptmk5" path="res://assets/graphics/projectiles/pixel_bullet.png" id="2_xdfmr"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_m2rb6"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_m2rb6"]
size = Vector2(11, 7) size = Vector2(11, 5)
[node name="Area2D" type="Area2D"] [node name="Area2D" type="Area2D"]
script = ExtResource("1_kc7iu") script = ExtResource("1_kc7iu")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0.5, -0.5) position = Vector2(0, 0.5)
shape = SubResource("RectangleShape2D_m2rb6") shape = SubResource("RectangleShape2D_m2rb6")
debug_color = Color(0.366555, 0.610522, 0.244131, 0.42) debug_color = Color(0.366555, 0.610522, 0.244131, 0.42)
[node name="Sprite2D" type="Sprite2D" parent="."]
texture_filter = 1
position = Vector2(-3, -2)
rotation = -3.14159
scale = Vector2(0.1, 0.1)
texture = ExtResource("2_xdfmr")
[connection signal="body_entered" from="." to="." method="_on_body_entered"] [connection signal="body_entered" from="." to="." method="_on_body_entered"]

View File

@ -1,26 +1,205 @@
[gd_scene load_steps=3 format=3 uid="uid://cjqhmd3158nb7"] [gd_scene load_steps=28 format=3 uid="uid://cjqhmd3158nb7"]
[ext_resource type="Script" path="res://scripts/dudecontroller.gd" id="1_u27sl"] [ext_resource type="Script" path="res://scripts/dudecontroller.gd" id="1_u27sl"]
[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://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"] [sub_resource type="CircleShape2D" id="CircleShape2D_pg3nc"]
radius = 18.1108 radius = 18.1108
[sub_resource type="AtlasTexture" id="AtlasTexture_mirx3"]
atlas = ExtResource("2_s31uh")
region = Rect2(0, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_ur0m7"]
atlas = ExtResource("2_s31uh")
region = Rect2(48, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_m2fh1"]
atlas = ExtResource("2_s31uh")
region = Rect2(96, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_lqxd8"]
atlas = ExtResource("2_s31uh")
region = Rect2(144, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_q1uhj"]
atlas = ExtResource("2_s31uh")
region = Rect2(192, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_3nxhs"]
atlas = ExtResource("2_s31uh")
region = Rect2(240, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_uly7f"]
atlas = ExtResource("2_s31uh")
region = Rect2(288, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_a0rgn"]
atlas = ExtResource("2_s31uh")
region = Rect2(336, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_vl0t4"]
atlas = ExtResource("2_s31uh")
region = Rect2(384, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_ywq8a"]
atlas = ExtResource("2_s31uh")
region = Rect2(432, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_qbdur"]
atlas = ExtResource("3_5pc3d")
region = Rect2(0, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_e0phq"]
atlas = ExtResource("3_5pc3d")
region = Rect2(48, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_aagb2"]
atlas = ExtResource("3_5pc3d")
region = Rect2(96, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_waibj"]
atlas = ExtResource("3_pvg6g")
region = Rect2(0, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_royxn"]
atlas = ExtResource("3_pvg6g")
region = Rect2(48, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_58lgm"]
atlas = ExtResource("3_pvg6g")
region = Rect2(96, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_sh18f"]
atlas = ExtResource("3_pvg6g")
region = Rect2(144, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_1wubr"]
atlas = ExtResource("3_pvg6g")
region = Rect2(192, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_v0216"]
atlas = ExtResource("3_pvg6g")
region = Rect2(240, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_ddbn2"]
atlas = ExtResource("3_pvg6g")
region = Rect2(288, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_txi2q"]
atlas = ExtResource("3_pvg6g")
region = Rect2(336, 0, 48, 48)
[sub_resource type="SpriteFrames" id="SpriteFrames_p5ykk"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_mirx3")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ur0m7")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_m2fh1")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_lqxd8")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_q1uhj")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_3nxhs")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_uly7f")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_a0rgn")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_vl0t4")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ywq8a")
}],
"loop": true,
"name": &"idle",
"speed": 12.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_qbdur")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_e0phq")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_aagb2")
}],
"loop": false,
"name": &"jump",
"speed": 8.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_waibj")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_royxn")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_58lgm")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_sh18f")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_1wubr")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_v0216")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ddbn2")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_txi2q")
}],
"loop": true,
"name": &"run",
"speed": 12.0
}]
[node name="CharacterBody2D" type="CharacterBody2D" groups=["player"]] [node name="CharacterBody2D" type="CharacterBody2D" groups=["player"]]
script = ExtResource("1_u27sl") script = ExtResource("1_u27sl")
metadata/_edit_group_ = true metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, 2)
scale = Vector2(0.8, 0.8)
shape = SubResource("CircleShape2D_pg3nc") shape = SubResource("CircleShape2D_pg3nc")
debug_color = Color(0.178776, 0.565003, 0.825276, 0.42) debug_color = Color(0.178776, 0.565003, 0.825276, 0.42)
[node name="RightRay" type="RayCast2D" parent="."] [node name="RightRay" type="RayCast2D" parent="."]
target_position = Vector2(28, 0) target_position = Vector2(17, 0)
[node name="LeftRay" type="RayCast2D" parent="."] [node name="LeftRay" type="RayCast2D" parent="."]
target_position = Vector2(-29, -1) target_position = Vector2(-19, 0)
[node name="RightTarget" type="Node2D" parent="."] [node name="RightTarget" type="Node2D" parent="."]
position = Vector2(23, -11) position = Vector2(18, -5)
[node name="LeftTarget" type="Node2D" parent="."] [node name="LeftTarget" type="Node2D" parent="."]
position = Vector2(-24, -10) position = Vector2(-18, -5)
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
texture_filter = 1
sprite_frames = SubResource("SpriteFrames_p5ykk")
animation = &"idle"
autoplay = "run"
[node name="Camera2D" type="Camera2D" parent="."]
position = Vector2(-1, 0)

View File

@ -1,10 +1,65 @@
[gd_scene load_steps=9 format=3 uid="uid://cmh68gsfunmwa"] [gd_scene load_steps=11 format=4 uid="uid://cmh68gsfunmwa"]
[ext_resource type="Texture2D" uid="uid://bvbxh8nxgekny" path="res://assets/graphics/environment/terrain/Terrain (32x32).png" id="1_n0y6d"]
[ext_resource type="Script" path="res://scripts/scene_manager.gd" id="1_obwxw"] [ext_resource type="Script" path="res://scripts/scene_manager.gd" id="1_obwxw"]
[ext_resource type="PackedScene" uid="uid://cjqhmd3158nb7" path="res://scenes/character.tscn" id="1_p32ky"] [ext_resource type="PackedScene" uid="uid://cjqhmd3158nb7" path="res://scenes/character.tscn" id="1_p32ky"]
[ext_resource type="Script" path="res://scripts/trigger.gd" id="2_tsnf5"] [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://dm71h7adhhf8u" path="res://scenes/box.tscn" id="3_pi0u1"]
[ext_resource type="PackedScene" uid="uid://02fr3rb7e6s2" path="res://scenes/bullet.tscn" id="4_7pxts"]
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_ih8kf"]
texture = ExtResource("1_n0y6d")
texture_region_size = Vector2i(32, 32)
0:0/0 = 0
1:0/0 = 0
2:0/0 = 0
4:0/0 = 0
6:0/0 = 0
7:0/0 = 0
9:0/0 = 0
10:0/0 = 0
12:0/0 = 0
13:0/0 = 0
15:0/0 = 0
0:1/0 = 0
1:1/0 = 0
2:1/0 = 0
4:1/0 = 0
6:1/0 = 0
7:1/0 = 0
9:1/0 = 0
10:1/0 = 0
12:1/0 = 0
13:1/0 = 0
15:1/0 = 0
16:1/0 = 0
0:2/0 = 0
1:2/0 = 0
2:2/0 = 0
4:2/0 = 0
6:3/0 = 0
7:3/0 = 0
9:3/0 = 0
10:3/0 = 0
12:3/0 = 0
13:3/0 = 0
15:3/0 = 0
16:3/0 = 0
0:4/0 = 0
1:4/0 = 0
2:4/0 = 0
4:4/0 = 0
6:4/0 = 0
7:4/0 = 0
9:4/0 = 0
10:4/0 = 0
12:4/0 = 0
13:4/0 = 0
15:4/0 = 0
16:4/0 = 0
[sub_resource type="TileSet" id="TileSet_wyq3g"]
tile_size = Vector2i(32, 32)
sources/0 = SubResource("TileSetAtlasSource_ih8kf")
[sub_resource type="RectangleShape2D" id="RectangleShape2D_rcjag"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_rcjag"]
size = Vector2(84, 12) size = Vector2(84, 12)
@ -15,32 +70,40 @@ size = Vector2(84, 12)
[node name="Game" type="Node2D"] [node name="Game" type="Node2D"]
[node name="TileMapLayer" type="TileMapLayer" parent="."]
tile_map_data = PackedByteArray("AAAOAAwAAAAAAAAAAAAPAAwAAAABAAAAAAAQAAwAAAABAAAAAAARAAwAAAACAAAAAAAKABEAAAABAAAAAAALABEAAAABAAAAAAAMABEAAAABAAAAAAANABEAAAABAAAAAAAOABEAAAABAAAAAAAPABEAAAABAAAAAAAQABEAAAABAAAAAAARABEAAAABAAAAAAASABEAAAABAAAAAAATABEAAAABAAAAAAAUABEAAAABAAAAAAAVABEAAAABAAAAAAAWABEAAAABAAAAAAAXABEAAAABAAAAAAAYABEAAAABAAAAAAAZABEAAAABAAAAAAAJABEAAAABAAAAAAAIABEAAAABAAAAAAAHABEAAAABAAAAAAAGABEAAAABAAAAAAAUAAoAAAAEAAQAAAAWAAgAAAAAAAAAAAAXAAgAAAABAAAAAAAYAAgAAAABAAAAAAAZAAgAAAABAAAAAAAaAAgAAAACAAAAAAAWAAkAAAAAAAIAAAAXAAkAAAABAAIAAAAYAAkAAAABAAIAAAAZAAkAAAABAAIAAAAaAAkAAAACAAIAAAA=")
tile_set = SubResource("TileSet_wyq3g")
[node name="SceneManager" type="Node" parent="."] [node name="SceneManager" type="Node" parent="."]
unique_name_in_owner = true unique_name_in_owner = true
script = ExtResource("1_obwxw") script = ExtResource("1_obwxw")
[node name="Platform" type="StaticBody2D" parent="."] [node name="Platform" type="StaticBody2D" parent="."]
position = Vector2(523, 407) position = Vector2(511, 393)
scale = Vector2(1.46914, 1)
metadata/_edit_group_ = true metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Platform"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Platform"]
shape = SubResource("RectangleShape2D_rcjag") shape = SubResource("RectangleShape2D_rcjag")
[node name="Platform2" type="StaticBody2D" parent="."] [node name="Platform2" type="StaticBody2D" parent="."]
position = Vector2(658, 415) position = Vector2(656, 327)
scale = Vector2(0.4, 1)
metadata/_edit_group_ = true metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Platform2"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Platform2"]
shape = SubResource("RectangleShape2D_rcjag") shape = SubResource("RectangleShape2D_rcjag")
[node name="Platform3" type="StaticBody2D" parent="."] [node name="Platform3" type="StaticBody2D" parent="."]
position = Vector2(725, 328) position = Vector2(786, 263)
scale = Vector2(2, 1)
metadata/_edit_group_ = true metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Platform3"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Platform3"]
shape = SubResource("RectangleShape2D_rcjag") shape = SubResource("RectangleShape2D_rcjag")
[node name="CharacterBody2D" parent="." instance=ExtResource("1_p32ky")] [node name="CharacterBody2D" parent="." instance=ExtResource("1_p32ky")]
position = Vector2(502, 230)
[node name="Area2D" type="Area2D" parent="."] [node name="Area2D" type="Area2D" parent="."]
position = Vector2(519, 464) position = Vector2(519, 464)
@ -56,19 +119,17 @@ debug_color = Color(0.793021, 0.25626, 0.844091, 0.42)
position = Vector2(571, 331) position = Vector2(571, 331)
[node name="RigidBody2D2" parent="." instance=ExtResource("3_pi0u1")] [node name="RigidBody2D2" parent="." instance=ExtResource("3_pi0u1")]
position = Vector2(622, 275)
[node name="RigidBody2D3" parent="." instance=ExtResource("3_pi0u1")] [node name="RigidBody2D3" parent="." instance=ExtResource("3_pi0u1")]
position = Vector2(479, 288) position = Vector2(479, 288)
rotation = 1.16823 rotation = 1.16823
[node name="StaticBody2D" type="StaticBody2D" parent="."] [node name="StaticBody2D" type="StaticBody2D" parent="."]
position = Vector2(508, 565) position = Vector2(508, 546)
metadata/_edit_group_ = true metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"] [node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"]
shape = SubResource("WorldBoundaryShape2D_c5gsu") shape = SubResource("WorldBoundaryShape2D_c5gsu")
[node name="Area2D2" parent="." instance=ExtResource("4_7pxts")]
position = Vector2(244, 348)
[connection signal="body_entered" from="Area2D" to="Area2D" method="_on_body_entered"] [connection signal="body_entered" from="Area2D" to="Area2D" method="_on_body_entered"]

View File

@ -1,11 +1,16 @@
class_name Bullet extends Area2D class_name Bullet extends Area2D
@onready var bulletSprite: Sprite2D = $Sprite2D
var speed = 750 var speed = 700
# did I hit anyone? # did I hit anyone?
signal hit(bullet, body) signal hit(bullet, body)
func setSpeed(speedValue): func setSpeed(speedValue):
speed = speedValue speed = speedValue
if speed <0:
bulletSprite.flip_h = true
else:
bulletSprite.flip_h = false
func _physics_process(delta): func _physics_process(delta):
position += transform.x * speed * delta position += transform.x * speed * delta

View File

@ -2,18 +2,21 @@ extends CharacterBody2D
const SPEED = 300.0 const SPEED = 300.0
const JUMP_VELOCITY = -400.0 const JUMP_VELOCITY = -450.0
const BUMPFORCE = 50 const BUMPFORCE = 50
const PUSHFORCE = 750 const PUSHFORCE = 750
@onready var right_ray: RayCast2D = $RightRay @onready var right_ray: RayCast2D = $RightRay
@onready var left_ray: RayCast2D = $LeftRay @onready var left_ray: RayCast2D = $LeftRay
@onready var playerSprite: AnimatedSprite2D = $AnimatedSprite2D
var faceLeft = false var faceLeft = false
var pushTarget var pushTarget
var pushLeftEnabled = false var pushLeftEnabled = false
var pushRightEnabled = false var pushRightEnabled = false
var isJumping = false
@onready var right_target: Node2D = $RightTarget @onready var right_target: Node2D = $RightTarget
@onready var left_target: Node2D = $LeftTarget @onready var left_target: Node2D = $LeftTarget
@ -44,10 +47,10 @@ func _physics_process(delta: float) -> void:
var myBullet = %SceneManager.bulletFactory() var myBullet = %SceneManager.bulletFactory()
if not faceLeft: if not faceLeft:
myBullet.transform = right_target.global_transform myBullet.transform = right_target.global_transform
myBullet.setSpeed(750) myBullet.setSpeed(700)
if faceLeft ==true: if faceLeft ==true:
myBullet.transform = left_target.global_transform myBullet.transform = left_target.global_transform
myBullet.setSpeed(-750) myBullet.setSpeed(-700)
if direction: if direction:
velocity.x = direction * SPEED velocity.x = direction * SPEED
@ -55,9 +58,26 @@ func _physics_process(delta: float) -> void:
faceLeft = false faceLeft = false
if direction < 0: if direction < 0:
faceLeft = true faceLeft = true
else: else:#TODO: implement jump
pass
velocity.x = move_toward(velocity.x, 0, SPEED) 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() move_and_slide()
if right_ray.is_colliding(): if right_ray.is_colliding():
print("Something is on my right") print("Something is on my right")