- Learn
- Build a Game
- Chess
- Making What a Card Shows
Making What a Card Shows
Every piece of Chess comes to you in two parts. The first is a story. It’s a few paragraphs that put the piece in your head: what it does on the Board, and roughly how. The second is a card, the same piece written out exactly, with every name and every number. Read the story. Then look at the card with that picture in mind, and build.
This page is about the cards. Each passage shows how to make one kind of thing in Myth Engine, in the editor’s own words. You don’t need all of it today. Read the first passage, Before your first card, and then start Chapter 1. Each chapter sends you back here the first time a card needs a passage. A paragraph that opens with a later chapter, such as From Chapter 4, can wait until then.
The editor will feel strange at first. That’s true for everyone. It passes, and somewhere in the first few chapters your hands start finding things before your eyes do.
Before Your First Card
Everything your game is made of lives in the Resources panel, down the left side of the editor: its Objects, its Logic, its tables, its pictures and its Scene. To make something new, press Add at the bottom of that panel. The Add Resource window asks what kind of thing it is. Double-click anything in the Resources. It opens in a tab of its own. Right-click it for a menu with Rename, Duplicate and Delete.
A card lists what you change. Nothing more. Whatever it leaves out stays the way the editor makes it.
One exception: a Text the card shows as (empty), or with nothing after its type, must be empty. If its box holds something, clear it.
From Chapter 2, a few blocks come from Advanced Mode. Chapter 2 needs three of them, the Actions that change a Data Table while the game runs: Set Data Cell, Reset Data Table and Control Data Row. Chapter 7 adds Tween and Run Code (JS). Chapter 10 adds the Draw Event, Draw Line and Set Draw Color. To see them, choose Settings > Advanced Mode at the top of the editor. The bar along the bottom says Advanced mode enabled. Only the editor changes. Your game stays exactly as it was.
To run your game, press Play, the triangle at the top of the editor. The game opens in a window of its own. Stop, the square beside it, closes that window. Save as you go with Ctrl+S, at the end of every part at least.
The Set Up Card
Each chapter opens with a Set up card. It holds everything that isn’t an Object or its Logic: pictures, settings, keys, and where things stand in the Scene. Each block starts with a heading in capitals. Here is Chapter 1’s. That chapter goes down it one line at a time.
Chess96011009601100Smooth TexturesMSAA (Hardware)#F4F1E9Chess Table · 2DART names the pictures the chapter is about to use. They’re in your project already. The Starter Kit brought every one of them in Chapter 1, so there’s nothing to make. The list only says which ones matter now: here, the Walnut Board and the Carved Walnut Pieces.
GAME SETTINGS lines say where each setting lives. Take GAME SETTINGS > Display > Window. Press Game Settings, the button at the top of the Resources panel. Choose Display, and find the Window group. The names under the heading are its fields, and you enter them in the card’s order, top to bottom. Where the order matters, the chapter says why.
A SCENE block marked (new) is a Scene the chapter makes. In Chapter 1, it’s the one Scene your new project already has, given the card’s name: Chess Table. To reach a Scene’s own settings, open it and pick Select, the arrow above the preview. Then click an empty spot. The Scene’s Properties appear on the left. Click the Background Color swatch, type the card’s code into the HEX box, and press Enter. A second click on the swatch closes it.
Start Scene comes after the Scene for a reason. It’s a list of your Scenes by name, and Chess Table is on it only once the Scene has that name.
PLACE THESE says what goes in the Scene, and where. Open the Scene and pick Place, the button beside the arrow, and the Place Scene Content panel opens on the left. Your Objects are near its bottom. They’re under Predefined Objects. Press one there, then click once in the preview, and it lands where you click. Then pick Select, click what you placed, and type the card’s X and Y into its World Position, in meters. An Object with no picture, such as the Game Rules, shows nothing in the preview. The Scene Explorer on the right lists it all the same, so click it there.
From Chapter 3, some placements stay put on the screen. The Status Line comes first, and the panels and buttons follow. Their X and Y go into Screen Offset (px), counted in pixels from the point their Screen Anchor picks. The anchor is one of nine dots in the placement’s Transform. The Status Line’s is the bottom middle of the screen, so its Y lifts it that many pixels above the bottom edge.
A placement marked hidden starts out of sight. Turn off its Visible at Game Start, near the top of its Properties.
From Chapter 3, GLOBAL VARIABLES are values the whole game shares, such as the words on the Status Line. On a card a Global has a $ in front, as in $status. That’s how you tell it from the others. You make one from any Logic Component. Open it, and down the left side of its canvas sits a small card named Globals. Press the + on it and choose New Global…. The Add Global window asks for a Name, a Type and a Default, the value it starts at. Type the name without the $. Some lines have nothing after “starts at”, because those start empty, so leave the Default clear.
From Chapter 4, GAME SETTINGS > General > Game State lists the states the game can be in, such as Playing and Promotion. Your project has Playing already. For each new one, press Add Game State under Available Game States. Type its Game State Name. Then press the window’s own Add Game State button. Each card lists every state, with the new ones last.
From Chapter 6, CHANGE THESE PLACEMENTS names placements already in the Scene, and what each one needs now. Take “move to X 0, Y 105”. Select that placement, and type the new numbers over the old ones.
From Chapter 2, REMOVED names something the game no longer needs. Right-click it in the Resources, and choose Delete at the bottom of the menu.
Chapter 12 brings COMMANDS and INPUT CONTEXTS, the game’s keys. They have a passage of their own, near the end of this page.
A Placement’s Own Values
From Chapter 4, some lines under a placement start with “with”. Each is a value only this placement has. The four Promotion Buttons are one Object, placed four times, and the line with Data Structure > Values > Kind = Queen is what makes the first one the Queen’s button.
Select the placement in the Scene, and its Properties open on the left. A Data Structure value sits in the placement’s Data Structure part, under Values. There’s one box for each field. The editor writes each field’s name its own way, so kind shows as Kind. Type the card’s value into it, with no quote marks.
The line with Z-Index = 29 is the placement’s Z-Index, under Rendering, and a higher number is drawn in front.
From Chapter 6, a line may end with (Edit Object Locally). Its value belongs to one of the Object’s components, such as the words on a button. Press Edit Object Locally, near the top of the placement’s Properties, and the Object’s components open for this one placement. Pick the component, and change the card’s field. The editor marks that component Override, because it now differs from the Object’s own. Back to Scene brings you back.
From Chapter 7, a line such as with Per Instance Variables > Slide = Rook sets a value this one placement keeps for itself. Look in the placement’s Logic part, near the bottom of its Properties. Under the Logic’s name sits Per Instance Variables. It has one box or switch for each. The editor writes slide as Slide, and saysWhenLanded as Says When Landed. A Yes or No is a switch: on is Yes.
An Object Card and Its Components
An Object is a thing in your game: the Board, a Piece, a button, the words under the Board. Make one with Add > Object. The Create Object window asks for the card’s name and an Object Type. The card tells you which type.
When the card’s Transform says Presentation > Space Window / UI, the Object is a Screen UI Object. It lives on the screen, measured in pixels. Its Space and Render Layer are set already. Its Bounding Box starts at 32 by 32, and it comes with UI Interaction attached.
Every other card in Chess is an Empty Object. It starts with a Transform and nothing else, and you attach what the card lists. No Object in this game needs a Collider, so none of them is a 2D Object.
Here is the Board, from Chapter 1. It lays out every Square when the game starts.
X 30, Y 30Walnut BoardX 30, Y 30Lay Out The BoardLay Out The Board DataPieceRank LabelFile LabelThe card lists the Object’s components, with the fields to change under each one. A component gives an Object one ability. Sprite shows a picture, and Text / UI shows words. Data Structure gives the Object a small form of values to carry, and UI Interaction lets the player press it. Transform is on every Object from the start. It says where the Object is and how big.
In the Object editor, Attached Components is the list at the top right. The Component Toolbox sits under it, in closed groups. Open a group, and click a component to attach it. Sprite and Text / UI are under Rendering, and Data Structure is under Data. When you select a component in Attached Components, its Properties open on the left, and the card’s lines are those Properties, in order.
A Sprite asks for its picture first. The Add Sprite Component window lists your pictures, so pick the card’s and press Add Sprite. Scene Depth (Draw Order) decides which Object is drawn over which. The higher number wins. The Piece’s 10 keeps it over the Board. Transform > Size is how big the picture is drawn, in meters for a thing on the Board and in pixels for a thing on the screen. That’s the Sprite’s own Transform, inside its part, with Positioning on Independent. When a card gives a Sprite a Transform > Position too, it goes there, right above Size.
From Chapter 4, a card can give a Sprite a Tint, a color laid over its picture. It’s under the picture, in the Sprite’s Appearance, right after Frame. Click the Tint swatch. Type the card’s code into the HEX box.
The Transform’s Bounding Box is a box the Object keeps for its own size, apart from its picture. It doesn’t change the picture. Type the card’s numbers into its Size all the same, so your Object matches the game’s.
A new Data Structure component starts on the first Data Structure in your project. Pick the card’s in its Data Structure list. Here, that’s Square Info.
A Text / UI’s Font Size is a box. Emphasis has a B button, an I button and a list of weights, and the Rank and File numbers use Extra Bold from that list. Color is a swatch: click it, type the card’s code into the HEX box, and press Enter. Alignment is a row of three choices. Center is the middle one.
Once, in Chapter 12, a card gives Font Style Italic, from that field’s own list. When a card gives Text Bounds Wrap to Width, pick it before you type the Size X under it.
A Text / UI has a Transform of its own, the place of the words inside their Object. Leave its Positioning on Independent. Type the card’s X and Y into its Position. The File Label’s X of 1.575 and Y of -1.388 tuck its letter into the bottom-right corner of its Square.
A Text with braces in it shows a live value, one that changes while the game runs. Type it into the Text field as the card spells it, braces and all. So {$status} follows the Global. And {kind} follows the field named kind in the Object’s own Data Structure.
On a Screen UI Object, UI Interaction comes attached. Its Element Type says whether the player can press it, as a Button, or only read it, as a Text. Its Group is a name the pieces of one panel share, so they show and hide together. A card that says (as it is added) means: leave its fields as they come.
Logic comes last on an Object card. It isn’t in the toolbox. Switch the list at the top right of the preview from Components to Logic. Now Attached Logic is on the left, and Compatible Logic is on the right. Click each Logic Component the card names. It joins Attached Logic, with a small switch at its left end, blue while it’s on.
Some Logic brings a Data Structure of its own. The Board’s card shows one, From Logic Lay Out The Board. Attaching that Logic adds the Data Structure to the Object too, so there’s nothing to do for it.
The lines under Shared Variables come after the Logic, because the Logic brings them. Switch the list back to Components. At the top of the Properties, under Variables, each Shared Variable the Logic gives this Object has a row: a name box, its Type, its Kind and its Value. A line under each says where it came from: From Logic: Lay Out The Board. A card line such as pieceObject Piece is that Value.
Each kind of Value takes the card’s in its own way. A number or a word goes into the Value box as the card writes it. On the File Label, shows is fileLetter, typed bare. An Object Value is a button with an Object’s name on it. Press it. Pick the card’s, so pieceObject becomes Piece. A Color Value is a swatch, with a HEX box beside it, as Show Label’s two colors are.
A Data Structure Card
A Data Structure is a small form of named fields, and an Object carries one filled-in copy. Every Piece carries a Square Info. It holds the name of the Square the Piece stands on. Make one with Add > Data Structure. The Create Data Structure window asks only for its Name, and a new one starts with no fields at all. Here is Square Info, the first one you’ll make, in Chapter 1.
Which Square of the Board an Object stands on. name: the Square's name, a1 to h8, which is its row in the Position table.
The sentence under its name is its Description. If you’d like it, type it into the Description box under the Name. The game never reads it, but months from now, you will.
Press Add Field for each line. A field has a Name, a Type and a Value, and the card’s default goes in Value. Where the card says default (empty), as Square Info’s does, the Value stays clear. A Boolean is a yes or a no. Its Value turns into a switch. The card writes its default as false or true, and false is No.
Three kinds of Data Structure have a job beyond an Object, and their names say which. One whose name ends in Data, such as Lay Out The Board Data, is what one Logic Component remembers on its Object. You make it here, from its card, and the Logic Component card shows where it goes. One whose name ends in Result, such as Square Position Result, is what a Function hands back. You make it here too. One whose name ends in Entry is the shape of one row of a Data Table. That one you don’t make here at all. Myth makes it with its table, as the Data Table passage shows.
A Logic Component Card
A Logic Component is a piece of behavior you attach to an Object: how a Piece shows itself, or how the Game Rules judge a click. Make one with Add > Logic Component. The Create Logic Component window asks for a Name and a Starter. Leave the Starter on Empty Logic Component. This card is from Chapter 1. It writes the number or letter at the edge of each Square.
Writes the Rank number or the File letter of the Square this label stands on (its Square Info), read from the Position table: shows names the column (rank, or fileLetter). It writes it in a color that stands out on that Square: labelOnLight on a light Square, labelOnDark on a dark one (a Square is dark when its File and Rank add up to an even number, as a1).
Any Objectself.squareInfoText / UI- Name
squareShade- Value
0
- Name
rank- Value
0
- Name
file- Value
0
- Component Value
self.text.text- Value
data('Position', self.squareInfo.name, @self.shows)
- Variable
file- Value
data('Position', self.squareInfo.name, 'file')
- Variable
rank- Value
data('Position', self.squareInfo.name, 'rank')
- Variable
squareShade- Value
(file + rank) % 2
squareShade == 1- Component Value
self.text.color- Value
@self.labelOnLight
- Component Value
self.text.color- Value
@self.labelOnDark
The top of the card names the Logic Component, and the Object you’ll attach it to in this game. The sentence under the name is its Description. The Attach to line under that is the Logic Component’s own setting. Leave it at Any Object, where a new one starts.
A new Logic Component opens on a big, empty canvas, crossed by a grid. Down its left side sits a column of small cards: Logic Component, Globals, Data Structures, Components, Per Instance Variables and Shared Variables. Each has a + in its corner, and the card’s blocks of the same names are made with them. The first one folds open to show the Name, the Description and Attach to. Type the Description there, if you’d like it. The game never reads it.
DATA STRUCTURES name the Data Structures this Logic reads on its Object. Make each one first, from its own card. Then press the + on Data Structures, and pick it under Existing Data Structures. Myth gives it a name of its own, and the card’s row shows it: Square Info self.squareInfo. The Logic reads every field through that name, as self.squareInfo.name. A Data Structure whose name ends in Data, such as Lay Out The Board Data, goes in the same way. Its fields are what this Logic remembers from one moment to the next.
COMPONENTS name a component of the Object that this Logic changes, such as self.text Text / UI. Press the + on Components, and pick Text / UI under Component types. The row then reads self.text. So self.text.color is the color of this Object’s words.
SHARED VARIABLES are values this Logic keeps on each Object it’s attached to, and each Object can set its own, as the Board’s card does. Press the + on Shared Variables. The Add Shared Variable window asks for a Name, a Kind, a Type and a Starting Value. Its Kind starts on Changeable, so pick the card’s, Constant on every one in this game. Then press Add. In the Logic, a Shared Variable reads with an @ in front: @self.shows.
The card’s last column holds the Starting Value. A Text one goes in bare: Show Label’s shows starts at rank, with no quote marks. A Color one is a swatch, with a HEX box. An Object one starts at None, and each Object that carries the Logic picks its own.
From Chapter 7, PER INSTANCE VARIABLES are values each placement of the Object keeps for itself. Press the + on Per Instance Variables. The Add Per Instance Variable window asks for a Name, a Type and a Starting Value, the card’s last column. In the Logic it reads with no @, as self.slide.
The rest of the card is its Events, each with its Actions. The next passages are about those.
An Object Variant
From Chapter 6, many buttons look alike and do different jobs. The Flip button and the New Game button are the same tan button, with different words and different Logic. Each is a variant of one Object, Tool Button. A variant keeps everything its Object has, and adds what makes it different.
A variant’s card is short, because it lists only what the variant adds, and its top names the Object it’s a variant of. Here is the Flip Button’s card, from Chapter 6, where the first variants come in.
It adds one thing, Report Flip. Make the Object first, from its card. Right-click it in the Resources and choose Add Variant…. The Add Object Variant window asks for its name, so type the card’s, such as Flip Button. Press Create Variant. The variant shows in the Resources under its Object. A small V marks its icon.
The variant opens in the Object editor, like any Object. Its pictures and words are the Object’s. Leave them be. Switch to Logic, and click the Logic Component it adds, such as Report Flip, under Compatible Logic. A Shared Variable it changes sits under Variables, marked from the base Object. Type the card’s value over it.
To place a variant, place its Object from Predefined Objects, as usual. Then open the placement’s Object list, near the top of its Properties, which holds the Object and every variant of it. Pick the card’s.
Events: The When Bars
An Event is a moment your Logic waits for: the Scene starting, a click on a Square, a message arriving. Each Event on a card starts with a plain heading, such as On Board Laid Out. That’s the name Myth gives the Event by itself, from its kind and its setting, so you never type it. It’s also the name you’ll pick when an Action asks for an Event.
Under the heading is the When bar. It names the kind of Event. Then comes its setting, if it has one: a Mouse button, a Timer name or a Command.
Press Add Event, the + in the canvas’s toolbar. Its window has a filter at the top, so type the kind’s name there, pick it, and press OK. Scene Start, Create, Game Start, UI Activated, Game State Changed and Draw ask nothing more.
The Event lands on the canvas as a big green block, with a smaller one beside it, joined by an arrow. That smaller block is the Event’s Mode, named Mode 1. Its Actions hang below it in one line. A card’s Event with one way of answering shows no Mode at all. Leave Mode 1 as it is. A Logic Component can have many Events, and they all sit on the one canvas, each with its own line. The buttons at the bottom of the canvas zoom it, and Fit shows the whole of it at once.
From Chapter 2, Mouse Pressed on Object asks for its Mouse button in a second window. It offers left, right and middle. Pick the card’s, left, and press OK again.
From Chapter 7, a Recurring Timer has a name you make up, so its second window can’t list it. Choose Type a timer name… and press OK. Then type the card’s name into the small window that comes next.
From Chapter 12, Command Pressed asks for its Command in a second window. So does 2D Direction Pressed. Chapter 12 shows where its Direction goes.
Most Events in Chess are a Custom Event, though. That’s a message one piece of Logic sends and others listen for, like a bell rung in one room and heard in another. Its When bar names the message, such as boardLaidOut. To listen for a new one, type Custom into the Add Event window’s filter, pick Add Custom Event…, and press OK. A window asks for its Event Name. Type the message, and press OK. Once some Logic sends that message or listens for it, it’s on the list already.
You can build the sending and the listening in either order. Trigger Custom Event rings the bell for every Object that listens. Trigger Custom Event on Object rings it for one Object only, the one its Applies to names. Either one’s Custom Event field takes the name exactly as you type it. So you can send a message before anything listens.
Modes: One Event, More Than One Way
From Chapter 7, some Events behave in more than one way. Each way is a Mode, with its own name and its own line of Actions. When the Board turns over, the Moving Piece either stays hidden or lands at once. It depends on whether a slide is under way. On a card, each Mode is a line under the When bar, such as Mode: Stay Hidden (Starting Mode). The card shows such an Event once for each of its Modes, each time with the same heading and When bar. Two headings alike are one Event with two Modes.
Name the first Mode: right-click Mode 1 and choose Rename Mode…. Type the card’s name. For each of the others, right-click the Event’s block and choose New Mode…, and type its Mode Name. Each new Mode gets its own block, to the right of the last, with its own line.
An Event with several Modes shows Modes on its block, with two choices. Every Event in Chess stays on One at a Time, as it starts, so one Mode answers at a time. The card marks the one it starts with, (Starting Mode), and you pick that one in the block’s Starting Mode list. A Mode marked (no Actions) stays empty. While it’s the one that answers, the Event does nothing at all.
Switch Mode changes which Mode answers, while the game runs. Its block picks an Event and a Mode. Each comes from a list of names, so the order you build in matters. The Event list gives each Event by its heading, with the Object that carries it after a dot. Pick the card’s, even when it’s the Event the block is in. Then the Mode list holds that Event’s Modes. So make the Event and its Modes first, and the Switch Mode that picks them last.
Actions, One at a Time
Under each Event, the numbered rows are its Actions, in order. On the canvas they’re blocks, joined by arrows into one line that runs down from the Mode. The Action List on the right holds every Action, in closed groups. Type an Action’s name into the search box at its top. Click it, and its block appears.
A new block lands a little to one side, apart from the line, with no arrow into it. A block like that does nothing when the game runs, however right its values are. So right-click it and choose Connect to Sequence. It joins the end of the line, and an arrow runs to it. Join each Action as you add it.
When an Event has several Modes, each Mode has a line of its own. To add an Action to one of them, right-click that Mode’s block, or a block on its line, and choose Add Unattached Action Here. A window opens with the Actions in it. Pick one and press OK. Its block lands near that line, and Connect to Sequence joins it there.
From Chapter 4, a new step sometimes goes between two old ones. Order matters there. Click the round handle at the bottom of the block it should follow, then the round handle at the top of the new block. To put it first, start from the Mode’s block. It has a bottom handle too. The handles join blocks of one panel only, though, and an If’s panel is its own. So between two blocks inside an If’s or a Repeat’s panel, add the new block with that block’s own Add Inside item first.
Fill in the fields the card lists, and leave the rest the way they start. Each field is a small box or list on the block. An Action with no lines under it, like the Set Alpha in Show Piece’s Otherwise panel, is whole: add it, join it, and leave it alone.
Declare Variable makes a value for one run of its Event. Its block reads Declare, with a Type list, a name and a value. The Type starts at Number. When the card gives a Type line, such as Text, pick it there. The value goes after the =. A Text with no Value line starts empty. When the Event’s Actions finish, the value is gone, and the next run makes it again.
Some Actions have an Applies to line, naming the Object they work on. Without one, they work on this Object. On the block, Applies to is a list, and it starts on Self. In a Function it lists the Objects the Function is handed, such as piece in Chapter 2.
A Change Variable sets one Variable to a Value. Its block reads Set. Type the Variable as the card writes it, such as boardLeft. The block may show it as self.boardLeft, which is the same value, written its own way. A name before the dot, as in piece.name, means another Object’s: here, the Piece that Create Instance made a moment before.
Beside the Variable is an Operator list. It starts at =, and then the Value replaces what the Variable held. With += the Value is added on, and with -= it’s taken away. With *= the Variable is multiplied by it. No Operator line on the card? Then it’s =.
Change Component Value changes one field of a component, the one its Component Value path names. Type the path as the card spells it. Take self.text.color, from Show Label. It’s the color field of this Object’s Text / UI, whose name on the canvas is self.text. So self.text.text is that Text / UI’s own words. A path through a Data Structure works the same way. self.layOutTheBoardData.squareName is the squareName field of the Lay Out The Board Data the Board carries.
The next three paragraphs come with Lay Out The Board, at the end of Chapter 1.
Create Instance makes a new Object while the game runs. Its Object to Create names what kind. In a Logic Component, it’s one of the Logic’s own Object Variables, as @self.pieceObject. In a Function, it’s one of the Function’s Object Parameters. The new Object needs a name for the Actions after it. That’s its Created As box: type the card’s name over the one it starts with, such as piece.
Some Actions hand back an answer. On the card their first line is an Action Name. On the block it’s the last box, after the word as, and it holds a name of Myth’s to start. Type the card’s name over it, with no quotes. A later Action reads the answer by that name, so spot.x is the x that a Square Position named spot found.
A Function goes in like any Action, from the Functions group of the Action List. The card marks it with a small Function tag. Its fields are the Function’s Parameters, by their names. An Object Parameter’s field is a list, and a new call starts it on self. The other fields are boxes, and you type their values as the card gives them.
From Chapter 7, Run Code (JS) has one box for its code. Type it exactly as the card has it.
Values, Quote Marks and All
Every value on a card is written the way its box should hold it. A plain name, such as kind, is a value this Logic declared, or a Function’s Parameter. A $ in front marks a Global, as in $status, and an @ a Shared Variable, as in @self.squareMeters. A value can be a small formula, too. The formula data('Position', square, 'file') reads one cell of the Position table. It’s the row named by square, in the column file.
Most boxes read a formula. In those, a word needs quote marks, so the card gives it with them, like 'Position' in data('Position', square, 'file'). Without them, the block turns red. The box took the word for the name of something else. A few boxes hold a word as you type it, such as a Custom Event’s name and a Text’s Starting Value. The card gives those bare. So it does a Table or a Logic Component, which you pick from a list.
Which kind is a box? You don’t have to work that out for yourself, because the card already did. A word the card shows in quotes goes in with them. A word it shows bare goes in bare.
Single and double quote marks do the same job, so 'Position' and "Position" are one word to Myth. Type whichever the card shows. And "" is two quote marks with nothing between them, a word with no letters.
A Yes or No is a list or a switch that holds the two, as on a Boolean’s Starting Value. In a formula, it’s the word true or false. The card shows which.
If, Else, Repeat and While
An If runs some Actions only when its condition is true. It’s in the Action List’s Logic group. On the canvas it’s a wide, pointed block, and a line marked True runs down from it. That line is the card’s Then panel. Join the If itself to the line with Connect to Sequence, like any block.
Its condition is the one box on the If. The card gives it after the word If. Click the box, type it whole as the card spells it, such as kind == "", and press Enter. A condition can join two tests. && means and: both have to be true. || means or: one is enough. Type them into the same box. A red edge means a name in it isn’t one this Logic knows, so check the spelling against the card.
To put a block on the True line, right-click the If and choose Add Inside Then. A window opens with the Actions in it, and a filter at the top. Pick the Action and press OK. It lands under the If, not joined yet, so right-click it and choose Connect to Sequence. It joins the end of the True line. With one If inside another, right-click the If whose line the card’s step is on.
The card’s Otherwise panel is the If’s Else, the Actions for false. Right-click the If and choose Add Else. The Else appears beside the If, on a line marked False. Right-click the Else and choose Add Inside Else for each of its Actions, and join each one. Otherwise gets a step number, but you won’t find it in the Action List.
From Chapter 2, an Otherwise sometimes asks a question of its own. On the card, it’s an Otherwise with an If right under it, at the same indent, as in steps 4 and 5 of Square Marks. On the canvas, it’s one block. That’s an Else If. Right-click the If and choose Add Else If. Type the second condition into it. Its own steps go in with its Add Inside Then, and its own Otherwise with Add Else.
The step numbers count right through the panels. So step 4 may sit inside an If that began at step 3, and the indent shows where each one belongs. A step at an If’s own indent, right after it, comes after the If instead of inside it. That step is on the line the If is on. Add it from the Action List. Join it with Connect to Sequence.
The next paragraph comes with Lay Out The Board, at the end of Chapter 1.
A Repeat runs its Each time panel a set number of times. That’s its Count. Its box is on the Repeat block itself. Lay Out The Board’s Count is dataCount('Position'), the number of rows in Position. So it runs once for each of the 64 Squares. Right-click the Repeat and choose Add Inside Repeat for each Action in the panel, and join each one. Inside a Repeat, local.index says which time round it is, counting from 0.
From Chapter 2, a While runs its Each time panel again and again, for as long as its condition holds. Its condition is on the block, and you type it the way you type an If’s. Right-click the While and choose Add Inside While for each Action in the panel. Something inside has to change the condition sooner or later. Otherwise the loop never ends. In Follow Direction, each time round leaves one step fewer.
A block that went into the wrong panel can move. Right-click it and choose Cut, right-click the block it should follow and choose Paste, then join it.
A Function Card
A Function is a small piece of Logic that does one job when it’s asked. Square Position, from Chapter 1, answers where the middle of a Square is. Make one with Add > Function. The Create Function window asks only for its Name.
Answers where the center of a Square is in the world, in meters. square: the Square's name (a1 to h8). squareMeters: how wide one Square is. boardLeft and boardBottom: where the Board's bottom-left corner (a1's corner) is. x and y (Outputs): the center.
- Name
file- Value
0
- Name
rank- Value
0
- Name
x- Value
0
- Name
y- Value
0
- Variable
file- Value
data('Position', square, 'file')
- Variable
rank- Value
data('Position', square, 'rank')
- Variable
x- Value
boardLeft + (file - 0.5) * squareMeters
- Variable
y- Value
boardBottom + (rank - 0.5) * squareMeters
- x
x- y
y
Its card has PARAMETERS, RETURN TYPE and ACTIONS. There’s no Event. Its line starts at a block marked Start, and its Actions run each time another piece of Logic calls it. The first Action you add lands apart from the line. Connect to Sequence joins it under Start. Its Description, if you’d like it, goes in the Function’s own card, at the top left of its canvas.
PARAMETERS are the values the Function is handed. Make them on its Start block, under Parameters, with the + there. The Add Parameter window asks for a Name, a Type and a Default, the card’s Starts at. Object, Data Structure and Function are at the very end of the Type list.
From Chapter 2, an Object Parameter has more lines. Look for Structural and Required Components under it. After you add it, press the pencil beside its name on the Start block. Its window has a Compatibility Mode, Nominal or Structural. Pick the card’s. For each Required Component, press Add Required Component, and pick the card’s Component Type. A Data Structure has one more line, its Required Schema, such as Square Info. Fill in the Slot Name last, such as squareInfo. That’s how Show Piece On Square reads the Square of the piece it’s handed, as piece.squareInfo.name.
RETURN TYPE says what the Function hands back. A Function that hands back nothing has no RETURN TYPE line. Square Position hands back two numbers at once, x and y, so it hands back a Data Structure that holds both: Square Position Result. Make that Data Structure first, from its card. Then open the Function’s own card, the one at the top left of the canvas, and pick it in its Return Type list.
The last step is a Return, from the Action List. Its block has one row for each field of the Return Type. Type the card’s value into each row. Square Position’s x hands back the x it worked out.
A Data Table Card
A Data Table is a spreadsheet the game reads while it plays, one row for each thing. Make one with Add > Data Table. The Create Data Table window asks only for its Name.
A new table makes a Data Structure of its own, named after it with Entry on the end. You’ll find it under Data in the Resources. Each of its fields is a column of the table. Its card comes right before the table’s, as Kinds Entry comes before Kinds.
One row of the "Kinds" Data Table, which follows it. One row per Kind of Piece, one column per Side. White and Black: the frame of the Piece Set art that shows this Kind for that Side (every Piece Set art keeps the same frame order). The columns are named for the Sides, so the Side of a Piece picks its column.
06174102839511Open the Entry, and press Add Field for each line, with the card’s default in its Value. The table shows the same columns at once. Its Entry Type list names that Data Structure, so leave it where it is.
Then the rows. Add Row sits under the grid. A new row starts with every column’s default, so set the defaults first, and you’ll type only what differs. A row’s name goes in the grid’s Entry column. Double-click a cell to type in it. Enter keeps what you typed.
The card counts rows from Row 0, and the editor numbers them from 1. So the card’s Row 0, King, is the first row on your screen.
Position is long: 64 rows, one for each Square. You won’t type them. Its card gives the table as a file to download, under IMPORT CSV. Make its Entry’s fields first, exactly as the card lists them. Then press Import CSV, beside Add Row. Pick the file. Myth Engine asks first, Import CSV Into Position? Press Import CSV again. The card’s FIRST ROWS show how the table begins, so you can check yours against them.
From Chapter 10, a column can hold a color. Its field’s Type is Color, and each cell takes the card’s code.
A Library Card
From Chapter 7, the Computer thinks with a chess program called Stockfish. It comes into your game as a Library: a file of code the game carries inside it. Its card is short. Myth fills in most of it for you.
stockfish-bridge.js, from the zip781.9 KBstockfishBridgeStockfishBridgeClassic BuildMake one with Add > Library, and the Create Library window asks for its Name. After Create, a window called Add a Library offers ready-made Libraries. You don’t need one. Press Close.
Download the zip from the card’s File line. Unzip it. Right-click it, choose Extract All…, then Extract. Back in Myth, open the Library’s Source section, and press Import .js…. Pick stockfish-bridge.js in the new folder. Myth reads the file and sets the Type and the Global Name by itself.
It also guesses the Alias (Lib.Ext….) from the file’s name. Type the card’s over it. That’s stockfishBridge, the name your Logic calls the Library by.
In Chapter 8, the Library’s file grows, and a Changes card says so. Import .js… again, with Chapter 8’s file.
Keys: Commands and Input Contexts
In Chapter 12, the game learns to listen to the keyboard. COMMANDS on the Set up card are its keys, each under a name your Logic uses. Your Logic asks whether Press Square was pressed, and never cares whether that was Enter or Space.
Open Game Settings and choose Input Manager. On its left are the Input Contexts. Each one is a set of Commands that work together, and your project has one, Default. Beside them is the Command Set. It shows the Commands of the context whose row is selected.
Press Add Command. A small window opens. It asks for the Command Name and the Input Type: Button or 2D Axis, in this game. Its own Add Command button makes it. A new Button Command has one row that reads No Input Assigned. Click it, and press the card’s key. Add Keybinding adds a row for a second key, such as Space beside Enter. A 2D Axis Command comes with a row for each direction, and each one takes its key the same way.
INPUT CONTEXTS says which Commands belong to which context. Default gets five. A new context, Promotion Choice, gets three of its own. Press Add Input Context, and type its Input Context Name in the window that opens. The new context starts Inactive at Start. Its row is selected, so the Commands you add next go into its Command Set. While the game runs, the Action Set Input Context Active turns a context on or off.
Changes Cards
From Chapter 2 on, the game changes what you’ve already made. A Changes card shows the whole piece with the changes marked, so you can find your place. Lines marked Add, in green, are new: add them. Lines marked Delete, red and struck through, are gone. Delete them. To take a block off the canvas, right-click it and choose Delete. Deleting an If, a Repeat or a While takes the blocks on its own lines with it, so nothing is left behind.
A struck step keeps the number it had, right above the steps that take its place. Every other step shows its number as it is now. Sometimes a step stays and only its values change. Then the new values are green, with the old ones struck under them. The Description at the top is always the new one, and it’s never marked. When most of a piece is built again, as Square Marks is in Chapter 3, the chapter gives its whole new card instead, and says what’s new.
When an Event’s When bar is struck, with a new one in green above it, the Event changes. Right-click the Event’s block and choose Change Event…. Pick the new kind, and a window asks Change Event? Press Change Event. Its Modes and their Actions stay.
This one, from Chapter 2, changes Show Piece. Its steps move into a Function of their own, so a second Event can run them too. A call to that Function takes their place in each Event. And Show Piece Data goes with them, so its row under DATA STRUCTURES is struck. On the canvas’s Data Structures card, press the bin beside its row.
Shows the Piece that stands on this Piece Object's Square: once the Board is laid out (Lay Out The Board sends "boardLaidOut"), and again after every Move (the Game Rules send "positionChanged").
Any Objectself.squareInfoself.showPieceData- Type
Text- Name
kind
- Variable
kind- Value
data('Position', self.squareInfo.name, 'kind')
kind == ""- Alpha
0
- Component Value
self.showPieceData.side- Value
data('Position', self.squareInfo.name, 'side')
- Frame
data('Kinds', kind, self.showPieceData.side)
- piece
self
- piece
self
If Your Game and a Card Disagree
It will happen. A value lands in the wrong box, or a step goes in the wrong panel. That’s how everyone learns this.
A piece that does nothing at all? Look first for a block with no arrow into it, and join it with Connect to Sequence. A block drawn in red, and a number on the Errors bar under the canvas? Open the bar. It says which block, and what it misses. Count its quote marks. A Mode that never answers? Look at the Event’s Starting Mode, and at the Switch Modes that should turn it on.
Every chapter’s Goal also holds that chapter’s finished project as a download. Chapters 1 to 6 give one project file. From Chapter 7 the download is a zip, so unzip it first. Open the project with File > Open Project…. If yours has changes you haven’t saved, Myth offers to save them first.
Find the piece that misbehaves. Go down it line by line against yours, until the two part ways. The download’s canvases hold a few things yours won’t. Green notes, comments, sit beside the blocks, and none of them changes how the game plays. Or start the next chapter from the download. It already holds the whole Starter Kit. Nothing you built is wasted, because now you know where everything goes.
Chapter 1 begins with a new, empty project. It ends with a walnut Board on a page the color of paper, and thirty-two Pieces waiting on it.
