Added player and a basic test level

This commit is contained in:
2026-02-06 16:00:03 -05:00
parent 1b0f1c9080
commit 83a4a8f374
104 changed files with 6897 additions and 0 deletions

11
utilities/Util.gd Normal file
View File

@@ -0,0 +1,11 @@
class_name Util
extends Node
#add effects
static func add_effect_to_self(node: Node, effect: PackedScene) -> void:
#instantiate the packed scene
var nodeInstance: Node = effect.instantiate()
#gets the nodes global postion and makes the node instance global position that
nodeInstance.global_position = node.global_position
#adds it to the scene
node.get_parent().add_child(nodeInstance)

1
utilities/Util.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://dwvep0kyhdgxt

14
utilities/debug.gd Normal file
View File

@@ -0,0 +1,14 @@
extends Node
#i have no idea why i have this i dont use it ever lol
func _unhandled_key_input(event: InputEvent) -> void:
var eventKey : InputEventKey = event
if event.is_pressed():
var key: int = eventKey.keycode
match key:
KEY_Q:
get_tree().quit()
KEY_R:
print_debug("reloading scene")
get_tree().reload_current_scene()

1
utilities/debug.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://cg56u0nxa13nw

View File

@@ -0,0 +1,19 @@
class_name NodeState
extends Node
@warning_ignore("unused_signal")
signal transition
@warning_ignore("unused_parameter")
func on_process(delta: float) -> void:
pass
@warning_ignore("unused_parameter")
func on_phyisics_process(delta: float) -> void:
pass
func enter() -> void:
pass
func exit() -> void:
pass

View File

@@ -0,0 +1 @@
uid://xjgib7bv7iw7

View File

@@ -0,0 +1,67 @@
class_name NodeStateMachine
extends Node
#TODO make it where the parent node will set it's self instead of each state needing export vars
#the state that the state machine will start with
@export var initialNodeState: NodeState
#the variables
var nodeState: Dictionary = {}
var currentNodeState: NodeState
var currentNodeStateName: String
func _ready() -> void:
#will get the all the states that are a chils of the state machine
for child in get_children():
#checks if the node is the correct type
if child is NodeState:
#adds the node to the node state dictonary
nodeState[child.name.to_lower()] = child
child.transition.connect(transition_to)
#checks if intial node was set
if initialNodeState:
#does the enter function for the starting state
initialNodeState.enter()
#sets the current state to inittal state
currentNodeState = initialNodeState
else:
#this is here cause im stupid and will forget to add the intial state
print_debug("you forgot to asign an initital node")
#both processes just does the states precesses functions
func _process(delta: float) -> void:
#print(currentNodeStateName)
if currentNodeState:
currentNodeState.on_process(delta)
func _physics_process(delta: float) -> void:
if currentNodeState:
currentNodeState.on_phyisics_process(delta)
#this function is called in the state machine controller
func transition_to(nodeStateName: String):
#this checks if the state that it's trying to switch to is the same as the current state
#if it's trying to switch to the same state it returns void
if nodeStateName == currentNodeState.name.to_lower():
return
#this gets the state that it's trying to switch to and puts it into a var
var newNodeState: NodeState = nodeState.get(nodeStateName.to_lower())
#if new node state is null it returns void
if !newNodeState:
return
#calls the exit function of the current state
if currentNodeState:
currentNodeState.exit()
#this calls the enter function in new state
newNodeState.enter()
#sets the current state to new state
currentNodeState = newNodeState
#this sets the current state name to the new state name
currentNodeStateName = currentNodeState.name.to_lower()

View File

@@ -0,0 +1 @@
uid://wohj0motyr3b