diff --git a/Assets/Graphics/Objects/crate.png b/Assets/Graphics/Objects/crate.png new file mode 100644 index 0000000..2b8bdcd Binary files /dev/null and b/Assets/Graphics/Objects/crate.png differ diff --git a/Assets/Graphics/Objects/crate.png.import b/Assets/Graphics/Objects/crate.png.import new file mode 100644 index 0000000..1e25fe4 --- /dev/null +++ b/Assets/Graphics/Objects/crate.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://m685ffchmchr" +path="res://.godot/imported/crate.png-28b7c466b4f961841d793cd5b48f75b2.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Graphics/Objects/crate.png" +dest_files=["res://.godot/imported/crate.png-28b7c466b4f961841d793cd5b48f75b2.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/Assets/Graphics/Player/Idle/Player Idle 48x48.png b/Assets/Graphics/Player/Idle/Player Idle 48x48.png new file mode 100644 index 0000000..b618511 Binary files /dev/null and b/Assets/Graphics/Player/Idle/Player Idle 48x48.png differ diff --git a/Assets/Graphics/Player/Idle/Player Idle 48x48.png.import b/Assets/Graphics/Player/Idle/Player Idle 48x48.png.import new file mode 100644 index 0000000..caa3575 --- /dev/null +++ b/Assets/Graphics/Player/Idle/Player Idle 48x48.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dl452cit6hmxl" +path="res://.godot/imported/Player Idle 48x48.png-43d8fdefecc09abb7b8a43ca7514cca3.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-43d8fdefecc09abb7b8a43ca7514cca3.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/Assets/Graphics/Player/Jump/player jump 48x48.png b/Assets/Graphics/Player/Jump/player jump 48x48.png new file mode 100644 index 0000000..dff105c Binary files /dev/null and b/Assets/Graphics/Player/Jump/player jump 48x48.png differ diff --git a/Assets/Graphics/Player/Jump/player jump 48x48.png.import b/Assets/Graphics/Player/Jump/player jump 48x48.png.import new file mode 100644 index 0000000..a979021 --- /dev/null +++ b/Assets/Graphics/Player/Jump/player jump 48x48.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dpv7hte6i8kui" +path="res://.godot/imported/player jump 48x48.png-197ede03251a4cd7c1d571acd2dc6d80.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-197ede03251a4cd7c1d571acd2dc6d80.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/Assets/Graphics/Player/Run/player run 48x48.png b/Assets/Graphics/Player/Run/player run 48x48.png new file mode 100644 index 0000000..aca5b55 Binary files /dev/null and b/Assets/Graphics/Player/Run/player run 48x48.png differ diff --git a/Assets/Graphics/Player/Run/player run 48x48.png.import b/Assets/Graphics/Player/Run/player run 48x48.png.import new file mode 100644 index 0000000..b551e64 --- /dev/null +++ b/Assets/Graphics/Player/Run/player run 48x48.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bmrxpbm2roq7s" +path="res://.godot/imported/player run 48x48.png-3c23f749058e47947519f4e375cf2db5.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-3c23f749058e47947519f4e375cf2db5.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/Assets/Graphics/Projectiles/pixel_bullet.png b/Assets/Graphics/Projectiles/pixel_bullet.png new file mode 100644 index 0000000..900d030 Binary files /dev/null and b/Assets/Graphics/Projectiles/pixel_bullet.png differ diff --git a/Assets/Graphics/Projectiles/pixel_bullet.png.import b/Assets/Graphics/Projectiles/pixel_bullet.png.import new file mode 100644 index 0000000..659e542 --- /dev/null +++ b/Assets/Graphics/Projectiles/pixel_bullet.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://s8lg7ju2rbga" +path="res://.godot/imported/pixel_bullet.png-6d6351b49166e9c444cfcd1accda4c0c.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Graphics/Projectiles/pixel_bullet.png" +dest_files=["res://.godot/imported/pixel_bullet.png-6d6351b49166e9c444cfcd1accda4c0c.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/Assets/Graphics/Terrains/Terrain (32x32).png b/Assets/Graphics/Terrains/Terrain (32x32).png new file mode 100644 index 0000000..ddf1eaf Binary files /dev/null and b/Assets/Graphics/Terrains/Terrain (32x32).png differ diff --git a/Assets/Graphics/Terrains/Terrain (32x32).png.import b/Assets/Graphics/Terrains/Terrain (32x32).png.import new file mode 100644 index 0000000..8a66f10 --- /dev/null +++ b/Assets/Graphics/Terrains/Terrain (32x32).png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://mfcyrgamj3cc" +path="res://.godot/imported/Terrain (32x32).png-794d2373a3e16792b67c3e955035bc36.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/Graphics/Terrains/Terrain (32x32).png" +dest_files=["res://.godot/imported/Terrain (32x32).png-794d2373a3e16792b67c3e955035bc36.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/Scenes/Player.tscn b/Scenes/Player.tscn index a220c81..40937bd 100644 --- a/Scenes/Player.tscn +++ b/Scenes/Player.tscn @@ -1,9 +1,182 @@ -[gd_scene load_steps=3 format=3 uid="uid://bu8e4iyw8pc03"] +[gd_scene load_steps=28 format=3 uid="uid://bu8e4iyw8pc03"] [ext_resource type="Script" uid="uid://dsryf6gxqcm1k" path="res://Scripts/character_body_2d.gd" id="1_0y7nr"] +[ext_resource type="Texture2D" uid="uid://dpv7hte6i8kui" path="res://Assets/Graphics/Player/Jump/player jump 48x48.png" id="2_dewec"] +[ext_resource type="Texture2D" uid="uid://dl452cit6hmxl" path="res://Assets/Graphics/Player/Idle/Player Idle 48x48.png" id="2_kyqiw"] +[ext_resource type="Texture2D" uid="uid://bmrxpbm2roq7s" path="res://Assets/Graphics/Player/Run/player run 48x48.png" id="3_gntrk"] [sub_resource type="CircleShape2D" id="CircleShape2D_2poj3"] +[sub_resource type="AtlasTexture" id="AtlasTexture_5v66d"] +atlas = ExtResource("2_dewec") +region = Rect2(96, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_gntrk"] +atlas = ExtResource("2_kyqiw") +region = Rect2(0, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_dewec"] +atlas = ExtResource("2_kyqiw") +region = Rect2(48, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_5ixxa"] +atlas = ExtResource("2_kyqiw") +region = Rect2(96, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_nn08x"] +atlas = ExtResource("2_kyqiw") +region = Rect2(144, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_52ee3"] +atlas = ExtResource("2_kyqiw") +region = Rect2(192, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_bhhdu"] +atlas = ExtResource("2_kyqiw") +region = Rect2(240, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_megsn"] +atlas = ExtResource("2_kyqiw") +region = Rect2(288, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_yoq75"] +atlas = ExtResource("2_kyqiw") +region = Rect2(336, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ksbbd"] +atlas = ExtResource("2_kyqiw") +region = Rect2(384, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_glx4g"] +atlas = ExtResource("2_kyqiw") +region = Rect2(432, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_x63xi"] +atlas = ExtResource("2_dewec") +region = Rect2(0, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_i2e8t"] +atlas = ExtResource("2_dewec") +region = Rect2(48, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_miouo"] +atlas = ExtResource("3_gntrk") +region = Rect2(0, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_o3h8g"] +atlas = ExtResource("3_gntrk") +region = Rect2(48, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_1e7my"] +atlas = ExtResource("3_gntrk") +region = Rect2(96, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_arntx"] +atlas = ExtResource("3_gntrk") +region = Rect2(144, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_lslt6"] +atlas = ExtResource("3_gntrk") +region = Rect2(192, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ulo2v"] +atlas = ExtResource("3_gntrk") +region = Rect2(240, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_1iu4k"] +atlas = ExtResource("3_gntrk") +region = Rect2(288, 0, 48, 48) + +[sub_resource type="AtlasTexture" id="AtlasTexture_m0x7a"] +atlas = ExtResource("3_gntrk") +region = Rect2(336, 0, 48, 48) + +[sub_resource type="SpriteFrames" id="SpriteFrames_miouo"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_5v66d") +}], +"loop": true, +"name": &"falling", +"speed": 5.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_gntrk") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_dewec") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_5ixxa") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_nn08x") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_52ee3") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_bhhdu") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_megsn") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_yoq75") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ksbbd") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_glx4g") +}], +"loop": true, +"name": &"idle", +"speed": 12.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_x63xi") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_i2e8t") +}], +"loop": false, +"name": &"jump", +"speed": 12.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_miouo") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_o3h8g") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_1e7my") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_arntx") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_lslt6") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ulo2v") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_1iu4k") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_m0x7a") +}], +"loop": true, +"name": &"run", +"speed": 12.0 +}] + [node name="CharacterBody2D" type="CharacterBody2D"] script = ExtResource("1_0y7nr") metadata/_edit_group_ = true @@ -23,3 +196,12 @@ position = Vector2(17, -8) [node name="LeftSpawn" type="Node2D" parent="."] position = Vector2(-14, -9) + +[node name="PlayerGraphic" type="AnimatedSprite2D" parent="."] +texture_filter = 1 +position = Vector2(0, -6) +sprite_frames = SubResource("SpriteFrames_miouo") +animation = &"falling" +autoplay = "idle" + +[connection signal="animation_finished" from="PlayerGraphic" to="." method="_on_animation_finished"] diff --git a/Scenes/bullet.tscn b/Scenes/bullet.tscn index afdd82d..d42aa57 100644 --- a/Scenes/bullet.tscn +++ b/Scenes/bullet.tscn @@ -1,14 +1,23 @@ -[gd_scene load_steps=3 format=3 uid="uid://cm8o5vpn4a00"] +[gd_scene load_steps=4 format=3 uid="uid://cm8o5vpn4a00"] -[ext_resource type="Script" uid="uid://q1ok5ukbtibm" path="res://bullet.gd" id="1_xjght"] +[ext_resource type="Script" uid="uid://q1ok5ukbtibm" path="res://Scripts/bullet.gd" id="1_xjght"] +[ext_resource type="Texture2D" uid="uid://s8lg7ju2rbga" path="res://Assets/Graphics/Projectiles/pixel_bullet.png" id="2_oduel"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_oduel"] -size = Vector2(14, 4) +size = Vector2(13, 4) [node name="Bullet" type="Area2D"] script = ExtResource("1_xjght") metadata/_edit_group_ = true +[node name="Sprite2D" type="Sprite2D" parent="."] +position = Vector2(-3, -2) +rotation = -3.14159 +scale = Vector2(0.0896342, 0.0851218) +texture = ExtResource("2_oduel") + [node name="CollisionShape2D" type="CollisionShape2D" parent="."] +texture_filter = 1 +position = Vector2(0.5, 0) shape = SubResource("RectangleShape2D_oduel") debug_color = Color(0.995859, 0, 0.197667, 0.42) diff --git a/Scenes/crate.tscn b/Scenes/crate.tscn index a4c42dd..cbf7f9e 100644 --- a/Scenes/crate.tscn +++ b/Scenes/crate.tscn @@ -1,11 +1,17 @@ -[gd_scene load_steps=2 format=3 uid="uid://cd7fv3pwgr880"] +[gd_scene load_steps=3 format=3 uid="uid://cd7fv3pwgr880"] + +[ext_resource type="Texture2D" uid="uid://m685ffchmchr" path="res://Assets/Graphics/Objects/crate.png" id="1_wp72f"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_ebmjs"] [node name="RigidBody2D3" type="RigidBody2D"] -rotation = -0.544116 metadata/_edit_group_ = true +[node name="Sprite2D" type="Sprite2D" parent="."] +position = Vector2(0, 1) +scale = Vector2(0.0754011, 0.0688039) +texture = ExtResource("1_wp72f") + [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource("RectangleShape2D_ebmjs") debug_color = Color(0.796822, 0.420181, 0.140254, 0.42) diff --git a/Scenes/game.tscn b/Scenes/game.tscn index 6dd9251..b3eaa0e 100644 --- a/Scenes/game.tscn +++ b/Scenes/game.tscn @@ -1,29 +1,90 @@ -[gd_scene load_steps=8 format=3 uid="uid://c6mxse0hqjro7"] +[gd_scene load_steps=12 format=4 uid="uid://c6mxse0hqjro7"] [ext_resource type="Script" uid="uid://tno7aku0yyke" path="res://Scripts/gamecontroller.gd" id="1_wrm1d"] +[ext_resource type="Texture2D" uid="uid://mfcyrgamj3cc" path="res://Assets/Graphics/Terrains/Terrain (32x32).png" id="2_1l0tm"] [ext_resource type="Script" uid="uid://bs4frobn6kxne" path="res://Scripts/scene_manager.gd" id="2_i6g32"] [ext_resource type="PackedScene" uid="uid://cd7fv3pwgr880" path="res://Scenes/crate.tscn" id="3_3dryh"] [ext_resource type="PackedScene" uid="uid://bu8e4iyw8pc03" path="res://Scenes/Player.tscn" id="4_3dryh"] [ext_resource type="PackedScene" uid="uid://b5d8himq5sttt" path="res://Scenes/trigger.tscn" id="4_wowpa"] [ext_resource type="PackedScene" uid="uid://cm8o5vpn4a00" path="res://Scenes/bullet.tscn" id="5_wowpa"] +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_v158k"] +texture = ExtResource("2_1l0tm") +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_h4fw4"] +tile_size = Vector2i(32, 32) +sources/0 = SubResource("TileSetAtlasSource_v158k") + [sub_resource type="RectangleShape2D" id="RectangleShape2D_2poj3"] size = Vector2(50, 20) +[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_1l0tm"] + [node name="Game" type="Node2D"] script = ExtResource("1_wrm1d") +[node name="TileMapLayer" type="TileMapLayer" parent="."] +tile_map_data = PackedByteArray("AAASAAoAAAAEAAQAAAATAAoAAAAEAAQAAAAUAAoAAAAEAAQAAAAVAAoAAAAEAAQAAAARAAoAAAAEAAQAAAAQAAoAAAAEAAQAAAAPAAoAAAAEAAQAAAA=") +tile_set = SubResource("TileSet_h4fw4") + [node name="SceneManager" type="Node2D" parent="."] unique_name_in_owner = true script = ExtResource("2_i6g32") [node name="StaticBody2D" type="StaticBody2D" parent="."] -position = Vector2(595, 337) -scale = Vector2(4.146, 0.985995) +position = Vector2(592, 337) +scale = Vector2(4.45399, 1.56585) metadata/_edit_group_ = true [node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"] -scale = Vector2(1, 1) shape = SubResource("RectangleShape2D_2poj3") [node name="RigidBody2D3" parent="." instance=ExtResource("3_3dryh")] @@ -35,18 +96,27 @@ position = Vector2(616, 222) [node name="RigidBody2D5" parent="." instance=ExtResource("3_3dryh")] position = Vector2(574, 222) -[node name="Area2D2" parent="." instance=ExtResource("4_wowpa")] -position = Vector2(507, 414) -effect = "destroy" - -[node name="Area2D3" parent="." instance=ExtResource("4_wowpa")] -position = Vector2(679, 430) - [node name="CharacterBody2D" parent="." instance=ExtResource("4_3dryh")] -position = Vector2(614, 314) +position = Vector2(613, 309) [node name="Bullet" parent="." instance=ExtResource("5_wowpa")] position = Vector2(520, 265) -[connection signal="areatrigger" from="Area2D2" to="." method="_on_areatrigger"] -[connection signal="areatrigger" from="Area2D3" to="." method="_on_areatrigger"] +[node name="Triggers" type="Node2D" parent="."] + +[node name="Area2D2" parent="Triggers" instance=ExtResource("4_wowpa")] +position = Vector2(507, 414) +effect = "destroy" + +[node name="Area2D3" parent="Triggers" instance=ExtResource("4_wowpa")] +position = Vector2(679, 430) + +[node name="StaticBody2D2" type="StaticBody2D" parent="."] +position = Vector2(589, 544) +metadata/_edit_group_ = true + +[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D2"] +shape = SubResource("WorldBoundaryShape2D_1l0tm") + +[connection signal="areatrigger" from="Triggers/Area2D2" to="." method="_on_areatrigger"] +[connection signal="areatrigger" from="Triggers/Area2D3" to="." method="_on_areatrigger"] diff --git a/bullet.gd b/Scripts/bullet.gd similarity index 100% rename from bullet.gd rename to Scripts/bullet.gd diff --git a/bullet.gd.uid b/Scripts/bullet.gd.uid similarity index 100% rename from bullet.gd.uid rename to Scripts/bullet.gd.uid diff --git a/Scripts/character_body_2d.gd b/Scripts/character_body_2d.gd index 90fa538..e000e5d 100644 --- a/Scripts/character_body_2d.gd +++ b/Scripts/character_body_2d.gd @@ -8,22 +8,83 @@ const JUMP_VELOCITY = -400.0 @onready var left_cast: RayCast2D = $LeftCast @onready var right_spawn: Node2D = $RightSpawn @onready var left_spawn: Node2D = $LeftSpawn +@onready var player_graphic: AnimatedSprite2D = $PlayerGraphic enum FaceDirection{LEFT, RIGHT} var facing:FaceDirection = FaceDirection.RIGHT +enum State{IDLE, RUN, JUMP, FALLING} +var current_state:State = State.IDLE + var pushTarget var pushEnabled = false +var direction +var upJump = false func _physics_process(delta: float) -> void: + #game loop + handle_input() + #calculate the movement + handle_movement(delta) + #change states + update_states() + #play animations + update_animation() + #collision with objects, raycasts + + + move_and_slide() + handle_collisions() + +func update_states(): + match current_state: + #idle when movement in x + State.IDLE when velocity.x !=0: + current_state = State.RUN + State.RUN: + if velocity.x ==0: + current_state = State.IDLE + #jumping when reaching apex + State.JUMP when velocity.y > 0: + current_state = State.FALLING + State.FALLING when is_on_floor(): + if velocity.x == 0: + current_state = State.IDLE + else: + current_state = State.RUN + +func update_animation(): + match current_state: + State.IDLE: + player_graphic.play("idle") + State.RUN: + player_graphic.play("run") + State.JUMP: + if upJump: + player_graphic.play("jump") + State.FALLING: + player_graphic.play("falling") +func handle_movement(delta): # Add the gravity. if not is_on_floor(): velocity += get_gravity() * delta - - # Handle jump. + + if direction: + velocity.x = direction * SPEED + if direction <0: + facing = FaceDirection.LEFT + player_graphic.flip_h = true + if direction >0: + facing = FaceDirection.RIGHT + player_graphic.flip_h = false + else: + velocity.x = move_toward(velocity.x, 0, SPEED) +func handle_input(): if Input.is_action_just_pressed("ui_accept") and is_on_floor(): velocity.y = JUMP_VELOCITY + current_state = State.JUMP + upJump = true if Input.is_action_just_pressed("shove") && pushEnabled: print("shove pressed") @@ -43,17 +104,8 @@ func _physics_process(delta: float) -> void: # Get the input direction and handle the movement/deceleration. # As good practice, you should replace UI actions with custom gameplay actions. - var direction := Input.get_axis("ui_left", "ui_right") - if direction: - velocity.x = direction * SPEED - if direction <0: - facing = FaceDirection.LEFT - if direction >0: - facing = FaceDirection.RIGHT - else: - velocity.x = move_toward(velocity.x, 0, SPEED) - - move_and_slide() + direction = Input.get_axis("ui_left", "ui_right") +func handle_collisions(): for i in get_slide_collision_count(): var c = get_slide_collision(i) if c.get_collider() is RigidBody2D: @@ -76,5 +128,9 @@ func _physics_process(delta: float) -> void: pushEnabled = true if not left_cast.is_colliding() && not right_cast.is_colliding(): pushEnabled = false - - + + +func _on_animation_finished() -> void: + match current_state: + State.JUMP: + upJump = false diff --git a/Scripts/scene_manager.gd b/Scripts/scene_manager.gd index f0d7ba2..938cb17 100644 --- a/Scripts/scene_manager.gd +++ b/Scripts/scene_manager.gd @@ -3,6 +3,12 @@ extends Node2D var bullet = preload("res://Scenes/bullet.tscn") var bulletArray =[] var totalAllowedBullets = 7 +@onready var triggers: Node2D = $"../Triggers" +@onready var gameController: Node2D = $".." + +func _ready() -> void: + for obj in triggers.get_children(): + obj.areatrigger.connect(gameController._on_areatrigger) #makes bullets func bulletFactory(): diff --git a/project.godot b/project.godot index 12c02d6..6c5b59e 100644 --- a/project.godot +++ b/project.godot @@ -18,6 +18,7 @@ config/icon="res://icon.svg" [file_customization] folder_colors={ +"res://Assets/": "teal", "res://Scenes/": "pink", "res://Scripts/": "orange" }