Skip to content

Commit

Permalink
Implement side door and loading stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
davnotdev committed May 19, 2024
1 parent cfb7fe2 commit e60b835
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 19 deletions.
23 changes: 20 additions & 3 deletions scenes/door.tscn
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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": [{
Expand Down Expand Up @@ -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"]
Expand All @@ -79,16 +92,20 @@ 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)
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)
Expand Down
3 changes: 2 additions & 1 deletion scenes/ogre.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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"]
27 changes: 16 additions & 11 deletions scripts/Door.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions scripts/RoomManager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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()
4 changes: 3 additions & 1 deletion scripts/next_level.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion scripts/ogre.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions scripts/start_menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)


Expand All @@ -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)

0 comments on commit e60b835

Please sign in to comment.