Alterna · учебный материал
Worlds and levels
44.2: How to describe levels, nets, obstacles and reproducible worlds for the Canvas shell.
Что в этом материале
- Map is a data structure
- Why do you need a seed?
- Level Design Test
- Rewrite the world generator
Содержание и основные понятия
A good level can be replicated, checked and changed, and for this purpose it is kept separately the geometry of the world and separately the rules by which the host renews the character.
Modelling
grid
seed
01
Map is a data structure
Materiality
Minimum data
The Canvas shell point
Background
Color and dimensions
sets boundaries and contrasts.
Obstruction
x
,
y
, width, height
becomes a rectangle on Canvas
Subject
center, radius, color
becomes a circle or a map marker.
Signature
text, coordinates, size
Explains the rules and purpose without hidden logic
canvas.size(640, 400)
canvas.clear("#0b1328")
canvas.rect(180, 110, 170, 22, "#a78bfa")
canvas.circle(100, 90, 12, "#fcd34d")
canvas.text("Портал", 550, 310, "#34d399", 18)
02
Why do you need a seed?
If a random generator starts with the same seed, the sequence of values is repeated. This allows us to go back to a good world, find an error in a particular version, and compare two changes to the rules on the same map.
Move the density of the objects, then update the seed. At one density, the new seed creates another map; the same seed repeats the original structure.
▦
Cell world generator
Object density
03
Level Design Test
Start
The player shouldn't appear inside the wall, leave a free radius around the starting point.
Objective
The target must have a route. If there are obstacles, at least check it manually.
Signal
Color, signature, and contrast help to distinguish the obstacle, object, and exit before moving.
04
Rewrite the world generator
The whole generator is open. Change the number of columns, the condition of the wall or the color. Space creates the next seed; the arrows move the grid marker.
Code Editor uploads...