My gamestate.gd (challenge)

I moved the endGame() function and the worldLimit variable to gamestate.gd so that player.gd doesn’t have anything in it relating to the game state logic.

player.gd:

func _process(delta):
	update_animation(motion)
	get_parent().updateGameState(position) # ***** this seems a little dodgy *****

gamestate.gd:

export var worldLimit = 5000

func updateGameState(_position):
	if _position.y > worldLimit:
	     endGame()

func endGame():
	get_tree().change_scene("res://Scenes/GameOver.tscn")
1 Like

Privacy & Terms