Compare commits
No commits in common. "041b26c2bd45cdf50117b22912f92b114c5d3484" and "762da40eec54feb6dbf63ab03c29fc080614754a" have entirely different histories.
041b26c2bd
...
762da40eec
19 changed files with 4 additions and 142 deletions
|
|
@ -1,7 +0,0 @@
|
||||||
@tool class_name RoomConfig extends Resource
|
|
||||||
|
|
||||||
|
|
||||||
@export var size: Vector2i = Vector2i.ZERO
|
|
||||||
@export var follow_player: bool = true
|
|
||||||
|
|
||||||
@export var camera_position: Vector2i = Vector2i.ZERO
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
uid://bamoq5wi0lkdy
|
|
||||||
|
|
@ -6,7 +6,7 @@ const DEADZONE = 0.1
|
||||||
@export var max_speed: float = 300.0
|
@export var max_speed: float = 300.0
|
||||||
|
|
||||||
@onready var sprite: AnimatedSprite2D = $AnimatedSprite2D
|
@onready var sprite: AnimatedSprite2D = $AnimatedSprite2D
|
||||||
@onready var state_machine: StateMachine = $PlayerStateMachine
|
@onready var state_machine: StateMachine = $StateMachine
|
||||||
|
|
||||||
var h_press_tick: int = 0 ## last time horizontal axis was pressed
|
var h_press_tick: int = 0 ## last time horizontal axis was pressed
|
||||||
var v_press_tick: int = 0 ## last time vertical axis was pressed
|
var v_press_tick: int = 0 ## last time vertical axis was pressed
|
||||||
|
|
|
||||||
|
|
@ -16,16 +16,16 @@ motion_mode = 1
|
||||||
script = ExtResource("1_dovo2")
|
script = ExtResource("1_dovo2")
|
||||||
max_speed = 95.0
|
max_speed = 95.0
|
||||||
|
|
||||||
[node name="PlayerStateMachine" type="Node" parent="." node_paths=PackedStringArray("initial_state")]
|
[node name="StateMachine" type="Node" parent="." node_paths=PackedStringArray("initial_state")]
|
||||||
script = ExtResource("2_lvxji")
|
script = ExtResource("2_lvxji")
|
||||||
initial_state = NodePath("Idle")
|
initial_state = NodePath("Idle")
|
||||||
metadata/_custom_type_script = "uid://diths5s8vd7lr"
|
metadata/_custom_type_script = "uid://diths5s8vd7lr"
|
||||||
|
|
||||||
[node name="Idle" type="Node" parent="PlayerStateMachine"]
|
[node name="Idle" type="Node" parent="StateMachine"]
|
||||||
script = ExtResource("3_p47bc")
|
script = ExtResource("3_p47bc")
|
||||||
metadata/_custom_type_script = "uid://bebe1y51hwns8"
|
metadata/_custom_type_script = "uid://bebe1y51hwns8"
|
||||||
|
|
||||||
[node name="Walking" type="Node" parent="PlayerStateMachine"]
|
[node name="Walking" type="Node" parent="StateMachine"]
|
||||||
script = ExtResource("4_p47bc")
|
script = ExtResource("4_p47bc")
|
||||||
metadata/_custom_type_script = "uid://bebe1y51hwns8"
|
metadata/_custom_type_script = "uid://bebe1y51hwns8"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
class_name Room extends Node2D
|
|
||||||
|
|
||||||
|
|
||||||
@export var room_config: RoomConfig
|
|
||||||
|
|
||||||
@onready var camera: RoomCamera = $RoomCamera
|
|
||||||
@onready var state_machine: StateMachine = $RoomStateMachine
|
|
||||||
|
|
||||||
var player_scene: PackedScene = preload("res://scenes/player/player.tscn")
|
|
||||||
|
|
||||||
var player: Player
|
|
||||||
var initial_spawn: Vector2i = Vector2i(16,16)
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
uid://pcl0om2k32g6
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
[gd_scene load_steps=8 format=3 uid="uid://bxhyxox662buj"]
|
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://pcl0om2k32g6" path="res://scenes/room/room.gd" id="1_8xru0"]
|
|
||||||
[ext_resource type="Script" uid="uid://bamoq5wi0lkdy" path="res://resources/room_config.gd" id="2_kxljb"]
|
|
||||||
[ext_resource type="Script" uid="uid://diou146pyb0br" path="res://scenes/room/room_camera.gd" id="3_y1kpu"]
|
|
||||||
[ext_resource type="Script" uid="uid://b7715auuhy7vu" path="res://scenes/room/states/room_starting.gd" id="4_1w8vm"]
|
|
||||||
[ext_resource type="Script" uid="uid://diths5s8vd7lr" path="res://classes/state_machine/state_machine.gd" id="4_vaubn"]
|
|
||||||
[ext_resource type="Script" uid="uid://d2xitfobwbk20" path="res://scenes/room/states/room_playing.gd" id="5_w7vtx"]
|
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_y1kpu"]
|
|
||||||
script = ExtResource("2_kxljb")
|
|
||||||
metadata/_custom_type_script = "uid://bamoq5wi0lkdy"
|
|
||||||
|
|
||||||
[node name="Room" type="Node2D"]
|
|
||||||
script = ExtResource("1_8xru0")
|
|
||||||
room_config = SubResource("Resource_y1kpu")
|
|
||||||
|
|
||||||
[node name="RoomStateMachine" type="Node" parent="." node_paths=PackedStringArray("initial_state")]
|
|
||||||
script = ExtResource("4_vaubn")
|
|
||||||
initial_state = NodePath("Starting")
|
|
||||||
metadata/_custom_type_script = "uid://diths5s8vd7lr"
|
|
||||||
|
|
||||||
[node name="Starting" type="Node" parent="RoomStateMachine"]
|
|
||||||
script = ExtResource("4_1w8vm")
|
|
||||||
metadata/_custom_type_script = "uid://hjm43hb4os07"
|
|
||||||
|
|
||||||
[node name="Playing" type="Node" parent="RoomStateMachine"]
|
|
||||||
script = ExtResource("5_w7vtx")
|
|
||||||
metadata/_custom_type_script = "uid://hjm43hb4os07"
|
|
||||||
|
|
||||||
[node name="RoomCamera" type="Camera2D" parent="."]
|
|
||||||
script = ExtResource("3_y1kpu")
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
class_name RoomCamera extends Camera2D
|
|
||||||
|
|
||||||
|
|
||||||
var room: Room
|
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
|
||||||
await owner.ready
|
|
||||||
room = owner as Room
|
|
||||||
assert(room != null, "The RoomCamera type must be used only in the room scene. It needs the owner to be a Room node.")
|
|
||||||
|
|
||||||
|
|
||||||
func follow_player(_delta: float) -> void:
|
|
||||||
global_position = room.player.global_position
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
uid://diou146pyb0br
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
class_name RoomState extends State
|
|
||||||
|
|
||||||
|
|
||||||
const ENTERING = "Entering"
|
|
||||||
const PLAYING = "Playing"
|
|
||||||
const EXITING = "Exiting"
|
|
||||||
|
|
||||||
var room: Room
|
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
|
||||||
await owner.ready
|
|
||||||
room = owner as Room
|
|
||||||
assert(room != null, "The RoomState state type must be used only in the room scene. It needs the owner's parent to be a Room node.")
|
|
||||||
|
|
||||||
|
|
||||||
func _enter(_previous_state_path: String, _data: Dictionary = {}) -> void:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
func _exit() -> void:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
func _handle_input(_event: InputEvent) -> void:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
func _state_update(_delta: float) -> void:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
func _state_physics_update(_delta: float) -> void:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
func match_state(exclude: Array[StringName] = []) -> StringName:
|
|
||||||
if Input.is_action_just_pressed("pause"):
|
|
||||||
if PAUSED in exclude: return ""
|
|
||||||
return PAUSED
|
|
||||||
|
|
||||||
return ""
|
|
||||||
|
|
||||||
|
|
||||||
func watch_state(exclude: Array[StringName] = [], data: Dictionary[StringName, Variant] = {}) -> bool:
|
|
||||||
var next_state: StringName = match_state(exclude)
|
|
||||||
if next_state != "":
|
|
||||||
finished.emit(next_state, data)
|
|
||||||
return true
|
|
||||||
|
|
||||||
return false
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
uid://hjm43hb4os07
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
extends RoomState
|
|
||||||
|
|
||||||
|
|
||||||
func _enter(_previous_state_path: String, _data: Dictionary = {}) -> void:
|
|
||||||
room.player = room.player_scene.instantiate()
|
|
||||||
room.add_child(room.player)
|
|
||||||
room.player.global_position = room.initial_spawn
|
|
||||||
|
|
||||||
finished.emit(PLAYING)
|
|
||||||
return
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
uid://b7715auuhy7vu
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
extends RoomState
|
|
||||||
|
|
||||||
|
|
||||||
func _state_physics_update(delta: float) -> void:
|
|
||||||
room.camera.follow_player(delta)
|
|
||||||
if match_state([PLAYING]): return
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
uid://d2xitfobwbk20
|
|
||||||
Loading…
Add table
Reference in a new issue