Getting started
GenoCode is a small language for making creatures, and an app where you write them, see them in 3D, breed them, morph them and watch them dance to music. This guide takes you from a first ball to a creature with genes and parts. The full rules are in the language reference.
The app
The app has six modes, along the top:
- View shows the creature, with its code beside it. Change the code and the creature follows as you type. The panel on the right has a slider for every gene, to try other values.
- Breed shows a grid of variations. Click creatures to choose them as parents, then Mutate or Breed for a new grid. Double-click one to open it.
- Morph blends a creature into its variants and back, in a loop.
- Dance moves the creature to music: a music file, a web address, the microphone or another browser tab.
- Patterns designs the textures and backgrounds creatures wear.
- Library has the creatures that come with GenoCode, and everything you've saved in the browser.
Start in the Library: open a few of the starter creatures, look at their code, and move their gene sliders. Every one of them was written in the language this guide describes.
A first creature
Press New and replace the code with this:
creature Snowman
// Three balls, one on another, each smaller than the last.
pitch -90
shape ball
repeat 3 {
lay
forward 0.8
grow 0.75
}
A GenoCode creature is drawn by a turtle: an invisible pen that moves and turns in 3D, and lays shapes where it is.
creature Snowmannames the creature. The comment below it describes it.pitch -90turns the turtle to face up. It starts facing you.shape ballpicks the shape it lays:ball,cube,cone,tube,ringordonut.repeat 3 { … }runs the block three times. Each time,laylays a ball,forward 0.8moves the turtle up, andgrow 0.75makes everything after it three quarters the size.
Moves are measured in the turtle's own size, so after grow 0.75 the next forward 0.8 goes three
quarters as far. That's why each ball sits neatly on the one below.
Genes
A gene is a value that can change when creatures mutate, breed and morph. Give it a range, and the app gives it a slider:
creature Snowman
// Balls one on another, each smaller than the last.
gene balls = 3 in 2..6 step 1 // how many balls
gene shrink = 0.75 in 0.5..0.95 // each ball's size compared with the one below
gene snow = hsv(200, 0.1, 1) in hsv(0, 0, 0.6)..hsv(360, 0.5, 1)
pitch -90
shape ball
colour snow
repeat balls {
lay
forward 0.8
grow shrink
}
gene balls = 3 in 2..6 step 1starts at 3 and can be any whole number from 2 to 6. The comment at the end of the line is the gene's description, shown in the gene panel.snowis a colour gene:hsv(hue, saturation, value), with the hue in degrees round the colour wheel.- Now press Breed: every creature in the grid is a snowman, each with its own genes.
Parts
A part is a named piece of a creature that can be laid again and again, with its own genes:
creature Snowman
// Balls one on another, each smaller than the last, with a carrot nose on the top one.
gene balls = 3 in 2..6 step 1 // how many balls
gene shrink = 0.75 in 0.5..0.95 // each ball's size compared with the one below
gene snow = hsv(200, 0.1, 1) in hsv(0, 0, 0.6)..hsv(360, 0.5, 1)
pitch -90
shape ball
colour snow
repeat balls {
lay
forward 0.8
grow shrink
}
grow 1 / shrink
back 0.8
nose
part nose {
gene reach = 1 in 0.3..2
gene carrot = hsv(28, 0.9, 1) in hsv(0, 0.5, 0.5)..hsv(60, 1, 1)
pitch 90
yaw 40
forward 0.4 + reach / 2
shape cone
colour carrot
lay { grow (0.25, 0.25, reach) }
}
- After the loop,
grow 1 / shrinkandback 0.8take the turtle back to the middle of the top ball.noseon its own line then runs the part there. lay { … }changes only the shape being laid. Here it stretches the cone into a carrot.- A part's genes belong to it: in the gene panel they're
nose.reachandnose.carrot.
Variants, morphing and dancing
A variant is another set of gene values for the same creature:
variant Tall { balls = 6; shrink = 0.9 }
Add that line at the end of the snowman and press Morph: the snowman grows into the tall one and back. In Dance, music carries it through the same loop. Pick a music file, or the microphone, and a dance style.
Creatures can also read the music directly: music.bass, music.level and the others run from 0
to 1 as the music plays, and time counts the seconds. For example, grow 1 + 0.2 * music.bass
makes everything swell with the bass.
Blocks
Press Blocks in View to see the code as blocks, beside the code itself. Drag blocks in from the palettes on the left, and the code is written for you. Change the code, and the blocks follow.
- A number that is a gene's value opens a slider. A colour has a swatch that opens a colour picker.
- A comment above a statement is a note on its block (the ?). A gene's description is the last row of its block.
Textures and backgrounds
Shapes can wear textures, and a creature can carry its own background:
creature Marble_Ball
// A ball of marble, on an aurora.
shape ball
texture pattern(marble, 200, 7, dusk, pearl)
lay
background {
fill pattern(aurora, 160, 12, dusk)
}
The Patterns mode is the easiest way to find recipes like these: try kinds, hues, schemes and finishes, breed the ones you like, and Copy code or Use as background.
Saving and sharing
- Save keeps a creature in this browser; it then appears in the Library under "Yours".
- Download saves the
.geniefile, and Open file opens one. Opening a background or dance file while a creature is on show offers to put it into the creature. - Picture in View saves a picture of the creature as it's shown.
Where next
- Open the starter creatures in the Library and read their code: each is a worked example.
- The language reference has everything else: functions, vectors, gradients, symmetry, the music inputs, dance styles and how mutating, breeding and morphing work.