![]() |
|
Isometric madness |
logan666
Member #2,024
March 2002
![]() |
Hi, Im working in an isometric demo, up to now i got the projection working. I use this simple piece of code to get the job done for(my=0; my< 30; my++ ) } As you can read the map is 30 x 30, tiles are 64 x 32. The problem is how to draw only what is seen in a given moment and not drawing the entire map every time, so that drawing speeds up with bigger maps. Im still trying a couple of ideas I came up with but havent succeed. Any one has an idea to help solve this isometric maddness?:-[ ================ |
DanielH
Member #934
January 2001
![]() |
Figure out which tiles will be seen and only draw those. Take the camera position and use that as the center. Go out from the center a few tiles until you are sure that the view area will be completely covered. Then draw it. In my isometric game, I have a 14x14 grid of tiles, but I draw a 30x40 grid of tiles to cover any missing areas. The vertical postion at the bottom might need some extra if you have a height to the tiles. I have a few tall tiles. they were disappearing instead of scrolling of the screen. I had to adjust the height until they no longer 'disappeared'. The source code might not be understandable, but you can download my isometric source. 'Daython's Quest' from the link in my sig. Look under 'mygames'. I created a template for the grid size. I calculated the position of the template when the game is initialized. And I use that template throughout the game to find the position of the mouse, etc... |
spellcaster
Member #1,493
September 2001
![]() |
Don't draw diamond shaped maps. Simply draw the map the way you'd draw a normal rectangular map. But: For every row increase y only by half the tileh eight and offset x every other row by half the tile width. If you want diamond shaped levels, simply put only visible tiles there, and use transparen tiles around them. Did this make sense? -- |
lameDuck
Member #2,327
May 2002
![]() |
I'm curious again:) In an isomentric game, how to you handle the sprite drawing order. You must have to blit the one that are further away in the Y direction first? Or have I just answered it, loop through all the visible sprites checking their Y positions... |
DanielH
Member #934
January 2001
![]() |
You might want multiple layers. I have multiple layers. I draw the people sprites in the middle of drawing the walls. Draw all the that are farther away first. then draw the sprite. Then repeat for next sprite. and about the diamond shapes maps. Now you tell me. 0 1 2 3 4 5 6 7 8 9 A B C D E F And it was hard to draw it. That's when I came up with the template system. I calculated the position for each tile before hand. Then all I had to do to draw it was draw the tiles draw_map() |
logan666
Member #2,024
March 2002
![]() |
Daniel H what is the idea behind your template system ================ |
DanielH
Member #934
January 2001
![]() |
There are too many calculations done in the map drawing. By doing all the calculations once in the template there are very little left during drawing. So far I get 80+ FPS. |
lameDuck
Member #2,327
May 2002
![]() |
I like the idea. How daft is this. I'm barely 20% through my first game and I'm already planning my second!!!
|
spellcaster
Member #1,493
September 2001
![]() |
Draw the map like this: 0 1 2 3 4 5 6 7 8 9 a b c d e
Now imagine that the lines are half the tile height apart... like this: See? That way you can use a slightly altered rect map drawing algorithm. -- |
Oscar Giner
Member #2,207
April 2002
![]() |
spellcaster: I did my isometric engine just like you (only that I have also height, so it's semi 3D -- |
logan666
Member #2,024
March 2002
![]() |
Spellcaster: I got the isometric stuff working with non diamond shaped maps, think its a better way to go, thanks for the advice.8-) ================ |
spellcaster
Member #1,493
September 2001
![]() |
Glad I could help. -- |
DOAdal3t
Member #2,067
March 2002
![]() |
I'm dumb!... spellcaster shouldn't u know better... use the diamond-style, but use it different... sorry I give u the dignity to commup with the anwser...(it is much better than that odd/even stuff) so that were all the hints... [url http://home.wanadoo.nl/~mkmk/screen2%20copy.jpg] __________________ |
spellcaster
Member #1,493
September 2001
![]() |
Not sure what you want to tell me here? And writing a map editor is much more easy as well. -- |
DOAdal3t
Member #2,067
March 2002
![]() |
gay... but I now own u(if it is something new to you).. well I now own all the people who read it: so bow for me, I am the elite...(still searching for others) well enough about that;D 0 1 3 2 4 6 5 7 8 this is simpler isn't it... well it has more... __________________ |
spellcaster
Member #1,493
September 2001
![]() |
I still don't get it. IMO this adds one more step during the screen->map conversion process. Ok, so what do you gain if you draw your map this way? -- |
DOAdal3t
Member #2,067
March 2002
![]() |
I never need to worry about odd/even... so e.g. circles will be circles...8-) __________________ |
spellcaster
Member #1,493
September 2001
![]() |
Odd / even? Ok, guess i'm dumb, but: Help? -- |
DOAdal3t
Member #2,067
March 2002
![]() |
the algoritm to place the tiles(so that they overlap the good way) is fairly difficult in the other diamond way. and about the circles... in my way it is really easy to change diameter without a set of precalculated masks(U use that... I think?). I think u should relook the numbers...;) __________________ |
spellcaster
Member #1,493
September 2001
![]() |
Sorry, but I think you want to solve a problem which doesn't exist 0 4 1 7 5 3 8 6 9
That's the "normal" way to draw diamond shaped maps, with (0,0) at the top, and map-x increasing down right, y increasing left-right. And i'd really like to know how you draw circles without having the tiles containg the circle gfx? But the main problem with the diamond shaped map is the conversion from screen to map coords. -- |
DOAdal3t
Member #2,067
March 2002
![]() |
d00d, why did you not propose the "normal" way... Cos DanielH proposed: 0 1 2 3 4 5 6 7 8 9 A B C D E F
which is totally sick... But I still think that the "normal" way is better than the zigzaw way. take for instance the calculation of a guy on ht isometric tile-map... in the jigzaw-way u still need to worry about odd/even... and also for placement that is neccesary... as for the normal way... all is pretty straight forward... __________________ |
spellcaster
Member #1,493
September 2001
![]() |
Ok, assume you have a map drawn your way. Please tell me how do you translate a mouse pos into tile-coords? Also, since you need to increase both x and y for each tile, you have more work in your inner drawing loop. At the end of a row you need to do additional work to reset the starting position. Finding the correct number of tiles to draw per map row is also a problem since the number of visible tiles per map row differs... Having multiple levels (along the z axis) does also become more complicated, esp. inside an editor. Quote: take for instance the calculation of a guy on ht isometric tile-map... in the jigzaw-way u still need to worry about odd/even
Pardon? If the guy can move independently from the tile position (free movement) all I need are his world (screen) coords. Which can be translated to tile coords easily. But this is not needed, since you can do almost everything in screen coords (like sprite / sprite collision). So, in the worst case you need to convert screen to tile coords, which is almost as cheap as with normal rect maps. -- |
DanielH
Member #934
January 2001
![]() |
My map is like this 0 4 1 8 5 2 C 9 6 3 D A 7 E B F but I draw it in this order. That was a problem. 0 1 2 3 4 5 6 7 8 9 A B C D E F By determining which tiles go where and when, the drawing was easy. All I have to do is supply which tile is at pos 0. Then the map template program does all the work. Very easy very quick. I have varying size tiles, width and height. So I also check to see if any are inside the drawing area before trying to draw them. That saves time also. About the tiles, the bases are all the same. 64x32, but you can have anysize object. Just center it vertically in the tile and adjust it so that the bottom of the object is in the center of the tile. |
spellcaster
Member #1,493
September 2001
![]() |
Ok, since both of you use diamond shaped maps... if you have a map which is way larger than the screen, how do you guys determine the upper left tile? -- |
DOAdal3t
Member #2,067
March 2002
![]() |
d00ds... think....So I was right, u people don't get it(well at least danielH)... The drawing order IS: 0 4 1 8 5 2 C 9 6 3 D A 7 E B F
And just for the info... my tile-map=3000*3000 tiles(32*32 bitmaps see my screenshot), and it is wrapped(looping) __________________ |
|
|