Make it dusk
You'll learn: that a game has many rules, and how to find them.
Time: 5 minutes.
Try itOpen this lesson in the Bitflinger Games app to try it.
The code
func _ready() -> void:
Variations.set_rule("sky.time", 14.0)
sky.time is the hour of the day, on a 24-hour clock. 14.0 is two in the
afternoon. Starter World reads this rule to colour the sky, move the sun and
light the lamps.
Change it
Set it to 19.0 for dusk:
Variations.set_rule("sky.time", 19.0)
Play. The sky turns orange and purple and the lamps start to glow.
Try this
22.0is night. The lamps are the brightest thing in the world.6.5is sunrise.- Put the line from lesson 1 under this one, so your game is fast and at dusk. A layer can change as many rules as it likes:
func _ready() -> void:
Variations.set_rule("sky.time", 19.0)
Variations.set_rule("player.speed", 14.0)
Which rules are there?
Starter World has these rules. The value is what it starts with.
| Rule | Starts at | What it does |
|---|---|---|
player.speed | 7.0 | How fast you run |
player.jump_height | 2.6 | How high one jump goes |
player.double_jump | true | Whether you can jump again in the air |
world.gravity | 24.0 | How fast you fall |
world.fall_limit | -40.0 | How far you can fall before you start again |
sky.time | 14.0 | The hour of the day, from 0 to 24 |
true is another kind of value. It means yes, and false means no. Try
setting player.double_jump to false.
What you learned
- A game can have many rules, and your layer can change several.
- Values can be numbers, like
19.0, or yes and no, writtentrueandfalse.
Next: When the game says no.