LevelComp
:The level component.
group
Component Types
tileWidth
(): numbertileHeight
(): numbernumRows
(): numbernumColumns
(): numberspawn
(sym: string, p: Vec2): GameObj | nullSpawn a tile from a symbol defined previously.
spawn
(sym: string, x: number, y: number): GameObj | nullspawn
(obj: CompList<T>, p: Vec2): GameObj<T> | nullSpawn a tile from a component list.
returns
The spawned game object, or null if the obj hasn't components.
spawn
(sym: CompList<T>, x: number, y: number): GameObj<T> | nulllevelWidth
(): numberTotal width of level in pixels.
levelHeight
(): numberTotal height of level in pixels.
getAt
(tilePos: Vec2): GameObj[]Get all game objects that's currently inside a given tile.
raycast
(origin: Vec2, direction: Vec2): RaycastResultRaycast all game objects on the given path.
tile2Pos
(tilePos: Vec2): Vec2Convert tile position to pixel position.
tile2Pos
(x: number, y: number): Vec2pos2Tile
(pos: Vec2): Vec2Convert pixel position to tile position.
pos2Tile
(x: number, y: number): Vec2getTilePath
(from: Vec2, to: Vec2, opts?: PathFindOpt): Vec2[] | nullFind the path to navigate from one tile to another tile.
returns
A list of traverse points in tile positions.
getPath
(from: Vec2, to: Vec2, opts?: PathFindOpt): Vec2[] | nullFind the path to navigate from one tile to another tile.
returns
A list of traverse points in pixel positions.