Hello again, last question for a while, I promise! I’ve spent a few hours off and on the last two days to get the tile placement correct. Using your example above, I’ve successfully been able to place tiles in the correct coordinates. What I can’t fiqure out, is how to determine what type of tile to place in the coordinates. I have a Read/Data for the tile type that should be placed, it I can not seem to place it properly in the code so that it works.
DIM tiletype(1 to 3) AS LONG ‘tile graphics to draw
tiletype(1) = _LOADIMAGE(“sprites\grass.png”,32)
tiletype(2) = _LOADIMAGE(“sprites\snow.png”,32)
tiletype(3) = _LOADIMAGE(“sprites\mountains.png”,32)
RESTORE mapdata ‘reads 1,2 or 3 to determine what type of tile to place
FOR k = 1 to 84
READ mapdata
Next k
‘This sections decides the location in order to place tiles to create a map
TYPE tiles
x AS INTEGER
y AS INTEGER
END TYPE
DIM tiles(1 to 84) AS tiles ‘reads tile location for placement
RESTORE tiletypedata
FOR t=1 to 84
READ tiles(t).x, tiles(t).y
_PUTIMAGE(tiles(t).x, tiles(t).y), tiletype(mapdata) ‘ mapdata = 1, 2 or 3 as read from the mapdata
NEXT t
mapdata:
DATA 1,1,1,1,2,2,1,2,1,2,1,3,1,1,2 etc... until 84 entries
tiletypedata:
DATA 1,1,81,1,161,1 etc... until 84 entries
I believe I need to nest the coordinate getting inside the first set, so the logic order will be:
Read the map data to find type of tile (1 to 3)
Read the coordinates to place tile
_PUTIMAGE
Repeat 83 more times via For\Next
The results of my efforts vary depending on where I place things, but I haven’t been able to nail it down so it works properly. I’m guessing my fault is in the first data retrieval, for if I substitute a 1,2 or 3 in the _PUTIMAGE line, it draws a screen, but only of the 1,2, or 3 type of tiles. OR, when reading the tile type data, it reads the whole line and not bit by bit, so the Putimage gets goofed up. I tried putting “next k” at the end of the program instead of where it currently is, so every loop the it reads one tile type, them does the coordinates stuff, then loops back to the tile type, but it didn’t work.
Thank you for any insight, I greatly appreciate it. Utilizing the help you gave me above, will save me tremendous amounts of typing time