diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..55cec2b --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "godotTools.editorPath.godot4": "/home/jonas/Dokumente/Godot/Godot.x86_64" +} \ No newline at end of file diff --git a/project.godot b/project.godot index f030969..10c1918 100644 --- a/project.godot +++ b/project.godot @@ -63,7 +63,8 @@ crawl={ } flower={ "deadzone": 0.5, -"events": [] +"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":69,"key_label":0,"unicode":101,"echo":false,"script":null) +] } [input_devices] diff --git a/scenes/blocks/enimie_barrier.tscn b/scenes/blocks/enimie_barrier.tscn new file mode 100644 index 0000000..b4b94ff --- /dev/null +++ b/scenes/blocks/enimie_barrier.tscn @@ -0,0 +1,11 @@ +[gd_scene load_steps=2 format=3 uid="uid://dflvi18e358ek"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_m1ni4"] +size = Vector2(16, 16) + +[node name="StaticBody2D" type="StaticBody2D"] +collision_layer = 16 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(8, -8) +shape = SubResource("RectangleShape2D_m1ni4") diff --git a/scenes/enemies/coopa.tscn b/scenes/enemies/coopa.tscn new file mode 100644 index 0000000..9df633b --- /dev/null +++ b/scenes/enemies/coopa.tscn @@ -0,0 +1,112 @@ +[gd_scene load_steps=10 format=3 uid="uid://bkpny146y0y0e"] + +[ext_resource type="Texture2D" uid="uid://ddl5f3lldrp2n" path="res://assets/enemies.png" id="1_451aa"] +[ext_resource type="Script" path="res://scripts/enemies/coopa.gd" id="1_iin32"] +[ext_resource type="AudioStream" uid="uid://bh8t167vl6j2n" path="res://assets/sounds/NES - Super Mario Bros - Sound Effects/Super Mario Bros 1 and 2(JP)/Kick.wav" id="2_e5ron"] + +[sub_resource type="AtlasTexture" id="AtlasTexture_ub6x3"] +atlas = ExtResource("1_451aa") +region = Rect2(150, 0, 16, 24) + +[sub_resource type="AtlasTexture" id="AtlasTexture_dr5y8"] +atlas = ExtResource("1_451aa") +region = Rect2(180, 0, 16, 24) + +[sub_resource type="AtlasTexture" id="AtlasTexture_hduks"] +atlas = ExtResource("1_451aa") +region = Rect2(360, 4, 16, 15) + +[sub_resource type="SpriteFrames" id="SpriteFrames_g2x7m"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_ub6x3") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_dr5y8") +}], +"loop": true, +"name": &"default", +"speed": 5.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_hduks") +}], +"loop": true, +"name": &"shrink", +"speed": 5.0 +}] + +[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_ti4si"] +radius = 7.0 +height = 24.0 + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_dpvp1"] +size = Vector2(10, 0.5) + +[node name="coopa" type="RigidBody2D"] +collision_layer = 128 +lock_rotation = true +script = ExtResource("1_iin32") + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] +position = Vector2(8, -12) +sprite_frames = SubResource("SpriteFrames_g2x7m") +autoplay = "default" + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(8, -12) +shape = SubResource("CapsuleShape2D_ti4si") + +[node name="RayCastLeft" type="RayCast2D" parent="."] +position = Vector2(8, -8) +target_position = Vector2(-8, 0) +collision_mask = 17 + +[node name="RayCastLeft2" type="RayCast2D" parent="."] +position = Vector2(8, -8) +target_position = Vector2(-8, 0) +collision_mask = 2 + +[node name="RayCastLeft3" type="RayCast2D" parent="."] +position = Vector2(8, -8) +target_position = Vector2(-8, 0) +collision_mask = 128 + +[node name="RayCastRight" type="RayCast2D" parent="."] +position = Vector2(8, -8) +target_position = Vector2(8, 0) +collision_mask = 17 + +[node name="RayCastRight2" type="RayCast2D" parent="."] +position = Vector2(8, -8) +target_position = Vector2(8, 0) +collision_mask = 2 + +[node name="RayCastRight3" type="RayCast2D" parent="."] +position = Vector2(8, -8) +target_position = Vector2(8, 0) +collision_mask = 128 + +[node name="die" type="Area2D" parent="."] +position = Vector2(0, -8) +collision_mask = 2 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="die"] +position = Vector2(8, -16.25) +shape = SubResource("RectangleShape2D_dpvp1") + +[node name="dieSound" type="AudioStreamPlayer2D" parent="."] +stream = ExtResource("2_e5ron") + +[node name="Timer2" type="Timer" parent="."] +one_shot = true + +[node name="Timer" type="Timer" parent="."] +wait_time = 0.5 +one_shot = true + +[connection signal="body_entered" from="die" to="." method="_on_die_body_entered"] +[connection signal="timeout" from="Timer2" to="." method="_on_timer_2_timeout"] +[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"] diff --git a/scenes/levels/level_1.tscn b/scenes/levels/level_1.tscn index 39deff2..dd5d366 100644 --- a/scenes/levels/level_1.tscn +++ b/scenes/levels/level_1.tscn @@ -14,6 +14,7 @@ [ext_resource type="Script" path="res://scripts/Label_Platform.gd" id="12_uc2k2"] [ext_resource type="Script" path="res://scripts/WorldBoundDown.gd" id="13_je7o8"] [ext_resource type="PackedScene" uid="uid://bm04qp5vgbi10" path="res://scenes/flag.tscn" id="14_ry537"] +[ext_resource type="PackedScene" uid="uid://dflvi18e358ek" path="res://scenes/blocks/enimie_barrier.tscn" id="15_ac2kk"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_sdqov"] texture = ExtResource("1_p04bh") @@ -19057,9 +19058,6 @@ texture = ExtResource("1_p04bh") physics_layer_0/collision_layer = 1 sources/1 = SubResource("TileSetAtlasSource_sdqov") -[sub_resource type="RectangleShape2D" id="RectangleShape2D_ipe5j"] -size = Vector2(16, 16) - [sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_tuxwn"] [sub_resource type="SegmentShape2D" id="SegmentShape2D_khpgg"] @@ -19297,30 +19295,6 @@ position = Vector2(752, 128) [node name="invisible_barriers" type="Node" parent="."] -[node name="StaticBody2D" type="StaticBody2D" parent="invisible_barriers"] -position = Vector2(1056, -16) -collision_layer = 16 - -[node name="CollisionShape2D" type="CollisionShape2D" parent="invisible_barriers/StaticBody2D"] -position = Vector2(-8, 8) -shape = SubResource("RectangleShape2D_ipe5j") - -[node name="StaticBody2D2" type="StaticBody2D" parent="invisible_barriers"] -position = Vector2(1312, -16) -collision_layer = 16 - -[node name="CollisionShape2D" type="CollisionShape2D" parent="invisible_barriers/StaticBody2D2"] -position = Vector2(-8, 8) -shape = SubResource("RectangleShape2D_ipe5j") - -[node name="StaticBody2D4" type="StaticBody2D" parent="invisible_barriers"] -position = Vector2(1344, -16) -collision_layer = 16 - -[node name="CollisionShape2D" type="CollisionShape2D" parent="invisible_barriers/StaticBody2D4"] -position = Vector2(-8, 8) -shape = SubResource("RectangleShape2D_ipe5j") - [node name="StaticBody2D3" type="StaticBody2D" parent="invisible_barriers"] position = Vector2(-160, -16) collision_layer = 17 @@ -19449,5 +19423,14 @@ text = "120" [node name="Flag" parent="." instance=ExtResource("14_ry537")] load_level = "level_2" +[node name="StaticBody2D" parent="." instance=ExtResource("15_ac2kk")] +position = Vector2(1040, 0) + +[node name="StaticBody2D2" parent="." instance=ExtResource("15_ac2kk")] +position = Vector2(1296, 0) + +[node name="StaticBody2D3" parent="." instance=ExtResource("15_ac2kk")] +position = Vector2(1328, 0) + [connection signal="body_entered" from="WorldBoundDown" to="WorldBoundDown" method="_on_body_entered"] [connection signal="timeout" from="WorldBoundDown/Timer" to="WorldBoundDown" method="_on_timer_timeout"] diff --git a/scenes/levels/level_2.tscn b/scenes/levels/level_2.tscn index 6c81fac..3a9259b 100644 --- a/scenes/levels/level_2.tscn +++ b/scenes/levels/level_2.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=20 format=3 uid="uid://c0r61y2b3pt4m"] +[gd_scene load_steps=23 format=3 uid="uid://c0r61y2b3pt4m"] [ext_resource type="PackedScene" uid="uid://dk1aby88pygtr" path="res://scenes/player.tscn" id="1_76q1j"] [ext_resource type="Texture2D" uid="uid://bbf2n32u766cp" path="res://assets/bg-1-2.png" id="1_cckci"] @@ -8,13 +8,16 @@ [ext_resource type="Script" path="res://scripts/WorldBoundDown.gd" id="3_xiqi1"] [ext_resource type="PackedScene" uid="uid://d25ukpt8ot8xv" path="res://scenes/blocks/itemblock.tscn" id="6_1xseh"] [ext_resource type="PackedScene" uid="uid://cc4excywfdh1v" path="res://scenes/blocks/destroyblock_dark.tscn" id="6_hol3k"] -[ext_resource type="PackedScene" uid="uid://b4dp88urmm7g8" path="res://scenes/items/mushroom.tscn" id="8_6u0iy"] [ext_resource type="PackedScene" uid="uid://nm5keea43u56" path="res://scenes/items/coin.tscn" id="9_a4rwl"] [ext_resource type="PackedScene" uid="uid://be832pldgbeyk" path="res://scenes/pipe.tscn" id="10_aqfih"] [ext_resource type="PackedScene" uid="uid://ct54hcx2h7riy" path="res://scenes/blocks/spawner.tscn" id="11_djx30"] [ext_resource type="PackedScene" uid="uid://dad1wol24icj0" path="res://scenes/blocks/move_platform_down.tscn" id="12_fha8x"] +[ext_resource type="PackedScene" uid="uid://bp71ntkh281k5" path="res://scenes/items/fire_flower.tscn" id="12_m58he"] [ext_resource type="PackedScene" uid="uid://bofueafaqy7so" path="res://scenes/blocks/move_platform_up.tscn" id="13_8y7tv"] [ext_resource type="PackedScene" uid="uid://bm04qp5vgbi10" path="res://scenes/flag.tscn" id="15_n64v8"] +[ext_resource type="PackedScene" uid="uid://cwviqxncs4fom" path="res://scenes/enemies/gumba.tscn" id="16_qpvvg"] +[ext_resource type="PackedScene" uid="uid://bkpny146y0y0e" path="res://scenes/enemies/coopa.tscn" id="17_4rxmp"] +[ext_resource type="PackedScene" uid="uid://dflvi18e358ek" path="res://scenes/blocks/enimie_barrier.tscn" id="18_ujrgy"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_6hwce"] texture = ExtResource("1_cckci") @@ -45038,7 +45041,7 @@ delay = 2.0 [node name="player" parent="." instance=ExtResource("1_76q1j")] unique_name_in_owner = true z_index = 5 -position = Vector2(1, -90) +position = Vector2(-112, -96) [node name="Music" type="AudioStreamPlayer" parent="."] unique_name_in_owner = true @@ -45579,19 +45582,27 @@ position = Vector2(1280, 128) [node name="itemblock" parent="interactionBlocks" instance=ExtResource("6_1xseh")] position = Vector2(32, -48) +hit_object = ExtResource("12_m58he") [node name="itemblock2" parent="interactionBlocks" instance=ExtResource("6_1xseh")] position = Vector2(48, -48) +hit_object = ExtResource("9_a4rwl") +auto_collect = true [node name="itemblock3" parent="interactionBlocks" instance=ExtResource("6_1xseh")] position = Vector2(64, -48) +hit_object = ExtResource("9_a4rwl") +auto_collect = true [node name="itemblock4" parent="interactionBlocks" instance=ExtResource("6_1xseh")] position = Vector2(80, -48) +hit_object = ExtResource("9_a4rwl") +auto_collect = true [node name="itemblock5" parent="interactionBlocks" instance=ExtResource("6_1xseh")] position = Vector2(96, -48) -hit_object = ExtResource("8_6u0iy") +hit_object = ExtResource("9_a4rwl") +auto_collect = true [node name="coins" type="Node" parent="."] @@ -45713,9 +45724,76 @@ position = Vector2(2720, -48) rotation = -1.57079 target = Vector2(-80, -736) +[node name="enemies" type="Node" parent="."] + +[node name="Gumba" parent="enemies" instance=ExtResource("16_qpvvg")] +position = Vector2(96, 0) + +[node name="Gumba2" parent="enemies" instance=ExtResource("16_qpvvg")] +position = Vector2(128, 0) + +[node name="Gumba3" parent="enemies" instance=ExtResource("16_qpvvg")] +position = Vector2(336, 0) + +[node name="coopa" parent="enemies" instance=ExtResource("17_4rxmp")] +position = Vector2(496, 0) + +[node name="coopa2" parent="enemies" instance=ExtResource("17_4rxmp")] +position = Vector2(528, 0) + +[node name="coopa3" parent="enemies" instance=ExtResource("17_4rxmp")] +position = Vector2(800, 0) + +[node name="Gumba4" parent="enemies" instance=ExtResource("16_qpvvg")] +position = Vector2(848, 0) + +[node name="Gumba5" parent="enemies" instance=ExtResource("16_qpvvg")] +position = Vector2(896, 0) + +[node name="Gumba6" parent="enemies" instance=ExtResource("16_qpvvg")] +position = Vector2(1120, 0) + +[node name="Gumba7" parent="enemies" instance=ExtResource("16_qpvvg")] +position = Vector2(1088, 0) + +[node name="Gumba8" parent="enemies" instance=ExtResource("16_qpvvg")] +position = Vector2(1088, -64) + +[node name="Gumba9" parent="enemies" instance=ExtResource("16_qpvvg")] +position = Vector2(1424, 0) + +[node name="Gumba10" parent="enemies" instance=ExtResource("16_qpvvg")] +position = Vector2(1392, 0) + +[node name="Gumba11" parent="enemies" instance=ExtResource("16_qpvvg")] +position = Vector2(1360, 0) + +[node name="Gumba12" parent="enemies" instance=ExtResource("16_qpvvg")] +position = Vector2(2000, -48) + +[node name="Gumba13" parent="enemies" instance=ExtResource("16_qpvvg")] +position = Vector2(1968, -16) + [node name="Flag" parent="." instance=ExtResource("15_n64v8")] position = Vector2(216, -679) load_level = "level_1" +[node name="invisibleBarriers" type="Node" parent="."] + +[node name="StaticBody2D" parent="." instance=ExtResource("18_ujrgy")] +position = Vector2(1824, 0) + +[node name="StaticBody2D2" parent="." instance=ExtResource("18_ujrgy")] +position = Vector2(1168, 0) + +[node name="StaticBody2D3" parent="." instance=ExtResource("18_ujrgy")] +position = Vector2(1136, 0) + +[node name="StaticBody2D4" parent="." instance=ExtResource("18_ujrgy")] +position = Vector2(720, 0) + +[node name="StaticBody2D5" parent="." instance=ExtResource("18_ujrgy")] +position = Vector2(736, 0) + [connection signal="body_entered" from="WorldBoundDown" to="WorldBoundDown" method="_on_body_entered"] [connection signal="timeout" from="WorldBoundDown/Timer" to="WorldBoundDown" method="_on_timer_timeout"] diff --git a/scripts/enemies/coopa.gd b/scripts/enemies/coopa.gd new file mode 100644 index 0000000..a9a4695 --- /dev/null +++ b/scripts/enemies/coopa.gd @@ -0,0 +1,101 @@ +extends RigidBody2D + +@export var speed = -70 +@onready var ray_cast_left = $RayCastLeft +@onready var ray_cast_right = $RayCastRight +@onready var animated_sprite_2d = $AnimatedSprite2D +@onready var timer = $Timer +@onready var die = $die +@onready var ray_cast_left_2 = $RayCastLeft2 +@onready var ray_cast_right_2 = $RayCastRight2 +var innocent = false +@onready var timer_2 = $Timer2 +var is_down = false +@onready var collision_shape_2d = $CollisionShape2D +@onready var ray_cast_left_3 = $RayCastLeft3 +@onready var ray_cast_right_3 = $RayCastRight3 + +func _ready(): + collision_shape_2d.shape.height = 24 + +func _physics_process(delta): + linear_velocity.x = speed + + if ray_cast_left_2 == null: + return + + if ray_cast_left.is_colliding() or ray_cast_left_2.is_colliding(): + speed = abs(speed) + animated_sprite_2d.flip_h = true + elif ray_cast_right.is_colliding() or ray_cast_right_2.is_colliding(): + speed = -abs(speed) + animated_sprite_2d.flip_h = false + + var other = null + if ray_cast_left_3.is_colliding(): + other = ray_cast_left_3.get_collider() + elif ray_cast_right_3.is_colliding(): + other = ray_cast_right_3.get_collider() + + if is_down and speed != 0 and other != null: + other.f_die() + + if innocent: + return + + var body = null + if ray_cast_left_2.is_colliding(): + if speed != 0: + body = ray_cast_left_2.get_collider() + else: + speed = 160 + innocent = true + die_sound.play() + timer_2.start() + elif ray_cast_right_2.is_colliding(): + if speed != 0: + body = ray_cast_right_2.get_collider() + else: + speed = -160 + innocent = true + die_sound.play() + timer_2.start() + + if body != null: + body.shrink() + innocent = true + timer_2.start() + + +@onready var die_sound = $dieSound + +func f_die(): + die_sound.play() + speed = 0 + innocent = true + timer.start() + +func f_shrink(body): + die_sound.play() + if not is_down: + speed = 0 + collision_shape_2d.shape.height -= 9 + die.position.y += 2 + animated_sprite_2d.play("shrink") + is_down = true + elif speed == 0: + speed = 160 if body.position.x < position.x else -160 + else: + speed = 0 + +func _on_timer_2_timeout(): + innocent = false + + +func _on_die_body_entered(body): + f_shrink(body) + body.velocity.y = body.JUMPt_velocity/1.5 + + +func _on_timer_timeout(): + queue_free() diff --git a/scripts/enemies/gumba.gd b/scripts/enemies/gumba.gd index da788b3..87b3fd6 100644 --- a/scripts/enemies/gumba.gd +++ b/scripts/enemies/gumba.gd @@ -38,6 +38,7 @@ func _physics_process(delta): @onready var die_sound = $dieSound func f_die(): + innocent = true speed = 0 animated_sprite_2d.play("die") timer.start()