I have recently been trying to create a wraparound scroll system like Defender's and have downloaded some sample code that I have tried to convert. I have had a bit of success as it now wraps endlessly to the right. However, when I scroll to the right, turn round and go back to the left, the map stops at its origin, I assume because the render routine is only designed to go one way. Can anyone help or give me some advice on this? Here is the current render routine:
Function RenderMap (map%, x_offset%, y_offset%)
ty% = y_offset / TileHeight (map)
sy% = -(y_offset Mod TileHeight (map))
While sy < SCREEN_HEIGHT
ty% = ty Mod MapHeight (map)
tx% = x_offset / TileWidth (map) ; tile x ?
sx% = -(x_offset Mod TileWidth (map)) ; screen x ?
While sx < SCREEN_WIDTH
tile% = GetTile (map, tx Mod MapWidth (map), ty Mod MapHeight (map))
DrawTile map, sx, sy, tile ;
tx = tx + 1
sx = sx + TileWidth (map)
Wend
ty = ty + 1
sy = sy + TileHeight (map)
Wend
End Function
If you need more of the code I can post that too.
Many thanx
Bungee
Function RenderMap (map%, x_offset%, y_offset%)
ty% = y_offset / TileHeight (map)
sy% = -(y_offset Mod TileHeight (map))
While sy < SCREEN_HEIGHT
ty% = ty Mod MapHeight (map)
tx% = x_offset / TileWidth (map) ; tile x ?
sx% = -(x_offset Mod TileWidth (map)) ; screen x ?
While sx < SCREEN_WIDTH
tile% = GetTile (map, tx Mod MapWidth (map), ty Mod MapHeight (map))
DrawTile map, sx, sy, tile ;
tx = tx + 1
sx = sx + TileWidth (map)
Wend
ty = ty + 1
sy = sy + TileHeight (map)
Wend
End Function
If you need more of the code I can post that too.
Many thanx
Bungee