Rendering how I want for now

This commit is contained in:
2025-11-28 15:11:58 -06:00
parent d532a9ab21
commit 5573ad815f
15 changed files with 199 additions and 376 deletions

View File

@@ -1,8 +1,8 @@
{ {
"godotTools.editorPath.godot4": "/var/lib/flatpak/app/org.godotengine.Godot/current/active/export/bin/org.godotengine.Godot", "godotTools.editorPath.godot4": "/var/lib/flatpak/app/org.godotengine.Godot/current/active/export/bin/org.godotengine.Godot",
"terminal.integrated.tabs.enabled": false, "terminal.integrated.tabs.enabled": false,
"editor.insertSpaces": false, "editor.insertSpaces": true,
"editor.tabSize": 4, "editor.tabSize": 2,
"files.exclude": { "files.exclude": {
"**/*.uid": true "**/*.uid": true
}, },

View File

@@ -4,29 +4,29 @@ var items:Array[CutsceneItem] = []
var itemIndex:int = 0 var itemIndex:int = 0
func _enter_tree() -> void: func _enter_tree() -> void:
# Get children # Get children
var children = get_children() var children = get_children()
for child in children: for child in children:
if !(child is CutsceneItem): if !(child is CutsceneItem):
continue continue
items.append(child) items.append(child)
pass pass
func _exit_tree() -> void: func _exit_tree() -> void:
items.clear() items.clear()
pass pass
func start() -> void: func start() -> void:
itemIndex = -1 itemIndex = -1
if items.size() == 0: if items.size() == 0:
return return
nextItem() nextItem()
func nextItem() -> void: func nextItem() -> void:
itemIndex += 1 itemIndex += 1
if itemIndex >= items.size(): if itemIndex >= items.size():
return return
var item = items[itemIndex] var item = items[itemIndex]
item.cutscene = self item.cutscene = self
item.start() item.start()

View File

@@ -4,21 +4,21 @@ class_name CutsceneText extends CutsceneItem
var nextTextIndex:int = 0 var nextTextIndex:int = 0
func _enter_tree() -> void: func _enter_tree() -> void:
pass pass
func _exit_tree() -> void: func _exit_tree() -> void:
UI.TEXTBOX.textboxClosing.disconnect(onTextboxClosing) UI.TEXTBOX.textboxClosing.disconnect(onTextboxClosing)
func start() -> void: func start() -> void:
nextTextIndex = 0 nextTextIndex = 0
UI.TEXTBOX.setText(interactTexts[nextTextIndex]) UI.TEXTBOX.setText(interactTexts[nextTextIndex])
UI.TEXTBOX.textboxClosing.connect(onTextboxClosing) UI.TEXTBOX.textboxClosing.connect(onTextboxClosing)
func onTextboxClosing() -> void: func onTextboxClosing() -> void:
nextTextIndex += 1 nextTextIndex += 1
if nextTextIndex < interactTexts.size(): if nextTextIndex < interactTexts.size():
UI.TEXTBOX.setText(interactTexts[nextTextIndex]) UI.TEXTBOX.setText(interactTexts[nextTextIndex])
else: else:
UI.TEXTBOX.textboxClosing.disconnect(onTextboxClosing) UI.TEXTBOX.textboxClosing.disconnect(onTextboxClosing)
UI.TEXTBOX.setText("") UI.TEXTBOX.setText("")
done() done()

View File

@@ -2,82 +2,20 @@
class_name EntityMovement extends Node class_name EntityMovement extends Node
const FRICTION = 0.01 const FRICTION = 0.01
const WALK_SPEED_DEFAULT = 8
enum FacingDirection { const RUN_SPEED_DEFAULT = 12
SOUTH = 0,
EAST = 1,
NORTH = 2,
WEST = 3
};
const FacingDirWalkAnimations = {
FacingDirection.SOUTH: "walk_south",
FacingDirection.EAST: "walk_east",
FacingDirection.NORTH: "walk_north",
FacingDirection.WEST: "walk_west"
};
const FacingDirAngle = {
FacingDirection.SOUTH: 0.0,
FacingDirection.EAST: PI / 2,
FacingDirection.NORTH: PI,
FacingDirection.WEST: -PI / 2
};
var _inputDir:Vector2 = Vector2.ZERO var _inputDir:Vector2 = Vector2.ZERO
var _facingDir:FacingDirection = FacingDirection.SOUTH
var _running:bool = false var _running:bool = false
@export var body:CharacterBody3D @export var body:CharacterBody3D
@export var rotate:Node3D @export var rotate:Node3D
@export var sprite:AnimatedSprite3D @export var walkSpeed:float = WALK_SPEED_DEFAULT
@export var walkSpeed:float = 48.0 @export var runSpeed:float = RUN_SPEED_DEFAULT
@export var runSpeed:float = 64.0
@export var facingDir:FacingDirection = FacingDirection.SOUTH:
set(value):
_facingDir = value
_updateSprite()
get:
return _facingDir
# #
# Private Methods # Private Methods
# #
func _updateSprite() -> void:
if !sprite || sprite.animation == FacingDirWalkAnimations[facingDir]:
return
sprite.animation = FacingDirWalkAnimations[facingDir]
func _applyFacingDir() -> void:
if !sprite || _inputDir.length() <= 0.01:
return
if _inputDir.y > 0:
if facingDir != FacingDirection.NORTH && _inputDir.x != 0:
if _inputDir.x > 0 && facingDir == FacingDirection.EAST:
facingDir = FacingDirection.EAST
elif _inputDir.x < 0 && facingDir == FacingDirection.WEST:
facingDir = FacingDirection.WEST
else:
facingDir = FacingDirection.NORTH
else:
facingDir = FacingDirection.NORTH
elif _inputDir.y < 0:
if facingDir != FacingDirection.SOUTH && _inputDir.x != 0:
if _inputDir.x > 0 && facingDir == FacingDirection.EAST:
facingDir = FacingDirection.EAST
elif _inputDir.x < 0 && facingDir == FacingDirection.WEST:
facingDir = FacingDirection.WEST
else:
facingDir = FacingDirection.SOUTH
else:
facingDir = FacingDirection.SOUTH
elif _inputDir.x > 0:
facingDir = FacingDirection.EAST
else:
facingDir = FacingDirection.WEST
func _applyGravity() -> void: func _applyGravity() -> void:
if !body.is_on_floor(): if !body.is_on_floor():
body.velocity += PHYSICS.GRAVITY * get_process_delta_time() body.velocity += PHYSICS.GRAVITY * get_process_delta_time()
@@ -132,7 +70,7 @@ func canMove() -> bool:
# Callbacks # Callbacks
# #
func _enter_tree() -> void: func _enter_tree() -> void:
_updateSprite() pass
func _physics_process(delta:float) -> void: func _physics_process(delta:float) -> void:
if Engine.is_editor_hint(): if Engine.is_editor_hint():
@@ -144,5 +82,4 @@ func _physics_process(delta:float) -> void:
_applyGravity() _applyGravity()
_applyFriction(delta) _applyFriction(delta)
_applyMovement() _applyMovement()
_applyFacingDir()
body.move_and_slide() body.move_and_slide()

View File

@@ -3,15 +3,6 @@ class_name NPC extends CharacterBody3D
@export var _movement:NPCMovement @export var _movement:NPCMovement
@export var facingDirection:EntityMovement.FacingDirection:
set(value):
if _movement:
_movement.facingDir = value
get:
if _movement:
return _movement.facingDir
return EntityMovement.FacingDirection.SOUTH
@export var walkSpeed:float = 48.0: @export var walkSpeed:float = 48.0:
set(value): set(value):
if _movement: if _movement:

View File

@@ -1,96 +1,48 @@
[gd_scene load_steps=12 format=3 uid="uid://kabs7mopalmo"] [gd_scene load_steps=8 format=3 uid="uid://kabs7mopalmo"]
[ext_resource type="Script" uid="uid://crw7ls7t8cwct" path="res://entity/npc/NPC.gd" id="1_00k55"] [ext_resource type="Script" uid="uid://crw7ls7t8cwct" path="res://entity/npc/NPC.gd" id="1_00k55"]
[ext_resource type="Script" uid="uid://b00rxpveu3v4m" path="res://InteractableArea.gd" id="2_x8luf"] [ext_resource type="Script" uid="uid://b00rxpveu3v4m" path="res://InteractableArea.gd" id="2_x8luf"]
[ext_resource type="Script" uid="uid://tlfthv88ki0y" path="res://entity/npc/NPCMovement.gd" id="3_1seh5"] [ext_resource type="Script" uid="uid://tlfthv88ki0y" path="res://entity/npc/NPCMovement.gd" id="3_1seh5"]
[ext_resource type="Texture2D" uid="uid://xx3qp5xh7tgu" path="res://entity/player/Player.png" id="4_x8luf"]
[sub_resource type="BoxShape3D" id="BoxShape3D_1seh5"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_jphom"]
size = Vector3(16, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_rl6fg"] [sub_resource type="BoxShape3D" id="BoxShape3D_jphom"]
atlas = ExtResource("4_x8luf") size = Vector3(1, 2, 1)
region = Rect2(16, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_q57vx"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_jphom"]
atlas = ExtResource("4_x8luf") shading_mode = 0
region = Rect2(48, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_ak4un"] [sub_resource type="CapsuleMesh" id="CapsuleMesh_jphom"]
atlas = ExtResource("4_x8luf") material = SubResource("StandardMaterial3D_jphom")
region = Rect2(0, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_1ms0h"]
atlas = ExtResource("4_x8luf")
region = Rect2(32, 0, 16, 16)
[sub_resource type="SpriteFrames" id="SpriteFrames_1seh5"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_rl6fg")
}],
"loop": true,
"name": &"walk_east",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_q57vx")
}],
"loop": true,
"name": &"walk_north",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_ak4un")
}],
"loop": true,
"name": &"walk_south",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_1ms0h")
}],
"loop": true,
"name": &"walk_west",
"speed": 5.0
}]
[sub_resource type="SphereShape3D" id="SphereShape3D_x8luf"]
radius = 8.5
[node name="NPC" type="CharacterBody3D" node_paths=PackedStringArray("_movement")] [node name="NPC" type="CharacterBody3D" node_paths=PackedStringArray("_movement")]
script = ExtResource("1_00k55") script = ExtResource("1_00k55")
facingDirection = null
walkSpeed = null
runSpeed = null
_movement = NodePath("Scripts/NPCMovement") _movement = NodePath("Scripts/NPCMovement")
[node name="Scripts" type="Node" parent="."] [node name="Scripts" type="Node" parent="."]
[node name="NPCMovement" type="Node" parent="Scripts" node_paths=PackedStringArray("body", "sprite")] [node name="NPCMovement" type="Node" parent="Scripts" node_paths=PackedStringArray("body")]
script = ExtResource("3_1seh5") script = ExtResource("3_1seh5")
body = NodePath("../..") body = NodePath("../..")
sprite = NodePath("../../AnimatedSprite3D")
[node name="InteractableArea" type="Area3D" parent="."] [node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("CapsuleShape3D_jphom")
[node name="Rotate" type="Node3D" parent="."]
[node name="InteractableArea" type="Area3D" parent="Rotate"]
script = ExtResource("2_x8luf") script = ExtResource("2_x8luf")
metadata/_custom_type_script = "uid://b00rxpveu3v4m" metadata/_custom_type_script = "uid://b00rxpveu3v4m"
[node name="CollisionShape3D" type="CollisionShape3D" parent="InteractableArea"] [node name="InteractableShape" type="CollisionShape3D" parent="Rotate/InteractableArea"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 8, 0) transform = Transform3D(0.999999, -0.000856732, 0.0007724, 0.000857588, 0.999999, -0.00114162, -0.000771449, 0.00114226, 0.999999, 0, 0, 0)
shape = SubResource("BoxShape3D_1seh5") shape = SubResource("BoxShape3D_jphom")
[node name="AnimatedSprite3D" type="AnimatedSprite3D" parent="."] [node name="CapsuleMesh" type="MeshInstance3D" parent="Rotate"]
pixel_size = 1.0 mesh = SubResource("CapsuleMesh_jphom")
axis = 1 skeleton = NodePath("../..")
double_sided = false
texture_filter = 0
sprite_frames = SubResource("SpriteFrames_1seh5")
animation = &"walk_south"
[node name="CollisionShape3D" type="CollisionShape3D" parent="."] [connection signal="interactEvent" from="Rotate/InteractableArea" to="." method="onInteract"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 8.5, 0)
shape = SubResource("SphereShape3D_x8luf")
[connection signal="interactEvent" from="InteractableArea" to="." method="onInteract"]

View File

@@ -3,29 +3,20 @@ class_name Player extends CharacterBody3D
@export var _movement:PlayerMovement @export var _movement:PlayerMovement
@export var facingDirection:EntityMovement.FacingDirection: @export var walkSpeed:float = EntityMovement.WALK_SPEED_DEFAULT:
set(value):
if _movement:
_movement.facingDir = value
get:
if _movement:
return _movement.facingDir
return EntityMovement.FacingDirection.SOUTH
@export var walkSpeed:float = 48.0:
set(value): set(value):
if _movement: if _movement:
_movement.walkSpeed = value _movement.walkSpeed = value
get: get:
if _movement: if _movement:
return _movement.walkSpeed return _movement.walkSpeed
return 48.0 return EntityMovement.WALK_SPEED_DEFAULT
@export var runSpeed:float = 64.0: @export var runSpeed:float = EntityMovement.RUN_SPEED_DEFAULT:
set(value): set(value):
if _movement: if _movement:
_movement.runSpeed = value _movement.runSpeed = value
get: get:
if _movement: if _movement:
return _movement.runSpeed return _movement.runSpeed
return 64.0 return EntityMovement.RUN_SPEED_DEFAULT

View File

@@ -1,68 +1,29 @@
[gd_scene load_steps=14 format=3 uid="uid://2ch34sio36nv"] [gd_scene load_steps=12 format=3 uid="uid://2ch34sio36nv"]
[ext_resource type="Script" uid="uid://ylmy3nvpirgr" path="res://entity/player/Player.gd" id="1_24gqh"] [ext_resource type="Script" uid="uid://ylmy3nvpirgr" path="res://entity/player/Player.gd" id="1_24gqh"]
[ext_resource type="Script" uid="uid://bwxdv3kxrs4oj" path="res://entity/player/PlayerMovement.gd" id="2_o7et6"] [ext_resource type="Script" uid="uid://bwxdv3kxrs4oj" path="res://entity/player/PlayerMovement.gd" id="2_o7et6"]
[ext_resource type="Script" uid="uid://b3nty7pvbo58d" path="res://entity/player/PlayerInteraction.gd" id="3_24gqh"] [ext_resource type="Script" uid="uid://b3nty7pvbo58d" path="res://entity/player/PlayerInteraction.gd" id="3_24gqh"]
[ext_resource type="Script" uid="uid://bdv1fj1pwknrs" path="res://entity/player/PlayerInput.gd" id="4_yjynp"] [ext_resource type="Script" uid="uid://bdv1fj1pwknrs" path="res://entity/player/PlayerInput.gd" id="4_yjynp"]
[ext_resource type="Script" uid="uid://bdjgvyiacbg28" path="res://entity/player/PlayerCamera.gd" id="5_g3lhm"] [ext_resource type="Script" uid="uid://bdjgvyiacbg28" path="res://entity/player/PlayerCamera.gd" id="5_g3lhm"]
[ext_resource type="Texture2D" uid="uid://xx3qp5xh7tgu" path="res://entity/player/Player.png" id="7_fmb3c"]
[sub_resource type="SphereShape3D" id="SphereShape3D_4pwj0"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_rykwh"]
radius = 8.5
[sub_resource type="AtlasTexture" id="AtlasTexture_rl6fg"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_rykwh"]
atlas = ExtResource("7_fmb3c") shading_mode = 0
region = Rect2(16, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_q57vx"] [sub_resource type="CapsuleMesh" id="CapsuleMesh_etv1g"]
atlas = ExtResource("7_fmb3c") material = SubResource("StandardMaterial3D_rykwh")
region = Rect2(48, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_ak4un"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_etv1g"]
atlas = ExtResource("7_fmb3c") shading_mode = 0
region = Rect2(0, 0, 16, 16) albedo_color = Color(0.376471, 1, 1, 1)
[sub_resource type="AtlasTexture" id="AtlasTexture_1ms0h"] [sub_resource type="BoxMesh" id="BoxMesh_m44ds"]
atlas = ExtResource("7_fmb3c") material = SubResource("StandardMaterial3D_etv1g")
region = Rect2(32, 0, 16, 16) size = Vector3(0.4, 0.4, 0.4)
[sub_resource type="SpriteFrames" id="SpriteFrames_2rv2u"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_rl6fg")
}],
"loop": true,
"name": &"walk_east",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_q57vx")
}],
"loop": true,
"name": &"walk_north",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_ak4un")
}],
"loop": true,
"name": &"walk_south",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_1ms0h")
}],
"loop": true,
"name": &"walk_west",
"speed": 5.0
}]
[sub_resource type="BoxShape3D" id="BoxShape3D_g13of"] [sub_resource type="BoxShape3D" id="BoxShape3D_g13of"]
size = Vector3(10, 16, 8) size = Vector3(1.14069, 1, 1.38867)
[node name="Player" type="CharacterBody3D" node_paths=PackedStringArray("_movement")] [node name="Player" type="CharacterBody3D" node_paths=PackedStringArray("_movement")]
script = ExtResource("1_24gqh") script = ExtResource("1_24gqh")
@@ -70,15 +31,14 @@ _movement = NodePath("Scripts/PlayerMovement")
[node name="Scripts" type="Node" parent="."] [node name="Scripts" type="Node" parent="."]
[node name="PlayerMovement" type="Node" parent="Scripts" node_paths=PackedStringArray("body", "rotate", "sprite")] [node name="PlayerMovement" type="Node" parent="Scripts" node_paths=PackedStringArray("body", "rotate")]
script = ExtResource("2_o7et6") script = ExtResource("2_o7et6")
body = NodePath("../..") body = NodePath("../..")
rotate = NodePath("../../PlayerRotated") rotate = NodePath("../../PlayerRotate")
sprite = NodePath("../../AnimatedSprite3D")
[node name="PlayerInteraction" type="Node" parent="Scripts" node_paths=PackedStringArray("interactableArea", "player")] [node name="PlayerInteraction" type="Node" parent="Scripts" node_paths=PackedStringArray("interactableArea", "player")]
script = ExtResource("3_24gqh") script = ExtResource("3_24gqh")
interactableArea = NodePath("../../PlayerRotated/PlayerInteractableArea") interactableArea = NodePath("../../PlayerRotate/PlayerInteractableArea")
player = NodePath("../..") player = NodePath("../..")
[node name="PlayerInput" type="Node" parent="Scripts" node_paths=PackedStringArray("interaction", "movement")] [node name="PlayerInput" type="Node" parent="Scripts" node_paths=PackedStringArray("interaction", "movement")]
@@ -92,24 +52,23 @@ camera = NodePath("../../PlayerCamera")
target = NodePath("../..") target = NodePath("../..")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."] [node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 8.5, 0) shape = SubResource("CapsuleShape3D_rykwh")
shape = SubResource("SphereShape3D_4pwj0")
[node name="PlayerCamera" type="Camera3D" parent="."] [node name="PlayerCamera" type="Camera3D" parent="."]
transform = Transform3D(1, -0.000461383, 0.000263726, 0.000138582, 0.705475, 0.708735, -0.00051305, -0.708735, 0.705475, 0.00619125, 4.26114, 4.36711)
[node name="AnimatedSprite3D" type="AnimatedSprite3D" parent="."] [node name="PlayerRotate" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0496178, 0, -0.00852585)
pixel_size = 1.0
axis = 1
double_sided = false
texture_filter = 0
sprite_frames = SubResource("SpriteFrames_2rv2u")
animation = &"walk_south"
[node name="PlayerRotated" type="Node3D" parent="."] [node name="CapsuleMesh" type="MeshInstance3D" parent="PlayerRotate"]
mesh = SubResource("CapsuleMesh_etv1g")
skeleton = NodePath("../..")
[node name="PlayerInteractableArea" type="Area3D" parent="PlayerRotated"] [node name="MeshInstance3D" type="MeshInstance3D" parent="PlayerRotate/CapsuleMesh"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.41166, 0.475431)
mesh = SubResource("BoxMesh_m44ds")
[node name="CollisionShape3D" type="CollisionShape3D" parent="PlayerRotated/PlayerInteractableArea"] [node name="PlayerInteractableArea" type="Area3D" parent="PlayerRotate"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 8, 10)
[node name="InteractHitbox" type="CollisionShape3D" parent="PlayerRotate/PlayerInteractableArea"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0233459, 0, 0.795664)
shape = SubResource("BoxShape3D_g13of") shape = SubResource("BoxShape3D_g13of")

View File

@@ -6,28 +6,22 @@ const CAMERA_PIXEL_SCALE = 1.0
@export var camera:Camera3D = null @export var camera:Camera3D = null
@export var target:Node3D = null @export var target:Node3D = null
@export var offset:Vector3 = Vector3(0, 0, 12)
var angle = 0.0
func _process(delta: float) -> void: func _process(delta: float) -> void:
if !camera || !target: if !camera || !target:
return return
# I tried a few things but this is most consistent for both backbuffer and # Follow target
# framebuffer viewports. # camera.global_transform.origin = target.global_transform.origin
var viewportHeight = get_viewport().get_visible_rect().size.y;
var unitScale = CAMERA_PIXEL_SCALE * CAMERA_PIXELS_PER_UNIT;
var z:float = ( # # Spin around origin.
tan((deg_to_rad(180) - deg_to_rad(camera.fov)) / 2.0) * # var rotation_speed = 1 # Radians per second
(viewportHeight / 2.0) # angle += rotation_speed * delta
) / unitScale; # var radius = 3.0
# var offset = Vector3(radius * sin(angle), 2.0, radius * cos(angle))
# camera.global_transform.origin += offset
var look = target.global_position; # # Look at target
var position = offset + look; # camera.look_at(target.global_transform.origin, Vector3.UP)
camera.look_at_from_position(
Vector3(position.x, position.y + z, position.z),
look
);
pass

View File

@@ -11,8 +11,9 @@ script = ExtResource("1_6ms5s")
[node name="TestMapBase" parent="." instance=ExtResource("1_ox0si")] [node name="TestMapBase" parent="." instance=ExtResource("1_ox0si")]
[node name="Player" parent="." instance=ExtResource("2_0d2qr")] [node name="Player" parent="." instance=ExtResource("2_0d2qr")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 8.04397, 1.9488, -16.5251) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 11.5777, 1.74123, 0)
facingDirection = 1
[node name="NPC" parent="." instance=ExtResource("3_0vfw4")] [node name="NPC" parent="." instance=ExtResource("3_0vfw4")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.30029, 4.06806, 0.563562) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 9.3026, 1.9909, -2.12904)
walkSpeed = 48.0
runSpeed = 64.0

View File

@@ -35,10 +35,9 @@ gdscript/warnings/shadowed_variable=0
window/size/viewport_width=480 window/size/viewport_width=480
window/size/viewport_height=270 window/size/viewport_height=270
window/size/window_width_override=960 window/size/window_width_override=1440
window/size/window_height_override=540 window/size/window_height_override=810
window/stretch/mode="viewport" window/stretch/mode="canvas_items"
window/stretch/scale_mode="integer"
[dotnet] [dotnet]

View File

@@ -8,25 +8,25 @@ signal loadProgress(scenePath:String, loadId:int, progress:float)
var watchingIds:Array[int] = [] var watchingIds:Array[int] = []
func _process(delta: float) -> void: func _process(delta: float) -> void:
var wIds = watchingIds.duplicate() var wIds = watchingIds.duplicate()
for watchId in wIds: for watchId in wIds:
var status = ResourceLoader.load_threaded_get_status(watchId) var status = ResourceLoader.load_threaded_get_status(watchId)
if status == ResourceLoader.ThreadLoadStatus.THREAD_LOAD_LOADED: if status == ResourceLoader.ThreadLoadStatus.THREAD_LOAD_LOADED:
watchingIds.erase(watchId) watchingIds.erase(watchId)
var resource = ResourceLoader.load_threaded_get(watchId) var resource = ResourceLoader.load_threaded_get(watchId)
loadEnd.emit(watchId, resource) loadEnd.emit(watchId, resource)
elif status == ResourceLoader.ThreadLoadStatus.THREAD_LOAD_FAILED: elif status == ResourceLoader.ThreadLoadStatus.THREAD_LOAD_FAILED:
watchingIds.erase(watchId) watchingIds.erase(watchId)
loadError.emit(watchId, "Error loading resource.") loadError.emit(watchId, "Error loading resource.")
elif status == ResourceLoader.ThreadLoadStatus.THREAD_LOAD_INVALID_RESOURCE: elif status == ResourceLoader.ThreadLoadStatus.THREAD_LOAD_INVALID_RESOURCE:
watchingIds.erase(watchId) watchingIds.erase(watchId)
loadError.emit(watchId, "Invalid Resource.") loadError.emit(watchId, "Invalid Resource.")
elif status == ResourceLoader.ThreadLoadStatus.THREAD_LOAD_IN_PROGRESS: elif status == ResourceLoader.ThreadLoadStatus.THREAD_LOAD_IN_PROGRESS:
loadProgress.emit(watchId, 0.0) loadProgress.emit(watchId, 0.0)
pass pass
func load(scenePath:String) -> int: func load(scenePath:String) -> int:
var loadId = ResourceLoader.load_threaded_request(scenePath) var loadId = ResourceLoader.load_threaded_request(scenePath)
watchingIds.append(loadId) watchingIds.append(loadId)
loadStart.emit(scenePath, loadId) loadStart.emit(scenePath, loadId)
return loadId return loadId

View File

@@ -1,19 +1,19 @@
class_name SceneSingleton extends Node class_name SceneSingleton extends Node
enum SceneType { enum SceneType {
UNSET, UNSET,
INITIAL, INITIAL,
OVERWORLD OVERWORLD
} }
var currentScene:SceneType = SceneType.UNSET var currentScene:SceneType = SceneType.UNSET
signal sceneChanged(newScene:SceneType) signal sceneChanged(newScene:SceneType)
func _enter_tree() -> void: func _enter_tree() -> void:
currentScene = SceneType.UNSET currentScene = SceneType.UNSET
func setScene(newScene:SceneType) -> void: func setScene(newScene:SceneType) -> void:
if currentScene == newScene: if currentScene == newScene:
return return
currentScene = newScene currentScene = newScene
sceneChanged.emit(currentScene) sceneChanged.emit(currentScene)

View File

@@ -1,9 +1,9 @@
class_name TransitionSingleton extends Control class_name TransitionSingleton extends Control
enum FadeType { enum FadeType {
NONE, NONE,
FADE_IN, FADE_IN,
FADE_OUT FADE_OUT
} }
signal fadeOutStart signal fadeOutStart
@@ -18,64 +18,64 @@ var fadeTime:float = 0.0
var inFade = false var inFade = false
func _enter_tree() -> void: func _enter_tree() -> void:
$Overlay.visible = false $Overlay.visible = false
func _process(delta: float) -> void: func _process(delta: float) -> void:
if fadeType == FadeType.NONE: if fadeType == FadeType.NONE:
return return
fadeTime += delta fadeTime += delta
var t:float = fadeTime / fadeDuration var t:float = fadeTime / fadeDuration
# Get destination alpha type. # Get destination alpha type.
var destAlpha:float = 0.0 var destAlpha:float = 0.0
var srcAlpha:float var srcAlpha:float
if fadeType == FadeType.FADE_IN: if fadeType == FadeType.FADE_IN:
srcAlpha = 1.0 srcAlpha = 1.0
destAlpha = 0.0 destAlpha = 0.0
elif fadeType == FadeType.FADE_OUT: elif fadeType == FadeType.FADE_OUT:
srcAlpha = 0.0 srcAlpha = 0.0
destAlpha = 1.0 destAlpha = 1.0
# End? # End?
if t >= 1.0: if t >= 1.0:
fadeUpdate.emit(1.0) fadeUpdate.emit(1.0)
var cFade = fadeType var cFade = fadeType
fadeType = FadeType.NONE fadeType = FadeType.NONE
$Overlay.color.a = destAlpha $Overlay.color.a = destAlpha
inFade = false inFade = false
if cFade == FadeType.FADE_OUT: if cFade == FadeType.FADE_OUT:
fadeOutEnd.emit() fadeOutEnd.emit()
elif cFade == FadeType.FADE_IN: elif cFade == FadeType.FADE_IN:
fadeInEnd.emit() fadeInEnd.emit()
return return
# TODO: Use curves # TODO: Use curves
$Overlay.color.a = srcAlpha + (destAlpha - srcAlpha) * t $Overlay.color.a = srcAlpha + (destAlpha - srcAlpha) * t
fadeUpdate.emit(t) fadeUpdate.emit(t)
pass pass
func fade( func fade(
fade:FadeType = FadeType.FADE_IN, fade:FadeType = FadeType.FADE_IN,
duration:float = 0.4, duration:float = 0.4,
color:Color = Color(0, 0, 0, 1), color:Color = Color(0, 0, 0, 1),
): ):
if inFade: if inFade:
push_error("Transition: Cannot start a new fade while another is in progress.") push_error("Transition: Cannot start a new fade while another is in progress.")
return return
$Overlay.visible = true $Overlay.visible = true
$Overlay.color = color $Overlay.color = color
fadeDuration = duration fadeDuration = duration
fadeTime = 0 fadeTime = 0
fadeType = fade fadeType = fade
inFade = true inFade = true
if fade == FadeType.FADE_IN: if fade == FadeType.FADE_IN:
fadeInStart.emit() fadeInStart.emit()
$Overlay.color.a = 0 $Overlay.color.a = 0
elif fade == FadeType.FADE_OUT: elif fade == FadeType.FADE_OUT:
fadeOutStart.emit() fadeOutStart.emit()
$Overlay.color.a = 1 $Overlay.color.a = 1

View File

@@ -2,4 +2,3 @@ class_name UISingleton extends Control
@export var TEXTBOX: VNTextbox @export var TEXTBOX: VNTextbox
@export var PAUSE: PauseMenu @export var PAUSE: PauseMenu
@onready var MADTALK:Node = $VNTextbox/MadTalk;