addLevel(map: string[], opt: LevelOpt): GameObj
Construct a level based on symbols.
param
map- The map data.
param
opt- The level options.
addLevel([ " $", " $", " $$ = $", " % ==== = $", " = ", " ^^ = > = &", "===========================", ], { // define the size of tile block tileWidth: 32, tileHeight: 32, // define what each symbol means, by a function returning a component list (what will be passed to add()) tiles: { "=": () => [ sprite("floor"), area(), body({ isStatic: true }), ], "$": () => [ sprite("coin"), area(), pos(0, -9), ], "^": () => [ sprite("spike"), area(), "danger", ], } })
returns
A game obj with the level.
since
v2000.0