Hi,
I am not using lime because I want random maps, so I’ve got this code which randomly generates tiles, however for one type of tile I want some physics properties, no matter where it is. Any way of doing this?
Thanks.
Here’s the code:
[code] local tilemaps =
{
{
{ 0, 0, 0, 0, 0, 0, 0, 0, },
{ 0, math.random (1,3), math.random (1,3),math.random (1,3), math.random (1,3), math.random (1,3),math.random (1,3), 0, },
{ 0, math.random (1,3), math.random (1,3),math.random (1,3), math.random (1,3), math.random (1,3),math.random (1,3), 0, },
{ 0, math.random (1,3), math.random (1,3),math.random (1,3), math.random (1,3), math.random (1,3),math.random (1,3), 0, },
{ 0, math.random (1,3), math.random (1,3),math.random (1,3), math.random (1,3), math.random (1,3),math.random (1,3), 0, },
{ 0, math.random (1,3), math.random (1,3),math.random (1,3), math.random (1,3), math.random (1,3),math.random (1,3), 0, },
{ 0, math.random (1,3), math.random (1,3),math.random (1,3), math.random (1,3), math.random (1,3),math.random (1,3), 0, },
{ 0, math.random (1,3), math.random (1,3),math.random (1,3), math.random (1,3), math.random (1,3),math.random (1,3), 0, },
{ 0, math.random (1,3), math.random (1,3),math.random (1,3), math.random (1,3), math.random (1,3),math.random (1,3), 0, },
{ 0, math.random (1,3), math.random (1,3),math.random (1,3), math.random (1,3), math.random (1,3),math.random (1,3), 0, },
{ 0, math.random (1,3), math.random (1,3),math.random (1,3), math.random (1,3), math.random (1,3),math.random (1,3), 0, },
{ 0, 0, 0, 0, 0, 0, 0, 0, },
}
}
local bg = display.newImage(“background.png”)
tilesheet = sprite.newSpriteSheet(“tileset.png”, 32, 32)
local tileset1 = sprite.newSpriteSet(tilesheet, 1, 4)
local spritemap = display.newGroup()
for y=0,11,1 do
for x=0,7,1 do
local tilesprite = sprite.newSprite( tileset1 )
tilesprite.x = x*32+20
tilesprite.y = y*32+20
spritemap:insert(tilesprite)
end
end
function loadlevel (level)
local i = 1
for y=0,11,1 do
for x=0,7,1 do
spritemap[i].currentFrame = tilemaps[level][(1+y)][(1+x)]+1
i = i + 1
end
end
end
loadlevel(1)[/code] [import]uid: 68047 topic_id: 13313 reply_id: 313313[/import]