Need help getting started

Thanks Everyone. Love the advice and different perspectives. I have found some GDScript alternatives to C# practices. Getting there slowly.

State Machine - Example :

class_name GameManager

static var CurrentState : BaseState = TestState.new()

static func _process(delta):
	CurrentState.Update(delta)

static func ChangeState(newstate):
	CurrentState.Exit()
	CurrentState = newstate.new()
	CurrentState.Enter()

Database Management - Example :

class_name Database

static var Chest_List = {"Lv1_Chest1": false, "Lv1_Chest2": true}

static var DeathCount : int = 0

class_name TreasureChest
extends Node

@export var Item_ID : String

var Is_Chest_Open : bool :
	get : return Database.Chest_List[Item_ID]
	set(value) : Database.Chest_List[Item_ID] = value

class_name Enemy
extends Node

func EnemyDeath():
	Database.DeathCount += 1	
1 Like

I am pretty much interested to read the tutorial that introduces concepts in the order you’ve specified. If you’re going to write it based on what you’ll learn.

My guess is that Godot doesn’t provide any high level logic tools like that, so most of these things is custom coding.

interested in menu based stuff with gamepad, not mouse.

1 Like

I’ve pretty much established the foundation with the things above. The get/set really makes a difference when interacting with the database when searching for Enemy_ID, Furniture_ID, Player_IDs, etc.

Because when you change the data directly and use that same data in other classes, you don’t have to apply signals or get references to everything. You directly use the same data and keep things simple.

I basically blind searched google and stumbled upon things that looked familiar. They looked similar enough to #C for me to understand. Things that are static are more efficient overall. My state machines use those static references that are organized to make things simple and clean.

class_name GameState

static var CurrentState : BaseState = TestState.new()

static func _ready():
	CurrentState.Enter()

static func _physics_process(delta):
	CurrentState.Update(delta)

static func ChangeState(newstate):
	CurrentState.Exit()
	CurrentState = newstate.new()
	CurrentState.Enter()

This state machine is pretty simple and doesn’t overcomplicate things. You are basically creating a variable and that holds an entire class inside. So instead of using switch statements you make a class instead.

class_name BaseState

func Enter():
	# Perform Enter Animation
	# Enable State Controls
	pass
	
func Exit():
	# Disable State Controls
	# Perform Exit Animation
	pass

func Update(delta):
	# Called every frame.
	# Delta is the elapsed time since the previous frame.
	pass	

Then you extend the entire class and use this for other states. As the states that extend from this, should share the exact same foundation. This makes sure you’re consistent with your code and makes things readable.

class_name TestState extends BaseState

var PlayerInput : bool = false

func Enter():
	# Perform Enter Animations and Sounds
	PlayerInput = true # Enable Controls
	pass

func Exit():
	PlayerInput = false # Disable Controls
	# Perform Exit Animations and Sounds	
	pass

func Update(_delta):
	if PlayerInput == true:
		Move_Input()
		Trigger_Input()
		Action_Input()

func Move_Input():
	pass

func Trigger_Input():
	pass

func Action_Input():
	pass

Here you will see my update function has three functions under a boolean if statement. The boolean makes sure that player input can be disabled at any time within this entire class.

Having the three functions like this helps organize the code, by splitting things up into bite size pieces. This way you can read and follow the code easier, because everything is separated into different categories.

func ChangeState():
	GameState.ChangeState(TestState)

I can then use the static function to change my state from anywhere. The UI will basically use the get/set for information displayed. For example, when you change the health directly in the database. the UI automatically updates.

Unless you want the health to slowly trickle down. You then make a new variable in the UI and check to make sure they’re equal. When they’re not equal, you update every frame to slowly increase/decrease the UI_health until they are equal to the health in the Database.

Anyone know whether the control node is required to build a user interface? I want the automatic resize from the anchors. But have absolutely no interest with the mouse and keyboard.

I specifically want to use my state machine to show/hide and start animations with the user interface, while my states do all the input management. I want to disable the mouse and keyboard entirely and have no interest in using them.