Sign in to follow this  

Beginner Question to scrolling in iso3D

This topic is 4863 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi@All I am new here and I try to program a diamond-shaped Isometric engine. I have a Loop, which draws all my Tiles to Screen. Many Tiles go over the screen out, so I have bad performance in scrolling them all. Do you know, what is the easiest way, to optimize scrolling, so that it is good in performance ? Here is my Draw-Routine (cx,cy = Cameraview) for (int y=0; y < tileCountY; y++) for (int x=0; x < tileCountX; x++) { int posX = cx + (x-y)*tileWidth/2; //Calc to Screen int posY = cy + (x+y)*tileHeight/2; //Calc to Screen tileMap[y][x]->draw(posY,posX); } Now, if I modify the cx,cy vars, it is not very smooth, cause ALL tiles will be drawn. Do you know, how I could optimize this ? Which calculation should I do ? Or do you know a good Tutorial ? Thanks :-) finalbrain

Share this post


Link to post
Share on other sites
Is the animation smooth but too slow, or is the problem that the animation is too jerky? One thing that will probably help is, rather than looping through all of the tiles, use the size of the viewing frustum and the tile size to compute which of the tiles are visible in a given frame and just loop through those.

Share this post


Link to post
Share on other sites
Yes thats a good Idea..but I cannot find the right computation...please..can someone give me some hints how to compute this ? (It is smooth but the slower the more Tiles!)

Current situation:

[image]www.finalbrain.de/pictureA.jgp[/image]

Wanted Situation:

[image]www.finalbrain.de/pictureB.jpg[/image]



[Edited by - finalbrain on August 21, 2004 12:55:01 PM]

Share this post


Link to post
Share on other sites
I've done this using square tiles, but it should work for any shape. First, You don't have to make a precise calculation, because a little off-screen business, won't hurt.

In 3d space, I would assume that how ever you move the camera, the camera x and y roughly corrospond to the x and y of the tile that displays in the middle of the screen. It should be possible to find a corrospondance between the camera and the tile that happens to be in the center screen. With square tiles, I always draw tile[x][y] at world coordinates x,y to simplify this step.

To find out which tiles you need to render, simply count the tiles up and down that fit along the height and width of your screen (in case of diamond tiles, these would be the tiles that stack point-to-point). Add one or two to each count, for tiles that will only partially fit on the screen. Call these the local tile counts, I guess .

instead of starting with y and x equal to zero, use the indeces of your center tile and subtract half the verticle local tile count for the y, and half the horizontal local tile count for x. Of course instead of tileCountY, use the center tile y index plus half of the verticle local tile count, and so on.

Share this post


Link to post
Share on other sites

This topic is 4863 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this