London Market 42 · Playtest a market shift on a phone

Market Day London · Lesson 42 of 50 · Publishing · About 38 min

Two testers try an early shopping shift. One taps Nia's pickup button, while the other tries handing over an order with an empty basket.

Watercolour of Nia carrying a basket past the produce, bread and flower stalls at a London street market.
What you’ll make Collect evidence about touch, small screens, invalid actions, offline play and resuming the game.

Download the projects from the course page. In Godot’s Project Manager, choose Import, select project.godot, and use Run Project (F5). Start from checkpoints/41 when the lesson builds on prior work, or copy the checkpoints/42 folder to try this lesson on its own. Read the file names in the steps before editing.

Identify. Label build and device. → Act. Recreate one action. → Observe. Write what you actually saw. → Retest. Repeat after a fix.
Identify → Act → Observe → Retest
Godot checkpoint window for Playtest a market shift on a phone
From the running Godot checkpoint.

Build it step by step

Language and tools in this lesson get_viewport_rect(), Array[Dictionary], String.join(), test case, regression.

  1. Record the test setup

    Write the version, device, operating system and orientation next to each check. Mark checks as pending if you only have a computer. Use an authorised adult to install any test build on a phone.

    Why it works The result needs to point to the actual version and device you tried.

  2. Measure the game view

    Import checkpoint 42. Open main.gd, press F5 and choose Measure the game view. Use a smaller editor game window if available, then compare dimensions.

    var dimensions := get_viewport_rect().size

    Why it works The view coordinates can stay fixed while the game is scaled into a smaller window.

  3. Rehearse evidence

    Choose Log an apple pickup and Log an invalid handover. Read each result including the expected and observed values. Find record() and trace how it appends the result.

    Why it works The practice checks are fictional records. Real test cases need the behaviour you observed.

  4. Test nearby controls

    On a supported device, move through at least two shifts. Tap direction buttons and neighbouring tiles where supported, then pick up an apple. Try an empty-basket handover and fill the basket to capacity. Confirm rejected moves show a clear result without adding a turn.

    Why it works Nearby touch controls and hover-dependent clues can behave differently on a phone.

  5. Leave and return

    Complete a shift, record the badge, close and reopen the build. In a fresh attempt, pause or background the app and return. The reference game gives feedback through text and pictures. Check that its feedback still makes sense with the phone muted, and repeat in airplane mode if the adult allows that setting change.

    Why it works The shipped reference stores completed shifts and badges locally. Check how temporary in-shift state behaves on the supported device.

  6. Reproduce and retest

    Write the smallest sequence that produces an unexpected result. After changing the game, rerun those exact steps on the same setup and check at least one earlier successful action.

    Why it works Retesting a previously working feature after a change checks for regressions.

Watch the values change

  1. Measure the viewport The drawing rectangle has a width and a height.
    What you see. Both dimensions appear in pixels.
  2. Record a successful pickup Expected and observed agree.
    What you see. The ledger marks a pass.
  3. Record an invalid handover with the wrong turn count Expected and observed differ.
    What you see. The ledger names the case to retest.

Predict before you run Does a correctly sized computer preview prove that a young player can reach the handover button on a phone?

Reveal the answer

It gives a useful rehearsal. Check the actual control position, feedback and touch behaviour on a supported device too.

Complete checkpoint

The successful pickup has matching observations, while the empty handover is listed for retest.

main.gd

extends Control

const Lab = preload("res://release_lab.gd")
const TITLE = "Playtest a market shift on a phone"
var ui: VBoxContainer

func _ready() -> void:
	ui = VBoxContainer.new()
	ui.set_script(Lab)
	add_child(ui)
	ui.start(TITLE)
	build()

var entries: Array[Dictionary] = []

func build() -> void:
	ui.say("Measure this view or add a fictional result to the ledger.")
	ui.option("Measure the game view", measure)
	ui.option("Log an apple pickup", record.bind("Apple pickup", "1 item", "1 item"))
	ui.option("Log an invalid handover", record.bind("Empty handover", "0 turns added", "1 turn added"))

func measure() -> void:
	var dimensions := get_viewport_rect().size
	ui.say("Game view: %d × %d pixels." % [dimensions.x, dimensions.y])

func record(action: String, expected: String, observed: String) -> void:
	entries.append({"action": action, "expected": expected, "observed": observed})
	var retest: Array[String] = []
	for entry in entries:
		if entry.expected != entry.observed:
			if entry.action not in retest:
				retest.append(entry.action)
	var result := "Pass" if expected == observed else "Retest"
	ui.say("%s: %s\nExpected: %s. Observed: %s.\nReports: %d. Retest: %s." % [
		result, action, expected, observed, entries.size(), ", ".join(retest) if not retest.is_empty() else "none"
	])

release_lab.gd

extends VBoxContainer

var output: Label

func start(title_text: String) -> void:
	set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
	offset_left = 32.0
	offset_top = 28.0
	offset_right = -32.0
	offset_bottom = -28.0
	add_theme_constant_override("separation", 12)
	var background := ColorRect.new()
	background.color = Color("#20342e")
	background.mouse_filter = Control.MOUSE_FILTER_IGNORE
	get_parent().add_child(background)
	background.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
	get_parent().move_child(background, 0)
	var title := Label.new()
	title.text = title_text
	title.add_theme_font_size_override("font_size", 32)
	title.add_theme_color_override("font_color", Color("#f3c991"))
	add_child(title)
	output = Label.new()
	output.custom_minimum_size.y = 151.0
	output.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
	output.add_theme_font_size_override("font_size", 19)
	add_child(output)

func say(message: String) -> void:
	output.text = message

func option(label: String, command: Callable) -> void:
	var button := Button.new()
	button.text = label
	button.custom_minimum_size.y = 46.0
	button.add_theme_font_size_override("font_size", 19)
	button.pressed.connect(command)
	add_child(button)

GDScript line by line

Follow the line numbers, including the indent at the start of each line. Find the code the game will run first, then look for the function that reacts when you tap or change something.

Read main.gd line by line
  1. extends ControlStarts with Godot's Control type. This script gets the abilities of that type and adds the game's own rules.
  2. const Lab = preload("res://release_lab.gd")Creates a constant named Lab. The expression prepares a resource at a fixed project path when the script is loaded.
  3. const TITLE = "Playtest a market shift on a phone"Creates a constant named TITLE. The expression uses the text inside the quotes.
  4. var ui: VBoxContainerDeclares ui for later use. A colon followed by a type says which kind of value belongs here.
  5. func _ready() -> void:Godot calls this once after the scene and its children are ready. Use it to set up the room and connect controls.
  6. ui = VBoxContainer.new()Stores the new value in ui. The expression creates a new VBoxContainer object.
  7. ui.set_script(Lab)Calls ui.set_script with the values in its parentheses.
  8. add_child(ui)Adds the new node to the scene tree so that Godot can run and draw it.
  9. ui.start(TITLE)Calls ui.start with the values in its parentheses.
  10. build()Calls build with the values in its parentheses.
  11. var entries: Array[Dictionary] = []Creates a variable named entries. The expression makes a list whose items keep their order. The type after the colon says what kind of value it can hold.
  12. func build() -> void:Defines build, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect.
  13. ui.say("Measure this view or add a fictional result to the ledger.")Calls ui.say with the values in its parentheses.
  14. ui.option("Measure the game view", measure)Calls ui.option with the values in its parentheses.
  15. ui.option("Log an apple pickup", record.bind("Apple pickup", "1 item", "1 item"))Calls ui.option with the values in its parentheses.
  16. ui.option("Log an invalid handover", record.bind("Empty handover", "0 turns added", "1 turn added"))Calls ui.option with the values in its parentheses.
  17. func measure() -> void:Defines measure, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect.
  18. var dimensions := get_viewport_rect().sizeCreates a variable named dimensions. The expression reads the game view's rectangle, which can change when the window changes. Godot infers the type from the first value.
  19. ui.say("Game view: %d × %d pixels." % [dimensions.x, dimensions.y])Calls ui.say with the values in its parentheses.
  20. func record(action: String, expected: String, observed: String) -> void:Defines record, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect.
  21. entries.append({"action": action, "expected": expected, "observed": observed})Adds an item to the end of a list.
  22. var retest: Array[String] = []Creates a variable named retest. The expression makes a list whose items keep their order. The type after the colon says what kind of value it can hold.
  23. for entry in entries:Repeats the indented instructions for each value in entries.
  24. if entry.expected != entry.observed:Checks entry.expected != entry.observed. The indented instructions below run only if this test passes.
  25. if entry.action not in retest:Checks entry.action not in retest. The indented instructions below run only if this test passes.
  26. retest.append(entry.action)Adds an item to the end of a list.
  27. var result := "Pass" if expected == observed else "Retest"Creates a variable named result. The expression chooses one of two values by checking the condition in the middle. Godot infers the type from the first value.
  28. ui.say("%s: %s\nExpected: %s. Observed: %s.\nReports: %d. Retest: %s." % [Calls ui.say with the values in its parentheses.
  29. result, action, expected, observed, entries.size(), ", ".join(retest) if not retest.is_empty() else "none"Continues the same instruction on a new line. This is one of the arguments, data entries or expressions started above.
  30. ])Continues the same instruction on a new line. This is one of the arguments, data entries or expressions started above.
Read release_lab.gd line by line
  1. extends VBoxContainerStarts with Godot's VBoxContainer type. This script gets the abilities of that type and adds the game's own rules.
  2. var output: LabelDeclares output for later use. A colon followed by a type says which kind of value belongs here.
  3. func start(title_text: String) -> void:Defines start, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect.
  4. set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)Positions this Control relative to the bounds of its parent.
  5. offset_left = 32.0Stores the new value in offset_left. The expression reads 32.0.
  6. offset_top = 28.0Stores the new value in offset_top. The expression reads 28.0.
  7. offset_right = -32.0Stores the new value in offset_right. The expression reads -32.0.
  8. offset_bottom = -28.0Stores the new value in offset_bottom. The expression reads -28.0.
  9. add_theme_constant_override("separation", 12)Calls add_theme_constant_override with the values in its parentheses.
  10. var background := ColorRect.new()Creates a variable named background. The expression creates a new ColorRect object. Godot infers the type from the first value.
  11. background.color = Color("#20342e")Stores the new value in background.color. The expression builds a colour from these values.
  12. background.mouse_filter = Control.MOUSE_FILTER_IGNOREUpdates background.mouse_filter, which controls how this control participates in pointer and touch input. The expression reads Control.MOUSE_FILTER_IGNORE.
  13. get_parent().add_child(background)Calls get_parent with the values in its parentheses.
  14. background.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)Positions this Control relative to the bounds of its parent.
  15. get_parent().move_child(background, 0)Calls get_parent with the values in its parentheses.
  16. var title := Label.new()Creates a variable named title. The expression creates a new Label object. Godot infers the type from the first value.
  17. title.text = title_textUpdates title.text, which controls the words a player sees. The expression reads title_text.
  18. title.add_theme_font_size_override("font_size", 32)Calls title.add_theme_font_size_override with the values in its parentheses.
  19. title.add_theme_color_override("font_color", Color("#f3c991"))Calls title.add_theme_color_override with the values in its parentheses.
  20. add_child(title)Adds the new node to the scene tree so that Godot can run and draw it.
  21. output = Label.new()Stores the new value in output. The expression creates a new Label object.
  22. output.custom_minimum_size.y = 151.0Stores the new value in output.custom_minimum_size.y. The expression reads 151.0.
  23. output.autowrap_mode = TextServer.AUTOWRAP_WORD_SMARTStores the new value in output.autowrap_mode. The expression reads TextServer.AUTOWRAP_WORD_SMART.
  24. output.add_theme_font_size_override("font_size", 19)Calls output.add_theme_font_size_override with the values in its parentheses.
  25. add_child(output)Adds the new node to the scene tree so that Godot can run and draw it.
  26. func say(message: String) -> void:Defines say, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect.
  27. output.text = messageUpdates output.text, which controls the words a player sees. The expression reads message.
  28. func option(label: String, command: Callable) -> void:Defines option, a reusable set of instructions. Parameters between the parentheses receive inputs. A return type after the arrow tells you which kind of result to expect.
  29. var button := Button.new()Creates a variable named button. The expression creates a new Button object. Godot infers the type from the first value.
  30. button.text = labelUpdates button.text, which controls the words a player sees. The expression reads label.
  31. button.custom_minimum_size.y = 46.0Stores the new value in button.custom_minimum_size.y. The expression reads 46.0.
  32. button.add_theme_font_size_override("font_size", 19)Calls button.add_theme_font_size_override with the values in its parentheses.
  33. button.pressed.connect(command)Links a signal to the function that should run when the event happens.
  34. add_child(button)Adds the new node to the scene tree so that Godot can run and draw it.

Find and fix a bug

If one action adds two records, check whether two signals call record() for the same press.

Try a change

Ages 10–12. Compare a valid pickup with an invalid one. Ages 13–16. Test two devices, including pause, offline play and muted feedback.