week 5 instructional update

This commit is contained in:
OddlyTimbot 2025-07-28 16:07:35 -04:00
parent 674677e617
commit 840e347049

View File

@ -35,6 +35,27 @@ It is possible that an autoload script can get quite cluttered with information,
Now that the game controller is persistent, it does not reload when the level timer completes. As a result, the level loads over and over again because it thinks the time has run out. Now that the game controller is persistent, it does not reload when the level timer completes. As a result, the level loads over and over again because it thinks the time has run out.
### Timer Example
```
var timer = Timer.new()
var timeLimit = 10
var level="res://scenes/game.tscn"
func _ready() -> void:
add_child(timer)
timer.wait_time = 1
timer.one_shot = false
timer.connect("timeout", secondCounter)
timer.start()
func secondCounter() -> void:
timeLimit -=1
if timeLimit <=0:
print("You lose")
get_tree().call_deferred("change_scene_to_file", level)
```
We can use this example to show the relationship of the scene manager to the game controller - because the scene manager DOES reload each time the level is updated. As it loads, it will tell the game controller to reset the timer. We can use this example to show the relationship of the scene manager to the game controller - because the scene manager DOES reload each time the level is updated. As it loads, it will tell the game controller to reset the timer.
In `Gamecontroller`: In `Gamecontroller`: