LESSON 6 OF 6

Restore the whole run and test a complete game

Connect a button and a keyboard command to one reset function, then check every state.

Godot 4.7.2 stable · standard edition · GDScript · 20 minutes estimated practice
0 of 6 lessons completeGuest progress stays in this browser. Account progress is separate.

Continue your working project from the previous lesson. Each download is the completed version of this lesson, for recovery and comparison. Start lesson one with checkpoint 01.

Write the complete reset in one place

Continue from lesson five, or start with checkpoint 05. Add reset_run below try_interact and before _draw. It restores position, movement, parcel state, delivery count and instruction.

Resetting only the visible courier would leave hidden state behind. Putting the complete reset in one function lets both controls use the same rule.

func reset_run() -> void:
	player.position = START
	player.velocity = Vector2.ZERO
	parcel_state = ParcelState.WAITING
	deliveries = 0
	status.text = "Find parcel [P], press Space nearby, then carry it to DROP. R restarts."
	queue_redraw()

Add and connect the restart button

Stop the game and open main.tscn in the 2D workspace. Select DeliveryRoom, add a Button child, and rename it Restart. It must be a direct child of DeliveryRoom so $Restart resolves correctly.

In the Inspector, set its text to Restart [R]. Set its layout position to x=800, y=25 and size to x=120, y=40. Set Focus Mode to None so clicking it does not capture directional-key focus. Save the scene.

Replace the entire _ready function with the code below. The first line keeps the wall setup; the next connects the button signal, and reset_run supplies the starting state.

func _ready() -> void:
	_add_walls()
	$Restart.pressed.connect(reset_run)
	reset_run()

Add the keyboard path to the same rule

Replace _unhandled_key_input with this version. Space still interacts. R calls reset_run when it is pressed; the echo check ignores held-key repeats.

In _draw(), you can update the bottom controls string to Arrow keys: move / Space: interact / R: restart. This changes the description, while the handler above changes behavior.

func _unhandled_key_input(event: InputEvent) -> void:
	if event.is_action_pressed("ui_accept"):
		try_interact()
	if event is InputEventKey and event.pressed and not event.echo and event.keycode == KEY_R:
		reset_run()

Play, compare and share one observation

Run the complete game. Try a restart before pickup, while carrying and after delivery. Each route should restore the same starting facts. Then complete another delivery and check that it still counts exactly once.

Ask another person to try one delivery from the displayed instructions. Record one thing they did, one point of confusion and one small change to test next. You can share a project or ask a focused question in the First Play Studios forum.

Checkpoint 06 is the completed comparison, with source and a regression fixture. Its automated checks exercise engine logic and physical collision; they do not replace checking the rendered game, input comfort and instructions yourself.

  1. Test Space while far from P, then collect P while nearby.
  2. Test Space while far from DROP, then complete a delivery beside it. Repeat Space and check the count.
  3. Use both R and the button at different stages of the run. Confirm the courier, parcel, counter and instruction all reset.
  4. Save a working checkpoint before changing the art, speed, route or rules. Change one thing, repeat the relevant checks and write down the observed result.
OBSERVE THE RESULT

Check your work.

  • The button and R both restore the initial courier position and stop its movement.
  • A carried or delivered parcel returns to its waiting position.
  • The delivery count returns to zero and the starting instruction returns.
  • A fresh delivery works after either restart path.
  • A new player can identify the parcel and destination from the words and shapes.
This is self-reported practice, not a qualification.

If something went wrong.

  • If Godot reports that Restart is missing, check its exact name and parent in the scene tree.
  • Connect the signal once in _ready(), rather than reconnecting it during every reset.
  • Use the same reset function for each restart control so they cannot drift apart.
TAKE THE CONTEXT TO YOUR OWN CHATGPT

Ask about one small step.

I completed the Godot 4.7.2 One Small Delivery workshop. Help me audit reset_run and choose one small improvement. First check which facts must reset, ask for my observed tests before proposing changes, and give me a focused regression checklist for the change I choose.

Source notes & checks.

Checked November 14, 2026 with Godot 4.7.2.stable.official.ed1daf0bf: all six checkpoints passed headless parser/import and 53 engine runtime checks, including actual movement and wall collision, interaction distance, single delivery and restart signal/handler behavior. Six packaged ZIP hashes were checked. Headless tests do not establish editor usability, rendered appearance, physical keyboard/mouse behavior, exported builds, mobile support or compatibility with other engine versions.

Original workshop project code and placeholder shapes are provided under the MIT license. Keep LICENSE.txt with redistributed source. Godot is distributed separately under its own license.

Workshop edition 1.0.0. Source and checkpoint downloads are free.