From: | Andrew Crowe |
Date: | 13 Aug 2001 at 18:16:19 |
Subject: | [amiga-c] Re: isometric gfx engine |
Hi David
> Wow, I was thinking about this last night and now it appears on a mailing
> list :) If you find any good info I'd appreciate if you could let me
> know. Please? :)
>
> The easiest way, like Andrew said would be to draw everything from back
> to front, but IMO that would be wasteful if you have lots of objects
> which would obscure things (e.g. buildings in Syndicate). There must be
> some trick to it for the speed. Syndicate flies on my 060, and I can't
> remember how fast UFO is, but I know it's a bit slower (although
> Syndicate only has 8 or 16 colours). But even on the 020, Syndicate was
> always a lot faster than UFO.
>
> I guess if the view is always fixed in one direction, you could have some
> special flags for some tiles, e.g. for making them solid, but not to
> display. Could be useful for say the backs of objects which would never
> be seen, but 'physically' have to be there.
What you could do is, if you dont want to redraw all the tiles, is to keep a z-buffer of the same size as the game area, and to write the "depth" of all the objects you paste onto the screen
eg. for each tile
for(x=0;x<width;x++){
for(y=0;y<height;y++){
if(tile[x,y]){
buffer[x+tileoffsetx,y+tileoffsetx]=tile[x,y]
zbuffer[x+tileoffsetx,y+tileoffsetx]=tiledepth
}
}
(obviously you'd have that loop optimised ;)
Then when you're drawing sprites
for(x=0;x<width;x++){
for(y=0;y<height;y++){
redrawbuffer=buffer[x+spriteoffsetx,y+spriteoffsetx]
// Dont forget to buffer the area under sprites if your not redrawing each frame
if(sprite[x,y]){
if(spritedepth>zbuffer[x+spriteoffsetx,y+spriteoffsetx]){
buffer[x+spriteoffsetx,y+spriteoffsetx]=sprite[x,y]
}
}
}
}
Well there you go, I'm not sure how well that would work in practice but it works nicely in theory :)
If you wanted faster you'd have to use rather complex procedures of calculating what tiles are infront of the sprites without keeping a z buffer then to either clip or paste ontop of the sprites
Andrew
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/