]> git.seodisparate.com - LD55/commitdiff
Work
authorStephen Seo <seo.disparate@gmail.com>
Sat, 13 Apr 2024 10:07:54 +0000 (19:07 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Sat, 13 Apr 2024 10:07:54 +0000 (19:07 +0900)
Set up logic for collision with guard.

Some resizing of the DungeonEntrance scene.

DungeonEntrance.tscn
MainLogic.gd
gander_schwartz.gd

index 1c3d0b78c0326caaf3d30f02c24aa1235b1179ff..9c3cf43a5b1967f43339f47e7d4d6633eba22550 100644 (file)
@@ -1,4 +1,4 @@
-[gd_scene load_steps=4 format=3 uid="uid://b55f770t7xs6a"]
+[gd_scene load_steps=7 format=3 uid="uid://b55f770t7xs6a"]
 
 [ext_resource type="Texture2D" uid="uid://npjqgc3tdgs1" path="res://gimp/DungeonEntrance.png" id="1_vo6aq"]
 [ext_resource type="Texture2D" uid="uid://nocjsuuft8qx" path="res://gimp/DungeonGuard.png" id="2_nujkm"]
@@ -7,24 +7,60 @@
 radius = 15.0
 height = 32.0
 
+[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_ocep5"]
+normal = Vector2(1, 0)
+
+[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_gq7j0"]
+
+[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_xvl4y"]
+normal = Vector2(-1, 0)
+
 [node name="Node2D" type="Node2D"]
 
 [node name="DungeonEntrance" type="Sprite2D" parent="."]
 texture_filter = 1
-position = Vector2(-1, -320)
+position = Vector2(2, -784)
+scale = Vector2(1.995, 1.995)
 texture = ExtResource("1_vo6aq")
 
 [node name="StaticBody2D" type="StaticBody2D" parent="DungeonEntrance"]
+visible = false
 
 [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="DungeonEntrance/StaticBody2D"]
+visible = false
 polygon = PackedVector2Array(-160, 127, -159, -129, 160, -126, 161, 127, 21, 127, 21, 79, -19, 79, -19, 127)
 
 [node name="DungeonGuard" type="Sprite2D" parent="."]
 texture_filter = 1
-position = Vector2(0, -208)
+position = Vector2(2, -552)
+scale = Vector2(1.71, 1.71)
 texture = ExtResource("2_nujkm")
 
-[node name="StaticBody2D" type="StaticBody2D" parent="DungeonGuard"]
+[node name="DungeonGuardStaticBody" type="StaticBody2D" parent="DungeonGuard"]
+visible = false
 
-[node name="CollisionShape2D" type="CollisionShape2D" parent="DungeonGuard/StaticBody2D"]
+[node name="DungeonGuardCollider" type="CollisionShape2D" parent="DungeonGuard/DungeonGuardStaticBody"]
+visible = false
 shape = SubResource("CapsuleShape2D_18p8i")
+
+[node name="StaticBody2D" type="StaticBody2D" parent="."]
+
+[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"]
+position = Vector2(-307, -1)
+shape = SubResource("WorldBoundaryShape2D_ocep5")
+
+[node name="CollisionShape2D2" type="CollisionShape2D" parent="StaticBody2D"]
+position = Vector2(0, 210)
+shape = SubResource("WorldBoundaryShape2D_gq7j0")
+
+[node name="CollisionShape2D3" type="CollisionShape2D" parent="StaticBody2D"]
+position = Vector2(314, 5)
+shape = SubResource("WorldBoundaryShape2D_xvl4y")
+
+[node name="Label" type="Label" parent="."]
+z_index = 5
+offset_left = -111.0
+offset_top = 152.0
+offset_right = 111.0
+offset_bottom = 175.0
+text = "The Dungeon is to the north!"
index d7b798f63a265fd9665a2fe2993661f390ed4b4f..e37a4c64bc6fce22e42aa4b93250a0e2e6bd8802 100644 (file)
@@ -10,6 +10,10 @@ extends Node2D
 
 @onready var music_player = $MusicPlayer
 
+@onready var camera = $Camera2D
+
+const camera_move_speed = 80.0
+
 const text_speed = 0.08
 
 const start_text = "You seek the elementals?\nProve your worth!\nShow the elements your mastery over summoning, and they are yours!"
@@ -46,12 +50,16 @@ enum StateT {
        Introduction_05_post,
        Introduction_06,
        Introduction_06_post,
-       Dungeon_Entrance
+       Dungeon_Entrance_pre,
+       Dungeon_Entrance_loading,
+       Dungeon_Entrance,
+       Dungeon_Entrance_Battle,
 }
 
 static var state_dict = {}
 
 var tween_volume
+var tween_text
 
 var diamonds_gone = false
 
@@ -59,6 +67,9 @@ var music_file
 
 var gander
 
+var level
+var level_guard = null
+
 # Called when the node enters the scene tree for the first time.
 func _ready():
        if not state_dict.has("state"):
@@ -149,6 +160,23 @@ func _process(delta):
                        update_text(intro_text_06, StateT.Introduction_06_post)
                StateT.Introduction_06_post:
                        pass
+               StateT.Dungeon_Entrance_loading:
+                       gander.player_controlled = true
+                       gander.current_scene_type = gander.GanderSceneT.Gameplay
+                       var dungeon_scene = load("res://DungeonEntrance.tscn")
+                       level = dungeon_scene.instantiate()
+                       add_child(level)
+                       state_dict["state"] = StateT.Dungeon_Entrance
+                       lower_label.text = "Arrow keys/WASD/Left-Stick to move."
+                       tween_text = get_tree().create_tween()
+                       tween_text.tween_property(lower_label, "self_modulate", Color(1, 1, 1, 0), 5)
+               StateT.Dungeon_Entrance:
+                       camera_to_gander(delta)
+                       if level_guard == null:
+                               level_guard = level.find_child("DungeonGuardStaticBody")
+                       if level_guard != null and gander.last_collided_id == level_guard.get_instance_id():
+                               print("collided with guard.")
+                               gander.last_collided_id = null
                _:
                        pass
        if gander is MainCharacter and not gander.player_controlled and gander.current_scene_type == gander.GanderSceneT.Introduction:
@@ -170,7 +198,10 @@ func _unhandled_input(event):
                                state_dict["state"] = StateT.Start_Stopping
                                tween_volume = get_tree().create_tween()
                                tween_volume.tween_property(music_player, "volume_db", -80.0, 4.0)
-                               tween_volume.tween_callback(start_volume_tween_callback)
+                               tween_volume.tween_callback(func():
+                                       music_player.stop()
+                                       state_dict["state"] = StateT.MainMenu
+                               )
                                main_label.text = ""
                                lower_label.text = ""
                        StateT.Introduction_00:
@@ -239,16 +270,19 @@ func _unhandled_input(event):
                                state_dict["text_idx"] = 0
                                main_label.text = intro_text_06
                        StateT.Introduction_06_post:
-                               state_dict["state"] = StateT.Dungeon_Entrance
+                               state_dict["state"] = StateT.Dungeon_Entrance_pre
                                state_dict["timer"] = 0.0
                                state_dict["text_idx"] = 0
                                main_label.text = ""
+                               tween_volume = get_tree().create_tween()
+                               tween_volume.tween_property(music_player, "volume_db", -80.0, 4.0)
+                               tween_volume.tween_callback(func():
+                                       music_player.stop()
+                                       state_dict["state"] = StateT.Dungeon_Entrance_loading
+                                       music_player.volume_db = 0.0
+                               )
                        _:
                                pass
-
-func start_volume_tween_callback():
-       music_player.stop()
-       state_dict["state"] = StateT.MainMenu
        
 func diamond_position_update():
        fire_diamond.position.x = cos(state_dict["start_diamonds"]["angle"]) * state_dict["start_diamonds"]["dist"]
@@ -288,3 +322,14 @@ func update_stop_diamonds(delta):
                state_dict["start_diamonds"]["angle"] -= TAU
        
        diamond_position_update()
+
+func camera_to_gander(delta):
+       var diff = gander.position - camera.position
+       if diff.length() > 0.04:
+               var move_vec = diff.normalized() * camera_move_speed * delta
+               if diff.length() < move_vec.length():
+                       camera.position = gander.position
+               else:
+                       camera.position += move_vec
+       else:
+               camera.position = gander.position
index 45a3ff1ec27371bb4e430e66162a255afa2668ca..de4054145e15bbb078332c360e334f5cfe3fc691 100644 (file)
@@ -10,7 +10,10 @@ enum GanderSceneT {
 var current_scene_type = GanderSceneT.Introduction
 var auto_control_action = "facing_front"
 
+var last_collided_id = null
+
 @onready var animated = $AnimatedSprite2D
+@onready var guard = $DungeonGuard
 
 const SPEED = 150.0
 const ANIM_DEADZONE = 0.3
@@ -58,3 +61,8 @@ func _physics_process(delta):
                animated.play(auto_control_action)
 
        move_and_slide()
+       var last_collision = get_last_slide_collision()
+       if last_collision != null:
+               last_collided_id = last_collision.get_collider_id()
+       else:
+               last_collided_id = null