Determine what to draw in an isometric map

BlitzMax Forums/BlitzMax Programming/Determine what to draw in an isometric map

plash(Posted 2009) [#1]
Currently my tilemap renders like this (no special doings to draw to the full size of the screen).

Map data is in rows of columns, when rendering the screen positions are calculated for isometric.

What would be the best/fastest way to determine where to start and end drawing so that the whole screen is filled with tiles?


slenkar(Posted 2009) [#2]
are those 2d images?

if so you have to just off set the co-ords to minus 100 so you are drawing off the screen


plash(Posted 2009) [#3]
It's not that simple.

The map data is in top-down format.. non isometric.

Row 0: 0, 0, 0, 0, 0
Row 1: 1, 1, 1, 1, 0
Row 2: 1, 0, 0, 1, 0
Row 3: 1, 1, 1, 1, 0
Row 4: 0, 0, 0, 0, 0

When they get drawn, the tile positions are transformed
http://img23.imageshack.us/img23/3032/tmisotrans.png

So simply increasing the number of rows and columns to draw from the starting point will just make the box larger (that would *work*, but it would be a waste, because there would be many tiles drawn outside the viewport).


Ginger Tea(Posted 2009) [#4]
first off
the first image is not isometric it is just rotated 45 degrees
isometric tiles are diamond shaped and a cube would look like a hexagon

second to fill the screen with tiles you would need to have a larger array than the screen as you would be trimming off some off screen parts

i need to find an image to explain better what i mean


plash(Posted 2009) [#5]
It's an isometrically projected map.

Clearly the example I gave in my last post is a tiny map.

The image in the first post is actually 100x100 tiles (much much larger than the screen), I am just taking 0,0 to about 16x16.


Ginger Tea(Posted 2009) [#6]
i take isometrically projected to be diamond squares hexagonal cubes like we had in the old q*bert alien 8 games, where as that image looks just "rotated 45 degrees"


plash(Posted 2009) [#7]
http://en.wikipedia.org/wiki/File:IsometricFlaw_2.svg
Wikipedia must be wrong then, clearly those floor-like tiles are not 'isometric'.

That is exactly how I am rendering my tilemap, but with height changes to simulate a terrain.


Jesse(Posted 2009) [#8]
why bother making shure the background is all full, most ismoetric tile engines show empty outer edges when displaying corners on maps. some just display a background image. and some just limit the walking area so no outer edges are displayed but I think its a waste of resources. Even 3D games like C&C Generals display a black background outer edge.


plash(Posted 2009) [#9]
@Jesse: I know that. I'm talking about non-corners.

In the shot above only the top-left and top-right sides are corners (no more map data in those directions), the other sides do have more data in their directions though (which is what I want to make it render so that the screen is as full as possible).

I'm just trying to get the rendering to display as much as possible to the screen size.


Jesse(Posted 2009) [#10]
I started working on a tile engine a while back but I gave up due to my lack of time. the way did it:
first I would find out how many tiles fit across and down the display area. Determining how many tiles across will determine how many tiles down I need to move. To display 8 tiles across I had to move the map 8 tiles down:
mapShiftY = (8* tileHeight)/2 

sence tiles are spaced half the tile height I have to divide by 2.
the same goes for displaying tiles down.

There might be a better way but this is how I did it a while back. I don't have the source anymore else I would post it.

ignore it if I missunderstood you.


kenshin(Posted 2009) [#11]
two stage process:

- Do a tile flood fill from the centre of your screen. Check whether each tile is visible on screen. If it is, you then store the relative offset of each visible tile in a list/array, as in relative to centre screen but stored as map co-ordinates. You only need to do this once. So now you have made an array of map offsets from centre screen, as in 2,2...-3,4 etc...only these are the offsets which actually lie on the visible screen, none of which are completely offscreen.

- When you need to render, you can work out which map location is sitting in the screen centre and then use the offset list you built previously to determine which tiles will need to be rendered.

Note: With your flood fill, it will be better to have a 'border' of one extra map tile around the edge of your screen otherwise you will occasionally see background at the edges as you scroll around.


AramusM(Posted 2009) [#12]
http://www.gamedev.net/reference/list.asp?categoryid=44 is a good place to have a look. it has lots of info on tile maps. Standard, Isometric and Hex tile maps covered.