From e60b835d997328bec1456e3e7328339540025e67 Mon Sep 17 00:00:00 2001 From: dav Date: Sun, 19 May 2024 15:20:53 -0700 Subject: [PATCH] Implement side door and loading stuff --- scenes/door.tscn | 23 ++++++++++++++++++++--- scenes/ogre.tscn | 3 ++- scripts/Door.gd | 27 ++++++++++++++++----------- scripts/RoomManager.gd | 2 ++ scripts/next_level.gd | 4 +++- scripts/ogre.gd | 3 ++- scripts/start_menu.gd | 7 +++++-- 7 files changed, 50 insertions(+), 19 deletions(-) diff --git a/scenes/door.tscn b/scenes/door.tscn index 9e4fe15..9dcd4bc 100644 --- a/scenes/door.tscn +++ b/scenes/door.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=14 format=3 uid="uid://ckc52m6ovxgvd"] +[gd_scene load_steps=16 format=3 uid="uid://ckc52m6ovxgvd"] [ext_resource type="Script" path="res://scripts/Door.gd" id="1_vkm81"] [ext_resource type="Texture2D" uid="uid://drokqbdx3rj2w" path="res://art/door animation-Sheet.png" id="2_bgshb"] [ext_resource type="Texture2D" uid="uid://cbmolpgifd208" path="res://art/door animation2-Sheet.png" id="3_ntp35"] +[ext_resource type="Texture2D" uid="uid://bau13teyplhkl" path="res://art/SunDoor.png" id="4_ewnw1"] [sub_resource type="AtlasTexture" id="AtlasTexture_lt2tw"] atlas = ExtResource("2_bgshb") @@ -24,6 +25,10 @@ region = Rect2(960, 0, 960, 640) atlas = ExtResource("3_ntp35") region = Rect2(1920, 0, 960, 640) +[sub_resource type="AtlasTexture" id="AtlasTexture_40klt"] +atlas = ExtResource("4_ewnw1") +region = Rect2(243, 0, 24, 72) + [sub_resource type="SpriteFrames" id="SpriteFrames_lf7j4"] animations = [{ "frames": [{ @@ -55,6 +60,14 @@ animations = [{ "loop": true, "name": &"opening", "speed": 5.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_40klt") +}], +"loop": true, +"name": &"side_closed", +"speed": 5.0 }] [sub_resource type="CompressedTexture2D" id="CompressedTexture2D_6dv1i"] @@ -79,9 +92,9 @@ script = ExtResource("1_vkm81") position = Vector2(1.99998, -48) scale = Vector2(0.225, 0.428125) sprite_frames = SubResource("SpriteFrames_lf7j4") -animation = &"opening" +animation = &"side_closed" -[node name="Sprite2D" type="Sprite2D" parent="."] +[node name="ForwardDoor" type="Sprite2D" parent="."] visible = false position = Vector2(94, -174) scale = Vector2(0.6, 0.84) @@ -89,6 +102,10 @@ texture = SubResource("CompressedTexture2D_6dv1i") offset = Vector2(-320, 320) metadata/_edit_group_ = true +[node name="SideDoor" type="Sprite2D" parent="."] +visible = false +texture = ExtResource("4_ewnw1") + [node name="CollisionShape2D" type="CollisionShape2D" parent="."] position = Vector2(0, -10) scale = Vector2(0.5, 0.5) diff --git a/scenes/ogre.tscn b/scenes/ogre.tscn index 37044e6..1f99f08 100644 --- a/scenes/ogre.tscn +++ b/scenes/ogre.tscn @@ -3,7 +3,7 @@ [ext_resource type="Script" path="res://scripts/ogre.gd" id="1_3lsmk"] [ext_resource type="Texture2D" uid="uid://e8riu5j0moty" path="res://art/ogreswing-Sheet.png" id="1_i8oap"] [ext_resource type="Texture2D" uid="uid://ce4lgqmvbhjho" path="res://art/ogre-Sheet.png" id="3_4mhx3"] -[ext_resource type="PackedScene" uid="uid://bs8ryit1q2i3t" path="res://scenes/fire_particle_2.tscn" id="4_wgpv8"] +[ext_resource type="PackedScene" uid="uid://cscfo63mmurx6" path="res://scenes/fire_particle_2.tscn" id="4_wgpv8"] [sub_resource type="AtlasTexture" id="AtlasTexture_ff038"] atlas = ExtResource("1_i8oap") @@ -248,6 +248,7 @@ show_percentage = false [node name="Fire Particle" parent="." instance=ExtResource("4_wgpv8")] z_index = -10 emitting = false +initial_velocity_min = 0.0 initial_velocity_max = 0.0 [connection signal="area_entered" from="Area2D" to="." method="_on_area_2d_area_entered"] diff --git a/scripts/Door.gd b/scripts/Door.gd index 61b439a..5ffb514 100644 --- a/scripts/Door.gd +++ b/scripts/Door.gd @@ -7,27 +7,32 @@ class_name Door @onready var enter_trigger = $EnterTrigger @onready var collider = $CollisionShape2D -@onready var sprite_2d = $Sprite2D @onready var animated_sprite_2d = $AnimatedSprite2D func _ready(): enter_trigger.position = -Vector2.UP * 100.0 rotation = direction.angle() + PI / 2 - - #sprite_2d.hide() - - animated_sprite_2d.play("open") + if abs(direction.x) > 0: + animated_sprite_2d.position.y += 50.0 + animated_sprite_2d.scale = Vector2(2.5, 2.5) + animated_sprite_2d.rotation -= PI / 2 + + set_disabled(true) func set_disabled(disabled: bool): collider.disabled = disabled + var play_animation if disabled: - # pass - #sprite_2d.hide() - animated_sprite_2d.play("open") + if abs(direction.x) > 0: + play_animation = "side_closed" + else: + play_animation = "open" else: - # pass - #sprite_2d.show() - animated_sprite_2d.play("closed") + if abs(direction.x) > 0: + play_animation = "side_closed" + else: + play_animation = "closed" + animated_sprite_2d.play(play_animation) func _on_enter_trigger_area_entered(area): if area.owner is Player: diff --git a/scripts/RoomManager.gd b/scripts/RoomManager.gd index 7134aab..a88c28f 100644 --- a/scripts/RoomManager.gd +++ b/scripts/RoomManager.gd @@ -87,3 +87,5 @@ func unpair_doors(): for door in doors: if door.direction == Vector2.DOWN: door.hide() + if door.direction == Vector2.RIGHT: + door.hide() diff --git a/scripts/next_level.gd b/scripts/next_level.gd index 5a53d9c..852ef45 100644 --- a/scripts/next_level.gd +++ b/scripts/next_level.gd @@ -3,6 +3,8 @@ extends Area2D @onready var sprite_2d = $Sprite2D var is_in_range = false +var world_scene = preload("res://scenes/test_world.tscn") + # Called when the node enters the scene tree for the first time. func _ready(): pass # Replace with function body. @@ -14,7 +16,7 @@ func _process(delta): is_in_range = false await LevelTransition.fade_to_black(1) Progression.next_level() - get_tree().change_scene_to_file("res://scenes/test_world.tscn") + get_tree().change_scene_to_packed(world_scene) LevelTransition.fade_from_black(1) func _on_area_entered(area): diff --git a/scripts/ogre.gd b/scripts/ogre.gd index 66b26cd..bbd78e0 100644 --- a/scripts/ogre.gd +++ b/scripts/ogre.gd @@ -63,7 +63,8 @@ func attack(): attacking = false await animated_sprite_2d.animation_finished - animated_sprite_2d.play("idle") + if !is_dead: + animated_sprite_2d.play("idle") func can_attack_player() -> bool: var to_player = player.position - position diff --git a/scripts/start_menu.gd b/scripts/start_menu.gd index 4c7efc1..3ba198f 100644 --- a/scripts/start_menu.gd +++ b/scripts/start_menu.gd @@ -4,6 +4,9 @@ extends CanvasLayer @onready var animated_title = $AnimatedTitle @onready var title_theme = $TitleTheme +var world_scene = preload("res://scenes/test_world.tscn") +var tutorial_scene = preload("res://scenes/tutorial_world.tscn") + var pressed = false var music_fade = false # Called when the node enters the scene tree for the first time. @@ -18,7 +21,7 @@ func _on_start_button_pressed(): music_fade = true pressed = true await LevelTransition.fade_to_black(1) - get_tree().change_scene_to_file("res://scenes/test_world.tscn") + get_tree().change_scene_to_packed(world_scene) LevelTransition.fade_from_black(1) @@ -36,5 +39,5 @@ func _on_tutorial_pressed(): Progression.set_tutorial() pressed = true await LevelTransition.fade_to_black(1) - get_tree().change_scene_to_file("res://scenes/tutorial_world.tscn") + get_tree().change_scene_to_packed(tutorial_scene) LevelTransition.fade_from_black(1)