166
edits
m (→A simple tile map: +comments) |
(→A simple tile map: Tilesize) |
||
Line 484: | Line 484: | ||
<syntaxhighlight lang="nasal" enclose="div"> | <syntaxhighlight lang="nasal" enclose="div"> | ||
var (width,height) = (768,512); | var (width,height) = (768,512); | ||
var tile_size = 256; | |||
var window = canvas.Window.new([width, height],"dialog") | var window = canvas.Window.new([width, height],"dialog") | ||
.set('title', "Tile map demo"); | .set('title', "Tile map demo"); | ||
Line 547: | Line 549: | ||
# simple aircraft icon at current position/center of the map | # simple aircraft icon at current position/center of the map | ||
g.createChild("path") | g.createChild("path") | ||
.moveTo( | .moveTo( tile_size * center_tile_offset[0] - 10, | ||
tile_size * center_tile_offset[1] ) | |||
.horiz(20) | .horiz(20) | ||
.move(-10,-10) | .move(-10,-10) | ||
Line 592: | Line 594: | ||
for(var x = 0; x < num_tiles[0]; x += 1) | for(var x = 0; x < num_tiles[0]; x += 1) | ||
for(var y = 0; y < num_tiles[1]; y += 1) | for(var y = 0; y < num_tiles[1]; y += 1) | ||
tiles[x][y].setTranslation(int((ox + x) * | tiles[x][y].setTranslation(int((ox + x) * tile_size + 0.5), int((oy + y) * tile_size + 0.5)); | ||
if( tile_index[0] != last_tile[0] | if( tile_index[0] != last_tile[0] |
edits