diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-04-22 16:34:25 +0200 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-04-22 16:34:25 +0200 |
commit | c8a316e4b8987dad963656a34665fa0e23dedcb1 (patch) | |
tree | 569af4b4f37d21079b6aedfad5164e94b50b6cb8 /Scenes/Entities | |
parent | f27937e6e9b6a7146dd09fc711d2d293ecf5abbf (diff) |
update
Diffstat (limited to 'Scenes/Entities')
-rw-r--r-- | Scenes/Entities/Bombs/Bomb.gd | 8 | ||||
-rw-r--r-- | Scenes/Entities/Bombs/Explosion.gd | 2 | ||||
-rw-r--r-- | Scenes/Entities/Bombs/Explosion.tscn | 2 | ||||
-rw-r--r-- | Scenes/Entities/Enemies/Balloon.tscn | 9 | ||||
-rw-r--r-- | Scenes/Entities/Enemies/Components/Movement.gd | 10 | ||||
-rw-r--r-- | Scenes/Entities/Objects/Coin.gd | 6 | ||||
-rw-r--r-- | Scenes/Entities/Objects/Coin.tscn | 11 | ||||
-rw-r--r-- | Scenes/Entities/Objects/Sign.gd | 2 | ||||
-rw-r--r-- | Scenes/Entities/Objects/Vines.gd | 53 | ||||
-rw-r--r-- | Scenes/Entities/Objects/Vines.tscn | 58 | ||||
-rw-r--r-- | Scenes/Entities/Player.tscn | 2 |
11 files changed, 145 insertions, 18 deletions
diff --git a/Scenes/Entities/Bombs/Bomb.gd b/Scenes/Entities/Bombs/Bomb.gd index 3981122..4256fc5 100644 --- a/Scenes/Entities/Bombs/Bomb.gd +++ b/Scenes/Entities/Bombs/Bomb.gd @@ -84,9 +84,11 @@ func explode(): collision_type = self._on_collide_group_bombs() elif collider.is_in_group("breakables"): collision_type = self._on_collide_group_breakables() + elif collider.is_in_group("hitables"): + collision_type = self._on_collide_group_hitables() else: collision_type = self._on_collide_group_else() - + # progress loop based on collision type if collision_type == EXPLOSION_COLLISION_TYPE.STOP: break @@ -178,5 +180,9 @@ func _on_collide_group_breakables(): return EXPLOSION_COLLISION_TYPE.HIT_STOP +func _on_collide_group_hitables(): + return EXPLOSION_COLLISION_TYPE.HIT_CONTINUE + + func _on_collide_group_else(): return EXPLOSION_COLLISION_TYPE.STOP diff --git a/Scenes/Entities/Bombs/Explosion.gd b/Scenes/Entities/Bombs/Explosion.gd index eba8b29..56524e3 100644 --- a/Scenes/Entities/Bombs/Explosion.gd +++ b/Scenes/Entities/Bombs/Explosion.gd @@ -1,5 +1,7 @@ extends Area2D +class_name Explosion + func _ready(): add_to_group("explosions") diff --git a/Scenes/Entities/Bombs/Explosion.tscn b/Scenes/Entities/Bombs/Explosion.tscn index 2521dfb..75740ad 100644 --- a/Scenes/Entities/Bombs/Explosion.tscn +++ b/Scenes/Entities/Bombs/Explosion.tscn @@ -49,7 +49,7 @@ radius = 7.5 [node name="Explosion" type="Area2D"] collision_layer = 32 -collision_mask = 62 +collision_mask = 126 script = ExtResource("2") [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] diff --git a/Scenes/Entities/Enemies/Balloon.tscn b/Scenes/Entities/Enemies/Balloon.tscn index 85b68c1..71f6e5d 100644 --- a/Scenes/Entities/Enemies/Balloon.tscn +++ b/Scenes/Entities/Enemies/Balloon.tscn @@ -98,11 +98,12 @@ animations = [{ [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_abul4"] radius = 6.0 -height = 18.0 +height = 15.0 [node name="Balloon" type="CharacterBody2D"] collision_layer = 16 -collision_mask = 62 +collision_mask = 60 +motion_mode = 1 script = ExtResource("1_8q3w8") health = 1 @@ -111,12 +112,14 @@ sprite_frames = SubResource("SpriteFrames_nxaqi") animation = &"down" [node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(0, -1) shape = SubResource("CapsuleShape2D_abul4") [node name="Movement" parent="." instance=ExtResource("15_fwetl")] entityPath = NodePath("..") spritePath = NodePath("../AnimatedSprite2D") -SPEED = 2 +SPEED = 5 +timer_time = 10.0 [node name="Collision" parent="." instance=ExtResource("16_yau34")] entityPath = NodePath("..") diff --git a/Scenes/Entities/Enemies/Components/Movement.gd b/Scenes/Entities/Enemies/Components/Movement.gd index 0b30820..6ded026 100644 --- a/Scenes/Entities/Enemies/Components/Movement.gd +++ b/Scenes/Entities/Enemies/Components/Movement.gd @@ -1,5 +1,6 @@ extends Node + signal direction_changed @export_node_path("CharacterBody2D") var entityPath: NodePath @@ -13,11 +14,12 @@ signal direction_changed const DIRECTIONS = [Vector2.UP, Vector2.RIGHT, Vector2.DOWN, Vector2.LEFT] var CURRENT_DIRECTION = Vector2.UP +@export var timer_time: float = 3.0 @onready var MovementTimer: Timer = Timer.new() func _ready(): - MovementTimer.wait_time = 3.0 + MovementTimer.wait_time = timer_time MovementTimer.autostart = true MovementTimer.connect("timeout", Callable(_on_movement_timer_timeout)) add_child(MovementTimer) @@ -38,7 +40,11 @@ func physics_process(delta): sprite.play("right") var collision = entity.move_and_collide(entity.velocity * delta) - entity.velocity = entity.velocity.lerp(Vector2(0, 0), 1) + entity.velocity = entity.velocity.lerp(Vector2(0, 0), 1) # speed too low => no collision + + if collision: + if MovementTimer.time_left > 0: + _on_movement_timer_timeout() return collision diff --git a/Scenes/Entities/Objects/Coin.gd b/Scenes/Entities/Objects/Coin.gd index 48e30b3..2bbb75c 100644 --- a/Scenes/Entities/Objects/Coin.gd +++ b/Scenes/Entities/Objects/Coin.gd @@ -9,10 +9,8 @@ func _ready(): add_child(collision_area) -func hit_by_explosion(): - queue_free() - - func _collide(area: Area2D): if area.is_in_group("player"): queue_free() + elif area.is_in_group("explosions"): + queue_free() diff --git a/Scenes/Entities/Objects/Coin.tscn b/Scenes/Entities/Objects/Coin.tscn index aacb70b..1025602 100644 --- a/Scenes/Entities/Objects/Coin.tscn +++ b/Scenes/Entities/Objects/Coin.tscn @@ -1,13 +1,14 @@ [gd_scene load_steps=4 format=3 uid="uid://cl7jri45a43t0"] [ext_resource type="Script" path="res://Scenes/Entities/Objects/Coin.gd" id="1_kjrye"] -[ext_resource type="Texture2D" uid="uid://5dk0c1kpvdgs" path="res://Assets/bomb_party_v4.png" id="2_0mghm"] +[ext_resource type="Texture2D" uid="uid://b6ce2eihxulqb" path="res://Assets/Stages/core_set pieces.png" id="2_jf7cy"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_rwppg"] size = Vector2(16, 16) [node name="Coin" type="StaticBody2D" groups=["breakables"]] -collision_layer = 8 +z_index = -1 +collision_layer = 64 collision_mask = 34 script = ExtResource("1_kjrye") @@ -15,7 +16,7 @@ script = ExtResource("1_kjrye") shape = SubResource("RectangleShape2D_rwppg") [node name="Sprite2D" type="Sprite2D" parent="."] -self_modulate = Color(1, 0, 1, 1) -texture = ExtResource("2_0mghm") +scale = Vector2(1.1, 1.1) +texture = ExtResource("2_jf7cy") region_enabled = true -region_rect = Rect2(48.8626, 208.456, 15.1374, 15.5442) +region_rect = Rect2(33.788, 376.89, 13, 13) diff --git a/Scenes/Entities/Objects/Sign.gd b/Scenes/Entities/Objects/Sign.gd index 9d83bab..81d3a6c 100644 --- a/Scenes/Entities/Objects/Sign.gd +++ b/Scenes/Entities/Objects/Sign.gd @@ -13,7 +13,7 @@ func _ready(): add_child(interaction_area) -func _physics_process(_delta): +func _input(event): if Input.is_action_just_pressed("ui_accept") and interaction_area.has_overlapping_areas(): for area in interaction_area.get_overlapping_areas(): if area.is_in_group("player"): diff --git a/Scenes/Entities/Objects/Vines.gd b/Scenes/Entities/Objects/Vines.gd new file mode 100644 index 0000000..ac2c249 --- /dev/null +++ b/Scenes/Entities/Objects/Vines.gd @@ -0,0 +1,53 @@ +extends StaticBody2D + + +@export_enum("up", "down", "left", "right") var spread_direction: String = "right" + + +# Called when the node enters the scene tree for the first time. +func _ready(): + add_to_group("hitables") + + if spread_direction == "up": + rotate(deg_to_rad(-90)) + elif spread_direction == "down": + rotate(deg_to_rad(90)) + elif spread_direction == "left": + rotate(deg_to_rad(180)) + elif spread_direction == "right": + rotate(deg_to_rad(0)) + + spread() + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(_delta): + pass + + +func spread(): + var grow = func(): + $CollisionShape2D.shape.size.x += 16 * $AnimatedSprite2D.frame + + $AnimatedSprite2D.frame_changed.connect(grow) + $AnimatedSprite2D.play() + await $AnimatedSprite2D.animation_finished + $AnimatedSprite2D.frame_changed.disconnect(grow) + + +func retract(): + var shrink = func(): + $CollisionShape2D.shape.size.x -= 16 * ($AnimatedSprite2D.frame + 1) + + $AnimatedSprite2D.frame_changed.connect(shrink) + $AnimatedSprite2D.play_backwards() + await $AnimatedSprite2D.animation_finished + $AnimatedSprite2D.frame_changed.disconnect(shrink) + + await get_tree().create_timer(3).timeout + spread() + + +func hit_by_explosion(): + if not $AnimatedSprite2D.is_playing(): + retract() diff --git a/Scenes/Entities/Objects/Vines.tscn b/Scenes/Entities/Objects/Vines.tscn new file mode 100644 index 0000000..2fd10f8 --- /dev/null +++ b/Scenes/Entities/Objects/Vines.tscn @@ -0,0 +1,58 @@ +[gd_scene load_steps=9 format=3 uid="uid://ceoy1eb10tq0a"] + +[ext_resource type="Script" path="res://Scenes/Entities/Objects/Vines.gd" id="1_ymtv0"] +[ext_resource type="Texture2D" uid="uid://bxl3lqlm22eem" path="res://Assets/Stages/core_outdoor.png" id="2_8tl8f"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_5f74o"] +resource_local_to_scene = true +size = Vector2(14, 14) + +[sub_resource type="AtlasTexture" id="AtlasTexture_skslo"] +atlas = ExtResource("2_8tl8f") +region = Rect2(384, 528, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_u5r5b"] +atlas = ExtResource("2_8tl8f") +region = Rect2(384, 528, 32, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_5h70f"] +atlas = ExtResource("2_8tl8f") +region = Rect2(384, 528, 48, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_osbyn"] +atlas = ExtResource("2_8tl8f") +region = Rect2(384, 528, 64, 16) + +[sub_resource type="SpriteFrames" id="SpriteFrames_xn7q5"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_skslo") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_u5r5b") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_5h70f") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_osbyn") +}], +"loop": false, +"name": &"default", +"speed": 8.0 +}] + +[node name="Vines" type="StaticBody2D"] +z_index = -1 +collision_layer = 72 +collision_mask = 0 +script = ExtResource("1_ymtv0") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("RectangleShape2D_5f74o") + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] +position = Vector2(-8, -8) +sprite_frames = SubResource("SpriteFrames_xn7q5") +centered = false diff --git a/Scenes/Entities/Player.tscn b/Scenes/Entities/Player.tscn index d52e032..54b2f30 100644 --- a/Scenes/Entities/Player.tscn +++ b/Scenes/Entities/Player.tscn @@ -238,7 +238,7 @@ size = Vector2(14, 14) [node name="Player" type="CharacterBody2D"] collision_layer = 2 -collision_mask = 60 +collision_mask = 236 motion_mode = 1 wall_min_slide_angle = 1.5708 script = ExtResource("1_2xulf") |