Add DungeonEntrance and DungeonGuard.

Some scripting for main character's movement.
This commit is contained in:
Stephen Seo 2024-04-13 16:16:11 +09:00
parent 5366561c58
commit 36cc125c7c
9 changed files with 235 additions and 5 deletions

30
DungeonEntrance.tscn Normal file
View file

@ -0,0 +1,30 @@
[gd_scene load_steps=4 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"]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_18p8i"]
radius = 15.0
height = 32.0
[node name="Node2D" type="Node2D"]
[node name="DungeonEntrance" type="Sprite2D" parent="."]
texture_filter = 1
position = Vector2(-1, -320)
texture = ExtResource("1_vo6aq")
[node name="StaticBody2D" type="StaticBody2D" parent="DungeonEntrance"]
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="DungeonEntrance/StaticBody2D"]
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)
texture = ExtResource("2_nujkm")
[node name="StaticBody2D" type="StaticBody2D" parent="DungeonGuard"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="DungeonGuard/StaticBody2D"]
shape = SubResource("CapsuleShape2D_18p8i")

View file

@ -17,6 +17,10 @@ const start_text = "You seek the elementals?\nProve your worth!\nShow the elemen
const intro_text_00 = "The name's Gander Schwartz.\nBut my friends call me the \"Wandering Gander\"."
const intro_text_01 = "I'm what most would call a \"third-rate summoner\",\nbut there's a reason for that.\nI summon \"items\", not \"beasts\"."
const intro_text_02 = "Most summoners summon beasts to fight for them.\nI summon items to fight with, or even tools to solve puzzles in dungeons."
const intro_text_03 = "There is one dungeon I've been itching to conquer.\nThe elemental dungeon!"
const intro_text_04 = "If I beat the elemental dungeon,\nI'll be able to enhance my summons with elemental properties!"
const intro_text_05 = "No longer would I need to light an oil lantern with flint and steel,\nor keep lugging around leather skins for water!"
const intro_text_06 = "But the dungeon is a challenge.\nA challenge I hope to best with my wits and my item summoning!"
const diamond_angle_rate = 1.2
const diamond_dist_rate = 50.0
@ -33,7 +37,16 @@ enum StateT {
Introduction_01,
Introduction_01_post,
Introduction_02,
Introduction_02_post
Introduction_02_post,
Introduction_03,
Introduction_03_post,
Introduction_04,
Introduction_04_post,
Introduction_05,
Introduction_05_post,
Introduction_06,
Introduction_06_post,
Dungeon_Entrance
}
static var state_dict = {}
@ -110,6 +123,22 @@ func _process(delta):
update_text(intro_text_02, StateT.Introduction_02_post)
StateT.Introduction_02_post:
pass
StateT.Introduction_03:
update_text(intro_text_03, StateT.Introduction_03_post)
StateT.Introduction_03_post:
pass
StateT.Introduction_04:
update_text(intro_text_04, StateT.Introduction_04_post)
StateT.Introduction_04_post:
pass
StateT.Introduction_05:
update_text(intro_text_05, StateT.Introduction_05_post)
StateT.Introduction_05_post:
pass
StateT.Introduction_06:
update_text(intro_text_06, StateT.Introduction_06_post)
StateT.Introduction_06_post:
pass
_:
pass
@ -153,6 +182,51 @@ func _unhandled_input(event):
state_dict["timer"] = 0.0
state_dict["text_idx"] = 0
main_label.text = intro_text_02
StateT.Introduction_02_post:
state_dict["state"] = StateT.Introduction_03
state_dict["timer"] = 0.0
state_dict["text_idx"] = 0
main_label.text = ""
StateT.Introduction_03:
state_dict["state"] = StateT.Introduction_03_post
state_dict["timer"] = 0.0
state_dict["text_idx"] = 0
main_label.text = intro_text_03
StateT.Introduction_03_post:
state_dict["state"] = StateT.Introduction_04
state_dict["timer"] = 0.0
state_dict["text_idx"] = 0
main_label.text = ""
StateT.Introduction_04:
state_dict["state"] = StateT.Introduction_04_post
state_dict["timer"] = 0.0
state_dict["text_idx"] = 0
main_label.text = intro_text_04
StateT.Introduction_04_post:
state_dict["state"] = StateT.Introduction_05
state_dict["timer"] = 0.0
state_dict["text_idx"] = 0
main_label.text = ""
StateT.Introduction_05:
state_dict["state"] = StateT.Introduction_05_post
state_dict["timer"] = 0.0
state_dict["text_idx"] = 0
main_label.text = intro_text_05
StateT.Introduction_05_post:
state_dict["state"] = StateT.Introduction_06
state_dict["timer"] = 0.0
state_dict["text_idx"] = 0
main_label.text = ""
StateT.Introduction_06:
state_dict["state"] = StateT.Introduction_06_post
state_dict["timer"] = 0.0
state_dict["text_idx"] = 0
main_label.text = intro_text_06
StateT.Introduction_06_post:
state_dict["state"] = StateT.Dungeon_Entrance
state_dict["timer"] = 0.0
state_dict["text_idx"] = 0
main_label.text = ""
_:
pass

48
gander_schwartz.gd Normal file
View file

@ -0,0 +1,48 @@
extends CharacterBody2D
@onready var animated = $AnimatedSprite2D
const SPEED = 150.0
const ANIM_DEADZONE = 0.3
func _physics_process(delta):
var vec2 = Vector2()
if Input.is_action_pressed("Left"):
vec2.x = -1.0
elif Input.is_action_pressed("Right"):
vec2.x = 1.0
if Input.is_action_pressed("Up"):
vec2.y = -1.0
elif Input.is_action_pressed("Down"):
vec2.y = 1.0
if vec2.length() > 0.1:
vec2 = vec2.normalized()
else:
vec2.x = 0.0
vec2.y = 0.0
if vec2.x > ANIM_DEADZONE:
animated.play("walking_right")
elif vec2.x < -ANIM_DEADZONE:
animated.play("walking_left")
elif vec2.y > ANIM_DEADZONE:
animated.play("walking_front")
elif vec2.y < -ANIM_DEADZONE:
animated.play("walking_back")
else:
match animated.animation:
"walking_right":
animated.play("facing_right")
"walking_left":
animated.play("facing_left")
"walking_front":
animated.play("facing_front")
"walking_back":
animated.play("facing_back")
_:
pass
velocity = vec2 * SPEED
move_and_slide()

View file

@ -1,5 +1,6 @@
[gd_scene load_steps=19 format=3 uid="uid://ktxqc7xtqkex"]
[gd_scene load_steps=21 format=3 uid="uid://ktxqc7xtqkex"]
[ext_resource type="Script" path="res://gander_schwartz.gd" id="1_6ob4s"]
[ext_resource type="Texture2D" uid="uid://cv0qw4j1q78r8" path="res://gimp/GanderSchwartz_spritesheet.png" id="1_n7bds"]
[sub_resource type="AtlasTexture" id="AtlasTexture_mj0lb"]
@ -157,14 +158,23 @@ animations = [{
"speed": 5.0
}]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_u3k2h"]
radius = 15.0
height = 80.0
[node name="GanderSchwartz" type="CharacterBody2D"]
motion_mode = 1
script = ExtResource("1_6ob4s")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
texture_filter = 1
position = Vector2(0, -24)
position = Vector2(0, -51)
scale = Vector2(2.11, 2.11)
sprite_frames = SubResource("SpriteFrames_i348s")
animation = &"walking_front"
frame = 3
frame_progress = 0.126405
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, -40)
shape = SubResource("CapsuleShape2D_u3k2h")

BIN
gimp/DungeonEntrance.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://npjqgc3tdgs1"
path="res://.godot/imported/DungeonEntrance.png-d5377cb906979b90475313ef20f7ee37.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://gimp/DungeonEntrance.png"
dest_files=["res://.godot/imported/DungeonEntrance.png-d5377cb906979b90475313ef20f7ee37.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
gimp/DungeonGuard.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 752 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://nocjsuuft8qx"
path="res://.godot/imported/DungeonGuard.png-dc8dcbb58e4d6814aac7a93a7908bbc9.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://gimp/DungeonGuard.png"
dest_files=["res://.godot/imported/DungeonGuard.png-dc8dcbb58e4d6814aac7a93a7908bbc9.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View file

@ -13,14 +13,14 @@ script = ExtResource("1_43no1")
[node name="Camera2D" type="Camera2D" parent="."]
[node name="MainLabel" type="Label" parent="Camera2D"]
z_index = 1
z_index = 5
offset_left = -277.0
offset_top = -96.0
offset_right = 278.0
offset_bottom = 97.0
[node name="LowerLabel" type="Label" parent="Camera2D"]
z_index = 1
z_index = 5
offset_left = -237.0
offset_top = 101.0
offset_right = 239.0