Build a GameCreating Pitch Shot

7  Winning

Goal

By the end of this chapter, finding the call wins the stage. A card comes up: “That’s the one!”, up to three stars for how well you listened, a line about how you found it, and the next stage’s name. A bar fills, and the next stage stands up.

The game as it is at the end of this chapter. Click the game to play.

If your game and this chapter part ways, here is the chapter’s finished project. Unzip it first. Then open it and compare, or start Chapter 8 from it.

Pitch Shot, Chapter 7 finishedZip of a Myth project · 2.8 MB

To open it, right-click the downloaded file, choose Extract All... and then Extract. Start Myth Engine, choose File › Open Project... and pick the .mythproj file in the new folder. Nunito-OFL.txt beside it comes with the game.

7.1 The Idea

Shoot at the call. The note bursts in gold, the world slows, and the tower comes down knocking. The rubble settles on the grass. Then a fresh happy note pops into the band, and the stage goes on, as if nothing had happened.

You found it. The game should say so.

This chapter gives the moment its ending. A moment after the last block lands, a card comes up over the meadow. “That’s the one!” Three stars, or two, or one. A line that says how you found it, such as “Found by ear, first time.” The name of the next stage. And a bar that fills, and when it’s full, the next stage stands up.

The stars are for listening. No wrong notes earns three. One or two wrong notes earn two, and more earn one. Every stage can be won, and the stars only say how well you heard it.

To end a stage, the game needs to know it has ended. That’s the Game State: one word for what the whole game is doing right now, Playing or Stage Won. Think of the sign on a shop door. Anyone walking by can read it, and one hand turns it over. Here that hand is Win The Stage, and the readers are the pieces that should stop when the stage is over.

Nothing in this chapter changes how a shot flies or a tower falls. It all happens after.

7.2 The Plan

Here’s how the pieces work together. A name in bold is a piece you’ll make or change, and a name in plain text is a Custom Event.

  • The call is found -> Win The Stage turns the Game State to Stage Won and counts the stars. Load The Happy Note and Repeat The Call read the sign and stay quiet.
  • At the same moment, Bring Up The Card waits for the blocks to settle -> cardShown.
  • On cardShown, Show With The Card shows the card’s parts. Light A Star, Tell How It Was Found and Show The Next Stage fill them in. Fill The Bar starts the bar.
  • The full bar sends cardTimeUp. A click sends goOnWanted, and Enter is the Go On Command. All three ways -> Go On To The Next Stage -> the next stage.
  • At the top, the Stage Title names the stage, and the Restart Button starts it again.

You’ll build it in that order: the win, then the card, then the way on, then the top of the screen.

7.3 Set Up

Set upWhat this chapter adds
ART (sprites, from the starter kit)
Title Pill Art
Card Panel Art
Star Art
Card Bar Track Art
Card Bar Fill Art
Restart Icon Art
SOUNDS (from the starter kit)
Sound Click
COMMANDS (Game Settings > Input Manager)
Go OnButton
KeybindingsEnter
INPUT CONTEXTS (Game Settings > Input Manager)
CardInactive at Start(new)
CommandsGo On
GLOBAL VARIABLES
$starsWonNumberstarts at 0
GAME SETTINGS > General > Game State
Available Game StatesPlaying, Stage Won
SCENE Field: PLACE THESE
ObjectXY
Restart Button1500-64
with Z-Index = 10010
Stage Title760-58
with Z-Index = 10010
Card Panel960-370
with Z-Index = 10050
Card Star850-316
with Z-Index = 10060
Card Star960-302
with Z-Index = 10060
with Per Instance Variables > Star Number = 2
Card Star1070-316
with Z-Index = 10060
with Per Instance Variables > Star Number = 3
Card Message960-408
with Z-Index = 10060
Card Next960-462
with Z-Index = 10060
Card Bar Track960-510
with Z-Index = 10060
Card Bar960-510
with Z-Index = 10061

ART names the pictures for the card and for the top of the screen. There’s the card itself, a star, the bar’s track and its fill, a pill for the stage’s name, and the restart icon. SOUNDS names Sound Click, for the restart button. The Starter Kit brought them all.

INPUT CONTEXTS has a new one, Card, and it starts Inactive at Start. Make it before the Command, so Go On goes into its Command Set, as Keys: Commands and Input Contexts says from Chapter 7. Next, add Go On, a Button, on Enter.

Why a second context? Enter already lets go of the happy note, in Field. While the card is up, Field is off and Card is on, so the same key means “go on” instead.

GLOBAL VARIABLES has one, $starsWon, a Number that starts at 0, for the stars this stage has earned. Open any Logic Component, and add it from its canvas’s Globals card.

GAME SETTINGS names the two Game States. Your project has Playing already, so add Stage Won, as The Set up card shows from Chapter 7.

PLACE THESE waits for the card’s parts, the Stage Title and the Restart Button. The chapter comes back to it when they’re made.

7.4 The Stage Is Won

First, the win itself. The card comes in the next part, so this one ends in quiet.

7.4.1 Win The Stage

When the Field starts, Win The Stage sets the Game State to Playing. It also turns Field on and Card off, so that Enter lets go of the happy note again, the way it did in Chapter 4.

When callFound comes, it turns the sign over: Stage Won. Then it counts the stars, from $wrongNotes, the count you made in Chapter 5. None, and $starsWon is 3. Up to twoStarWrongNotes, which is 2, and the stage earns 2 stars. More, and it’s 1.

Logic ComponentWin The StageAttach to: Game Rules

Finding the called note wins the stage: the game is Stage Won, and the stage earns stars for listening.

Attach toAny Object
SHARED VARIABLES
NameTypeKindStarting Value
twoStarWrongNotesNumberConstant2
When the Scene Starts
WhenScene Start
1Set Game State
Game State
Playing
2Set Input Context Active
Input Context
Field
3Set Input Context Active
Input Context
Card
Active
No
On Call Found
WhencallFoundCustom Event
1Set Game State
Game State
Stage Won
2If$wrongNotes == 0
Then
3Change Variable
Variable
$starsWon
Value
3
4Otherwise
5If$wrongNotes <= @self.twoStarWrongNotes
Then
6Change Variable
Variable
$starsWon
Value
2
7Otherwise
8Change Variable
Variable
$starsWon
Value
1

Set Game State has one list, Game State, with your two in it. Set Input Context Active has two: an Input Context list, and an Active switch. The switch starts On. So where the card gives no Active line, leave it On, and where it says No, turn it off.

The stars are an If with an If in its Else. Build the outer If first. Use Add inside Else to add the inner If, with its own Else.

7.4.2 Load The Happy Note, Changed

Logic ComponentLoad The Happy NoteAttach to: SlingshotAddDelete

Puts a happy note in the band when the opening is over, and again a moment after each shot ends, if none is there.

Attach toAny Object
SHARED VARIABLES
NameTypeKindStarting Value
happyNoteObjectConstantNone
bandOffsetXNumberConstant-0.01
bandOffsetYNumberConstant1.01
secondsAfterShotNumberConstant0.35
On Opening Finished
WhenopeningFinishedCustom Event
1Put A Note In The BandFunction
bandX
self.transform.position.x + @self.bandOffsetX
bandY
self.transform.position.y + @self.bandOffsetY
happyNote
@self.happyNote
slingshot
self
On Shot Ended
WhenshotEndedCustom Event
1Start Recurring Timer
Timer Name
"loadNext"
Repeat Every (s)
@self.secondsAfterShot
Ring Once
Yes
On the Load Next Timer
WhenRecurring TimerTimer name: loadNext
1Put A Note In The BandFunction
bandX
self.transform.position.x + @self.bandOffsetX
bandY
self.transform.position.y + @self.bandOffsetY
happyNote
@self.happyNote
slingshot
self
1Check Game State
Action Name
isPlaying
Game State
Playing
2IfisPlaying.value == true
Then
3Put A Note In The BandFunction
bandX
self.transform.position.x + @self.bandOffsetX
bandY
self.transform.position.y + @self.bandOffsetY
happyNote
@self.happyNote
slingshot
self

After the winning shot ends, the slingshot would load a note, as it does after every shot. Nobody needs one now. So the loadNext timer asks first.

Check Game State asks whether the game is in the state you pick, and its answer is isPlaying. You’ve read an answer like that before, from Check Cooldown Ready in Chapter 6. The If reads isPlaying.value == true, and the call to Put A Note In The Band moves inside it.

Delete the old call. The Event’s line is empty now, as On Opening Finished’s was in Chapter 4, so Connect to Sequence joins Check Game State at its start. Add the If after it, and join it. Use Add inside Then for Put A Note In The Band, with the same four values.

7.4.3 Repeat The Call, Changed

Logic ComponentRepeat The CallAttach to: Game RulesAddDelete

Plays the call whenever it is asked for while the stage is being played, and again by itself after a quiet spell, at most twice in a row, never over the player's aim or a shot in the air.

Attach toAny Object
DATA STRUCTURES
Repeat The Call Dataself.repeatTheCallData
SHARED VARIABLES
NameTypeKindStarting Value
quietSecondsNumberConstant8
mostRepeatsNumberConstant2
waitSecondsNumberConstant1
On Call Requested
WhencallRequestedCustom Event
1If$calledPitch > 0
Then
1Check Game State
Action Name
isPlaying
Game State
Playing
2IfisPlaying.value == true && $calledPitch > 0
Then
3Play Piano NoteFunction
pitch
$calledPitch
4Change Component Value
Component Value
self.repeatTheCallData.repeatsLeft
Value
@self.mostRepeats
5Start Recurring Timer
Timer Name
"repeatTheCall"
Repeat Every (s)
@self.quietSeconds
First Delay (s)
@self.quietSeconds
On the Repeat the Call Timer
WhenRecurring TimerTimer name: repeatTheCall
1Ifself.repeatTheCallData.isNoteWaiting == true
Then
2Play Piano NoteFunction
pitch
$calledPitch
3Change Component Value
Component Value
self.repeatTheCallData.repeatsLeft
Operator
+=
Value
-1
4Ifself.repeatTheCallData.repeatsLeft <= 0
Then
5Stop Recurring Timer
Timer Name
"repeatTheCall"
6Otherwise
7Start Recurring Timer
Timer Name
"repeatTheCall"
Repeat Every (s)
@self.quietSeconds
First Delay (s)
@self.waitSeconds
On Happy Note Loaded
WhenhappyNoteLoadedCustom Event
1Change Component Value
Component Value
self.repeatTheCallData.isNoteWaiting
Value
true
On Pull Started
WhenpullStartedCustom Event
1Change Component Value
Component Value
self.repeatTheCallData.isNoteWaiting
Value
false
On Pull Ended
WhenpullEndedCustom Event
1Change Component Value
Component Value
self.repeatTheCallData.isNoteWaiting
Value
true
On Happy Note Launched
WhenhappyNoteLaunchedCustom Event
1Change Component Value
Component Value
self.repeatTheCallData.isNoteWaiting
Value
false
On Shot Ended
WhenshotEndedCustom Event
1Start Recurring Timer
Timer Name
"repeatTheCall"
Repeat Every (s)
@self.quietSeconds
First Delay (s)
@self.quietSeconds
1Check Game State
Action Name
isStillPlaying
Game State
Playing
2IfisStillPlaying.value == true
Then
3Start Recurring Timer
Timer Name
"repeatTheCall"
Repeat Every (s)
@self.quietSeconds
First Delay (s)
@self.quietSeconds
On Call Found
WhencallFoundCustom Event
1Stop Recurring Timer
Timer Name
"repeatTheCall"

The call should rest once it’s found. Three changes.

On Call Requested asks the same question first. Once the stage is won, “Hear it again” rests too, because the call has been found.

The Changes card replaces the old If. Delete that If and its three Actions, then rebuild this Event from the green lines. Start with Check Game State, named isPlaying, on the empty Event line. Add the new If after it. Its one Condition box joins the state check and the pitch check with &&. Use Add inside Then to rebuild the three Actions under it. Their values stay the same. The card leaves those values unmarked; here you rebuild their Actions under the new If.

On Shot Ended starts the quiet spell only while Playing. Delete its timer, and build it again the same way: Check Game State named isStillPlaying on the empty line, the If after it, and the timer inside Then.

And a new Event: when callFound comes, Stop Recurring Timer stops the repeatTheCall timer. Its one box takes repeatTheCall, the timer’s name.

7.4.4 Game Rules, Changed

ObjectGame RulesAddDelete
Data Structure
From LogicSound The Fall
Data StructureSound The Fall Data
Data Structure
From LogicRepeat The Call
Data StructureRepeat The Call Data
Data Structure
From LogicMake Way For The Notes
Data StructureMake Way For The Notes Data
Logic
Build The Stage
Sound The Fall
Slow The Moment
Watch The Towers Fall
Call A Note
Repeat The Call
Play The Place's Tune
Make Way For The Notes
Count The Shots
Ask Again
Win The Stage
Bring Up The Card
Go On To The Next Stage
Shared Variables
singingNoteSinging Note

Attach Win The Stage to Game Rules now. Bring Up The Card and Go On To The Next Stage join it later in the chapter.

Run the game. Find the call. The tower comes down, the rubble settles, and then nothing. No new note in the band, and the call doesn’t come back. Press Space, and the meadow stays quiet.

It looks like the game has stopped. It hasn’t. It’s waiting for the card, which is the next part’s work.

7.5 The Card Comes Up

Now the card. It’s six pieces on the screen: the panel, three stars, a message, the next stage’s name, and a bar on a track. And one Logic decides when it appears.

7.5.1 Bring Up The Card

The card shouldn’t come up in the middle of the crash. It waits for the dust to settle.

Count the beats. The call is found. A little over a second and a half goes by, cardAfterSeconds, 1.6. Are blocks still knocking? Wait another restSeconds, 0.4 seconds, and ask again. And again. When the knocks have been quiet for 0.4 seconds, up comes the card. A big crash can’t hold it back for long. At latestCardSeconds, 3.5, it comes up anyway.

The quiet is a cooldown, the named stopwatch from Chapter 6. Every blockKnocked starts stillCrashing over. The stopwatch runs out only once the knocks stop.

A Cooldown Key takes its name bare, as a Timer Name does. Type stillCrashing without quote marks.

Two timers race, showCard and latestCard. Whichever rings first sends cardDue, and On Card Due stops them both, so the card comes up once.

Trigger Custom Event on Object sends cardDue only to Game Rules itself. Then it turns Field off and Card on, and sends cardShown to the whole Scene. Everything on the card waits for that.

Logic ComponentBring Up The CardAttach to: Game Rules

When the stage is won, the card comes up cardAfterSeconds later, or later while blocks are still crashing, and at latestCardSeconds at the latest.

Attach toAny Object
SHARED VARIABLES
NameTypeKindStarting Value
cardAfterSecondsNumberConstant1.6
latestCardSecondsNumberConstant3.5
restSecondsNumberConstant0.4
On Call Found
WhencallFoundCustom Event
1Start Recurring Timer
Timer Name
"showCard"
Repeat Every (s)
@self.cardAfterSeconds
Ring Once
Yes
2Start Recurring Timer
Timer Name
"latestCard"
Repeat Every (s)
@self.latestCardSeconds
Ring Once
Yes
On Block Knocked
WhenblockKnockedCustom Event
1Start Cooldown
Cooldown Key
"stillCrashing"
Seconds
@self.restSeconds
On the Show Card Timer
WhenRecurring TimerTimer name: showCard
1Check Cooldown Ready
Action Name
isQuiet
Cooldown Key
"stillCrashing"
2IfisQuiet.value == true
Then
3Trigger Custom Event on Object
Custom Event
cardDue
4Otherwise
5Start Recurring Timer
Timer Name
"showCard"
Repeat Every (s)
@self.restSeconds
Ring Once
Yes
On the Latest Card Timer
WhenRecurring TimerTimer name: latestCard
1Trigger Custom Event on Object
Custom Event
cardDue
On Card Due
WhencardDueCustom Event
1Stop Recurring Timer
Timer Name
"showCard"
2Stop Recurring Timer
Timer Name
"latestCard"
3Set Input Context Active
Input Context
Field
Active
No
4Set Input Context Active
Input Context
Card
5Trigger Custom Event
Custom Event
cardShown

The blocks are familiar. The Else at step 4 belongs to the If at step 2. It starts the showCard timer again. Attach Bring Up The Card to Game Rules now, before the run at the end of this part.

7.5.2 Show With The Card

Every part of the card starts hidden. It appears on cardShown. That’s one small Logic, Show With The Card. Five Objects carry it.

Logic ComponentShow With The CardAttach to: Card Panel, Card Message, Card Star, Card Bar Track, Card Bar

A part of the card that shows when a stage is won: hidden until then.

Attach toAny Object
When Created
WhenCreate
1Set Visible
Visible
No
On Card Shown
WhencardShownCustom Event
1Set Visible
Visible
Yes

Make it once, and attach it to each card part as you make it. One Logic can sit on many Objects, and each one runs it for itself, at its own place on the screen. Each part’s Object card lists the Logic it carries.

7.5.3 The Card Panel

ObjectCard Panel
Transform
Presentation > SpaceWindow / UI
Presentation > Render LayerUI
Bounding Box > SizeX 820, Y 426
Sprite
Z Index Within Object-1
SpriteCard Panel Art
Transform > SizeX 820, Y 426
Text / UI
TextThat’s the one!
FontNunito
Font Size54
EmphasisExtra Bold
Color#EC4A33
AlignmentCenter
RenderingVector
Transform > PositionX 0, Y 162
UI Interaction(as it is added)
Logic
Show With The Card
Go On From The Card

The win card is a cream panel with a dark rim, Card Panel Art. Across its top, in red, it says That’s the one!

That apostrophe is a curly one, ’. It isn’t the straight ’ on your keyboard, so copy the words from the card, and yours will match the game. The words sit at Y 162, near the top of the panel.

Keep its UI Interaction, as it comes. A click on the card goes on to the next stage, and Go On From The Card joins it in the next part.

7.5.4 Light A Star

Logic ComponentLight A StarAttach to: Card Star

One of the three stars on the card (each placement has its starNumber): it shows lit when the stage earned at least that many stars.

Attach toAny Object
PER INSTANCE VARIABLES
NameTypeStarting Value
starNumberNumber1
On Card Shown
WhencardShownCustom Event
1If$starsWon >= self.starNumber
Then
2Set Frame
Frame
1
3Otherwise
4Set Frame
Frame
0

Star Art is a picture with two frames, a dim star and a lit one. Set Frame shows one of them: 0 is dim, 1 is lit.

Each star knows its number, Star Number, read as self.starNumber. When the card comes up, it asks: did this stage earn at least my number of stars? If so, it lights. Two stars earned, and stars 1 and 2 light, while star 3 stays dim.

7.5.5 The Card Star

ObjectCard Star
Transform
Presentation > SpaceWindow / UI
Presentation > Render LayerUI
Bounding Box > SizeX 96, Y 96
Sprite
Z Index Within Object-1
SpriteStar Art
Transform > SizeX 96, Y 96
Logic
Show With The Card
Light A Star

There’s one Card Star, placed three times. Each placement gets its own Star Number under PLACE THESE. The first keeps its Starting Value of 1; the others get 2 and 3. Use the placement’s Properties. One Object gives you three stars, each with a number of its own. The stars aren’t buttons. Remove the UI Interaction.

7.5.6 Found Line, Found Words and Tell How It Was Found

Data StructureFound Line

One line of the card's message.

wordsTextdefault (empty)
wordsAfterNumberTextdefault (empty)
Data TableFound WordsData Structure: Found Line
Row 0First Time
wordsFound by ear, first time.
wordsAfterNumber
Row 1One Wrong Note
wordsFound after one wrong note.
wordsAfterNumber
Row 2More Wrong Notes
wordsFound after
wordsAfterNumberwrong notes.

The message under the stars says how you found the call. Its words live in a table, Found Words, made of Found Line rows, like the message near the top, whose words live in Messages.

Rows 0 and 1 are whole lines. Row 2 comes in two halves, “Found after” and “wrong notes.”, because a number goes between them. Leave the empty wordsAfterNumber cells empty.

Logic ComponentTell How It Was FoundAttach to: Card Message

The card's message: how the called note was found, by how many wrong notes came first.

Attach toAny Object
On Card Shown
WhencardShownCustom Event
1Declare Variable
Type
Text
Name
wordsBefore
2Declare Variable
Type
Text
Name
wordsAfter
3If$wrongNotes <= 1
Then
4Set UI Text
Text
data("Found Words", $wrongNotes, "words")
5Otherwise
6Change Variable
Variable
wordsBefore
Value
data("Found Words", 2, "words")
7Change Variable
Variable
wordsAfter
Value
data("Found Words", 2, "wordsAfterNumber")
8Set UI Text
Text
text(wordsBefore, " ", $wrongNotes, " ", wordsAfter)

Declare Variable makes wordsBefore and wordsAfter as Text, ready to hold the two halves of the message. Leave their starting Value alone; both are filled before the message uses them.

The row number is $wrongNotes. No wrong notes reads row 0, and one reads row 1. More than one takes row 2’s two halves, and text(...) joins them with the number between, into one line: Found after 3 wrong notes.

Set UI Text puts words on a Screen UI Object. Leave its Element box blank, and it writes on the Object this Logic is attached to.

7.5.7 The Card Message

ObjectCard Message
Transform
Presentation > SpaceWindow / UI
Presentation > Render LayerUI
Bounding Box > SizeX 740, Y 50
Text / UI
FontNunito
Font Size32
EmphasisExtra Bold
Color#3A1D0B
AlignmentCenter
RenderingVector
UI Interaction
Element TypeText
Logic
Tell How It Was Found
Show With The Card

The Card Message has no words of its own until Tell How It Was Found writes them. Its UI Interaction stays, with Element Type set to Text in its list, so Set UI Text can write through it. Text templates in braces read their values without UI Interaction.

7.5.8 Show The Next Stage and the Card Next

Logic ComponentShow The Next StageAttach to: Card Next

The card's last line, the number and name of the next stage: shown with the card when there is a next stage.

Attach toAny Object
When Created
WhenCreate
1Set Visible
Visible
No
On Card Shown
WhencardShownCustom Event
1If$stage < dataCount("Stages")
Then
2Set Visible
Visible
Yes

The next stage gets a line of its own at the bottom of the win card. It’s hidden until the card comes up, like the others. But it has its own Logic, because one stage has no next stage. dataCount("Stages") counts the rows of the Stages table. While $stage is less than that, there’s a next stage, and the line shows. On the very last stage there isn’t. Chapter 10 gives that moment its own ending.

ObjectCard Next
Transform
Presentation > SpaceWindow / UI
Presentation > Render LayerUI
Bounding Box > SizeX 740, Y 40
Text / UI
TextNext: {$stage + 1}. {data("Stages", $stage, "name")}
FontNunito
Font Size26
EmphasisExtra Bold
Color#3A1D0B
AlignmentCenter
RenderingVector
Logic
Show The Next Stage

Its Text is a template, like the shot count’s {$shots}, with two pieces in braces. The first is the next stage’s number. The second reads that stage’s name from Stages. Stage 1 is row 0, so the next stage’s row is $stage itself. Copy the line from the card. Its card lists no UI Interaction, so remove the one it came with.

7.5.9 Fill The Bar, the Card Bar Track and the Card Bar

Logic ComponentFill The BarAttach to: Card Bar

The bar on the card fills over fillSeconds; when it is full it says the card has had its time.

Attach toAny Object
SHARED VARIABLES
NameTypeKindStarting Value
fillSecondsNumberConstant2.4
On Card Shown
WhencardShownCustom Event
1Set Scale
Horizontal Scale
0
Vertical Scale
1
2Tween
Value
self.transform.scale.x
Target
1
Duration
@self.fillSeconds
3Start Recurring Timer
Timer Name
"barFull"
Repeat Every (s)
@self.fillSeconds
Ring Once
Yes
On the Bar Full Timer
WhenRecurring TimerTimer name: barFull
1Trigger Custom Event
Custom Event
cardTimeUp

The bar is the card’s clock. When the card comes up, Set Scale squeezes the bar to nothing across, a Horizontal Scale of 0. Then Tween grows it back to 1 over fillSeconds, 2.4 seconds, from its middle out to both ends. A timer, barFull, rings at the same moment. It sends cardTimeUp.

ObjectCard Bar Track
Transform
Presentation > SpaceWindow / UI
Presentation > Render LayerUI
Bounding Box > SizeX 480, Y 18
Sprite
Z Index Within Object-1
SpriteCard Bar Track Art
Transform > SizeX 480, Y 18
Logic
Show With The Card
ObjectCard Bar
Transform
Presentation > SpaceWindow / UI
Presentation > Render LayerUI
Bounding Box > SizeX 476, Y 14
Sprite
Z Index Within Object-1
SpriteCard Bar Fill Art
Transform > SizeX 476, Y 14
Logic
Show With The Card
Fill The Bar

The track is a pale strip, and the bar is the orange fill drawn on top of it, a little smaller. Neither one is clicked, so remove their UI Interactions.

Now PLACE THESE, for the card. Drag each part onto the Field, and leave its Screen Anchor on the top-left dot, as in Chapter 4. Type its X, Y and Z-Index from the card. Place the Card Star three times, and give each its Star Number under Per Instance Variables in Properties. The Z-Indexes stack the card: the panel at 10050, its words and stars at 10060, and the bar at 10061, in front of its track.

Run the game. Find the call. The tower comes down, and a moment after the last knock, the card comes up. “That’s the one!”, the stars, your line, and the next stage’s name. The bar fills.

And then it stays there, full, and nothing happens, because nobody is listening for cardTimeUp yet.

7.6 On to the Next Stage

The bar is full. Time to go on to the next stage.

7.6.1 Go On To The Next Stage

Logic ComponentGo On To The Next StageAttach to: Game Rules

From the card, the next stage starts: by itself when the card has had its time, or at once with Enter or a click.

Attach toAny Object
On Card Time Up
WhencardTimeUpCustom Event
1Trigger Custom Event on Object
Custom Event
goOn
On Go on Wanted
WhengoOnWantedCustom Event
1Trigger Custom Event on Object
Custom Event
goOn
When Goon Is Pressed
WhenCommand PressedCommand: Go On
1Trigger Custom Event on Object
Custom Event
goOn
On Go on
WhengoOnCustom Event
1Set Logic State
Logic Component
Go On To The Next Stage
State
Disable
2Change Variable
Variable
$stage
Operator
+=
Value
1
3Restart Scene

There are three ways on: the bar fills, you press Enter, or you click the card. Each of the first three Events sends one message, goOn, to Game Rules itself. One way on, really. Three doors into it.

On Go on adds 1 to $stage, and Restart Scene starts the Field again. That’s all a new stage takes. The Field starts, Build The Stage reads $stage, and the next stage stands up, with a new call.

When Goon Is Pressed is Myth’s heading for the Go On Command, with the words joined.

Set Logic State has two lists. Choose Go On To The Next Stage in the first, and Disable in the second.

Before any of that, On Go on switches its own Logic off. Why? Press Enter at the instant the bar fills, and two goOns arrive in the same moment. Without that first step, both would add 1, and you’d skip a stage. Now the second one finds the Logic off, and does nothing at all, and the new Field starts it on again.

7.6.2 Go On From The Card

Logic ComponentGo On From The CardAttach to: Card Panel

Clicking or tapping the card asks to go on at once.

Attach toAny Object
On Hud Activated
WhenUI Activated
1Trigger Custom Event
Custom Event
goOnWanted

A click on the panel sends goOnWanted, and that’s all. Attach it to the Card Panel, under Show With The Card. The heading On Hud Activated is Myth’s own name for a UI Activated Event, as on the Listen Button in Chapter 2.

7.6.3 Game Rules, Complete for Now

Attach Go On To The Next Stage to Game Rules now. Bring Up The Card is there already. The Game Rules card at the start lists all three new Logic Components.

Run the game. Find the call. The card comes up, the bar fills, and the meadow changes under it. Stage 2, Hilltop echo. A taller tower stands, and the notes sing their opening again.

Play another, and press Enter while the bar is filling. You’re on at once.

7.7 The Top of the Screen

Last, two small things at the top, so you always know where you are.

7.7.1 The Stage Title

ObjectStage Title
Transform
Presentation > SpaceWindow / UI
Presentation > Render LayerUI
Bounding Box > SizeX 640, Y 64
Sprite
Z Index Within Object-1
SpriteTitle Pill Art
Transform > SizeX 640, Y 64
Text / UI
Text{data("Stages", $stage - 1, "place")} · {$stage}. {data("Stages", $stage - 1, "name")}
FontNunito
Font Size27
EmphasisExtra Bold
Color#3A1D0B
AlignmentCenter
RenderingVector

A cream pill at the top names the place and the stage: Sunny Meadow · 1. Low and high. Its Text is a template with three pieces in braces. The place and the name come from the Stages table, at row $stage - 1, because stage 1 is row 0.

The dot in the middle, ·, isn’t on most keyboards. Copy the whole line from the card, the two spaces on each side of the dot too. It has no Logic. Its card lists no UI Interaction either, so remove the one it came with.

7.7.2 Start The Stage Again and the Restart Button

Logic ComponentStart The Stage AgainAttach to: Restart Button

The Restart button: starts the stage being played again from the beginning (with a new call).

Attach toAny Object
On Hud Activated
WhenUI Activated
1Control Sound
Sound
Sound Click
2Restart Scene

Control Sound plays Sound Click here. Pick Sound Click in its Sound list, and leave its other fields at their defaults. Restart Scene has no boxes.

The round gold button at the top right starts the stage again. Click it, and Restart Scene starts the Field over. There’s nothing to reset by hand. A new Field already builds the stage, sets the shots to 0, sings the opening and picks a new call.

ObjectRestart Button
Transform
Presentation > SpaceWindow / UI
Presentation > Render LayerUI
Bounding Box > SizeX 96, Y 102
Sprite
Z Index Within Object-1
SpriteRestart Icon Art
Transform > SizeX 96, Y 102
UI Interaction(as it is added)
Logic
Start The Stage Again

Keep its UI Interaction, as it comes, because this one is a button.

Now the rest of PLACE THESE: the Restart Button at 1500 and -64, and the Stage Title at 760 and -58, both at 10010, like the shot count.

Run the game. The title names the stage. Press the restart button halfway through a stage, and the tower stands up again, whole, with a new call.

Play it!

Listen, and watch, for each of these.

  • Find the call on your first try. A moment after the last block lands, the card comes up: That’s the one!, three lit stars, Found by ear, first time.
  • Hit one wrong note first, then the call. Two stars light, the third stays dim, and the line says Found after one wrong note.
  • Hit three wrong notes first, and then the call. One star lights, and the line says Found after 3 wrong notes.
  • Make a big crash. The card waits until the knocking stops, but never longer than 3.5 seconds after the win.
  • Under the line, the next stage’s number and name: Next: 2. Hilltop echo.
  • The bar fills from its middle out, in 2.4 seconds, and then the next stage stands up.
  • Press Enter, or click the card, while the bar fills. You’re on to the next stage at once. One stage on, never two.
  • Once the call is found, no new happy note loads, and “Hear it again” stays quiet.
  • At the top, the stage title reads Sunny Meadow · 1. Low and high. The restart button starts the stage over, with the shot count back at 0.
How it works

The call is found, and Win The Stage turns the sign to Stage Won and counts the stars. The slingshot and the call read the sign and rest. Bring Up The Card waits out the crash, then sends cardShown. Each part of the card answers it for itself: one shows, a star lights, a line is written, a bar fills. The full bar, Enter or a click sends goOn, and Restart Scene brings up the next stage.

Underneath it is one idea: a stage has a beginning and an end, and the game says which it’s in. Before this chapter, every piece ran all the time. Now each one can ask the Game State first, and the stage can stop, still and finished, while the card is up.

7.8 If It Didn’t Work

Most slips in this chapter leave the card missing, or stuck. Watch what the game does after the win, and you’ll know where to look.

The tower falls, and a new note loads anyway? Look at Load The Happy Note’s loadNext Event, and at Win The Stage on Game Rules. Is the Game State set to Stage Won on callFound?

The card never comes up? Is Bring Up The Card on Game Rules? Perhaps a part of the card is hidden because Show With The Card missed it. Look at that part’s Logic, and at its Z-Index.

The card comes up empty, a panel with no stars? Perhaps the Card Stars aren’t placed, or their Z-Index is under the panel’s 10050.

Every star lights, every time? Look at each placement’s Star Number, because all three may still say 1.

The message is missing? Look at the Card Message’s UI Interaction, whose Element Type should be Text.

The bar fills and nothing happens? Is Go On To The Next Stage on Game Rules? Is barFull spelled the same, letter for letter, in both Events of Fill The Bar, the one that starts the timer and the one that hears it?

Enter lets go of a note instead of going on? Look at Bring Up The Card’s On Card Due, where Field goes off and Card goes on. And is Go On in the Card context, not in Field?

A stage gets skipped? Look at step 1 of On Go on, which switches the Logic off before anything else can happen.

Each of these is one small fix. Make it, run the game, and find the call again. And if you’d like to compare, the catch-up download in the Goal is this chapter’s game, finished.

Challenge

The win is yours to shape. Change twoStarWrongNotes in Win The Stage from 2 to 0, and only a perfect stage earns more than one star. Or change fillSeconds in Fill The Bar from 2.4 to 6, and the card stays up long enough to read twice. Or change the words in Found Words, and make the card say it your way. What would you want it to say? Put everything back before Chapter 8.

Still stuck? Search the manual, or ask in the Myth Engine Discord (opens a new tab).

Your stages begin and end now, and each one leads to the next. In Chapter 8, the game gets its front door.