I am working on a top-down 2D tower defense game and I am trying to figure out how to work tile-based levels. I seem to have figured it out but not really sure where to go from here and I have some questions. Also I have included the two tiles I am using.
-Unless I use the \"color backdrop\" command, regard less of number used, the background with flash blue, which hasn\'t happened to me in other programs where I just used the \"backdrop off\" command.
-I cannot create the sprites inside a repeat loop like I have had to before, it has to be done outside and I\'m not sure why.
`set display mode 600, 480, 32
`backdrop off
color backdrop 1
type positions
xPos as integer
yPos as integer
endtype
tilePos as positions
tilePos.xPos = 0
tilePos.yPos = 0
spriNum as integer
spriNum = 1
data 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
data 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1
data 1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 2, 1, 1, 1, 2, 2, 1, 1, 1, 1
data 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1
data 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1
data 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1
data 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1
data 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1
dim firstArray(20, 8) as integer
load image \"grass.png\", 1
load image \"dirt.png\", 2
for y = 1 to 8
for x = 1 to 20
read firstArray(x, y)
next x
next y
for y = 1 to 8
tilePos.xPos = 0
for x = 1 to 20
sprite spriNum, tilePos.xPos, tilePos.yPos, firstArray(x, y)
inc spriNum, 1
tilePos.xPos = x * 32
next x
tilePos.yPos = y * 32
next y
repeat
cls
sync
until escapekey()
Any information as to how my code is or how I can get tile-based levels and collision to work would be appreciated.
On a side note, I have a game I have mostly finished, but I would like to have my code looked at to get advice on how I can make it better and maybe get some bugs fixed. Where on the forums would be the best place to post it. And again thanks for the help!