Cruise Game 42 · Run a real-device sea trial

Midnight Deck Dash · Lesson 42 of 50 · Publishing · About 45 min

Two crew members try the same delivery on different phones. Turn their observations into a test another developer can repeat.

The ship’s Art Deco Grand Atrium, with carved rails, teal upholstery and warm gold lights.
What you’ll make Record reproducible touch, readability, offline and resume test results.

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.

Record build. Write down device, OS and version. → Try the route. Test input, save and offline use. → Compare. Record what actually happened. → Retest. Repeat after a fix.
Record build → Try the route → Compare → Retest

Build it step by step

Language and tools in this lesson Dictionary, bind(), get_viewport_rect(), Vector2, resize, regression test.

  1. Identify the build and phone

    Make a test sheet with build number, model, OS, orientation, steps, expected, observed and retest result. Describe the device without putting the owner's name or private identifiers in the sheet.

    Why it works A repeatable report tells a developer what was tested.

  2. Measure the viewport

    Open main.gd and find dimensions(). Press F5 and choose Measure viewport. If the standalone desktop window resizes, make it smaller and measure again. Compare with a phone deployment when an adult has prepared it.

    var inside := get_viewport_rect().size

    Why it works The viewport is the game's visible coordinate space. With a fixed base resolution, the value may stay the same as the outer window changes.

  3. Try one-handed controls

    On a physical phone, open the actual game and test a direction tap, hold and double tap, both hands, and a cargo pickup followed by delivery. Record what each action actually did.

    Why it works An input test pairs the press and release with the resulting move.

  4. Test an offline crossing

    With the device owner's consent, launch the game offline. Complete a job, background and resume the app, then close and reopen it fully. Record the restored progress.

    Why it works Backgrounding may keep the script in memory. A fresh process start checks the real save.

  5. Record and retest a problem

    Press Flag touch for retest. Enter clear steps for a real defect, then after a fix use Record touch pass only once the actual test passes. See how the current result changes.

    results[key] = result

    Why it works The dictionary stores one latest result against each key, so unrelated tests keep their status.

  6. Recheck nearby controls

    After fixing a problem, repeat the original test and an adjacent one. If you moved a button, check that the new placement fixes the old issue and doesn't overlap another button.

    Why it works This is a regression check for behaviour that used to work.

Watch the values change

  1. Start trial Touch and resume are untested.
    What you see. The log displays question marks.
  2. Flag touch The touch key becomes RETEST.
    What you see. Resume is still untouched.
  3. Pass touch The same key becomes PASS.
    What you see. The test history can refer to the build on the external sheet.

Predict before you run Can a viewport measurement prove that a phone tap works?

Reveal the answer

No. It helps with layout, while a touch test needs actual taps and a check of the courier's response.

Complete checkpoint

Measuring displays viewport dimensions. Updating touch never updates resume.

main.gd

extends Control

const Lab = preload("res://release_lab.gd")
const TITLE := "Run a real-device sea trial"
var ui: VBoxContainer

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

var results := {"touch": "?", "resume": "?"}

func build() -> void:
	update_log()
	ui.option("Measure viewport", dimensions)
	ui.option("Flag touch for retest", set_result.bind("touch", "RETEST"))
	ui.option("Record touch pass", set_result.bind("touch", "PASS"))
	ui.option("Record resume pass", set_result.bind("resume", "PASS"))

func set_result(key: String, result: String) -> void:
	results[key] = result
	update_log()

func update_log() -> void:
	ui.say("Device trial log\nTouch: %s   Resume: %s\nRecord a pass after performing the test." % [results["touch"], results["resume"]])

func dimensions() -> void:
	var inside := get_viewport_rect().size
	ui.say("Viewport coordinate space: %d × %d. Check finger reach on real hardware." % [inside.x, inside.y])

release_lab.gd

extends VBoxContainer

var body: Label

func start(title_text: String) -> void:
	set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
	offset_left = 34.0
	offset_top = 24.0
	offset_right = -34.0
	offset_bottom = -24.0
	add_theme_constant_override("separation", 12)
	var title := Label.new()
	title.text = title_text
	title.add_theme_font_size_override("font_size", 31)
	title.add_theme_color_override("font_color", Color("#f5cd85"))
	add_child(title)
	body = Label.new()
	body.custom_minimum_size.y = 138.0
	body.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
	body.add_theme_font_size_override("font_size", 19)
	add_child(body)
	var bg := ColorRect.new()
	bg.color = Color("#132942")
	bg.mouse_filter = Control.MOUSE_FILTER_IGNORE
	bg.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
	get_parent().add_child(bg)
	get_parent().move_child(bg, 0)

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

func option(label: String, command: Callable) -> void:
	var button := Button.new()
	button.text = label
	button.custom_minimum_size.y = 45.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 := "Run a real-device sea trial"Creates a constant named TITLE. The expression uses the text inside the quotes. Godot infers the type from the first value.
  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 results := {"touch": "?", "resume": "?"}Creates a variable named results. The expression makes a dictionary that looks up values by key. Godot infers the type from the first value.
  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. update_log()Calls update_log with the values in its parentheses.
  14. ui.option("Measure viewport", dimensions)Calls ui.option with the values in its parentheses.
  15. ui.option("Flag touch for retest", set_result.bind("touch", "RETEST"))Calls ui.option with the values in its parentheses.
  16. ui.option("Record touch pass", set_result.bind("touch", "PASS"))Calls ui.option with the values in its parentheses.
  17. ui.option("Record resume pass", set_result.bind("resume", "PASS"))Calls ui.option with the values in its parentheses.
  18. func set_result(key: String, result: String) -> void:Defines set result, 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.
  19. results[key] = resultStores the new value in results[key]. The expression reads result.
  20. update_log()Calls update_log with the values in its parentheses.
  21. func update_log() -> void:Defines update log, 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.
  22. ui.say("Device trial log\nTouch: %s Resume: %s\nRecord a pass after performing the test." % [results["touch"], results["resume"]])Calls ui.say with the values in its parentheses.
  23. func dimensions() -> void:Defines dimensions, 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.
  24. var inside := get_viewport_rect().sizeCreates a variable named inside. The expression reads the game view's rectangle, which can change when the window changes. Godot infers the type from the first value.
  25. ui.say("Viewport coordinate space: %d × %d. Check finger reach on real hardware." % [inside.x, inside.y])Calls ui.say with the values in its parentheses.
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 body: LabelDeclares body 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 = 34.0Stores the new value in offset_left. The expression reads 34.0.
  6. offset_top = 24.0Stores the new value in offset_top. The expression reads 24.0.
  7. offset_right = -34.0Stores the new value in offset_right. The expression reads -34.0.
  8. offset_bottom = -24.0Stores the new value in offset_bottom. The expression reads -24.0.
  9. add_theme_constant_override("separation", 12)Calls add_theme_constant_override with the values in its parentheses.
  10. var title := Label.new()Creates a variable named title. The expression creates a new Label object. Godot infers the type from the first value.
  11. title.text = title_textUpdates title.text, which controls the words a player sees. The expression reads title_text.
  12. title.add_theme_font_size_override("font_size", 31)Calls title.add_theme_font_size_override with the values in its parentheses.
  13. title.add_theme_color_override("font_color", Color("#f5cd85"))Calls title.add_theme_color_override with the values in its parentheses.
  14. add_child(title)Adds the new node to the scene tree so that Godot can run and draw it.
  15. body = Label.new()Stores the new value in body. The expression creates a new Label object.
  16. body.custom_minimum_size.y = 138.0Stores the new value in body.custom_minimum_size.y. The expression reads 138.0.
  17. body.autowrap_mode = TextServer.AUTOWRAP_WORD_SMARTStores the new value in body.autowrap_mode. The expression reads TextServer.AUTOWRAP_WORD_SMART.
  18. body.add_theme_font_size_override("font_size", 19)Calls body.add_theme_font_size_override with the values in its parentheses.
  19. add_child(body)Adds the new node to the scene tree so that Godot can run and draw it.
  20. var bg := ColorRect.new()Creates a variable named bg. The expression creates a new ColorRect object. Godot infers the type from the first value.
  21. bg.color = Color("#132942")Stores the new value in bg.color. The expression builds a colour from these values.
  22. bg.mouse_filter = Control.MOUSE_FILTER_IGNOREUpdates bg.mouse_filter, which controls how this control participates in pointer and touch input. The expression reads Control.MOUSE_FILTER_IGNORE.
  23. bg.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)Positions this Control relative to the bounds of its parent.
  24. get_parent().add_child(bg)Calls get_parent with the values in its parentheses.
  25. get_parent().move_child(bg, 0)Calls get_parent with the values in its parentheses.
  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. body.text = messageUpdates body.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 = 45.0Stores the new value in button.custom_minimum_size.y. The expression reads 45.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

A vague report like ‘it broke’ needs one reproducible sequence, the build and what happened.

Try a change

Ages 10–12. Compare two screen sizes. Ages 13–16. Record one clear regression sequence with a retest on two devices.

Official instructions