Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.

Guest Anonymous Poster

finite coords..what the..?

This topic is 7023 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

Guest Anonymous Poster
hello all! I am building a basic isometric engine..and have everything working except one thing...when i scroll the map..its currently scrolling 1 tile length (left, right, up, or down)

this makes for some pretty fast and choppy scrolling..i know that there is a way to scroll more smoothly using something i think is called 'finite coords' ? can anyone explain this method or point me in the right direction to figure it out?

thanks alot!!


Share this post

Link to post
Share on other sites
i know that Jim Adams has an article about this on the light befallen site.


fortunately, and unfortunately at the same time, i'm currently working on a program that demonstrates EXACTLY what you are asking about. (the unfortunate part is that i wont be done with it for a few days, or i could show you right now)

however, i will give a quick answer as to how you can solve your problem.

the issue here is in translation of screen coordinates(ScreenSpace) to world coordinates(TileSpace), and vice versa.

ScreenSpace is the viewable area of the screen. it is usually a rectangle.

so, for example, lets say you are doing a fullscreen application that runs in 640x480, but at the left hand side of the screen, you have a 64 pixel wide toolbar, at the top of the screen you have a 16 pixels menu bar, thus leaving you with the following rectangle:


const int TOOLBARWIDTH=64;
const int MENUHEIGHT=8;
const int SCREENWIDTH=640;
const int SCREENHEIGHT=480;

RECT rcScreenSpace;

and now lets say you want to also put an 8x8 pixel border inside this area.


const int BORDERWIDTH=8;
cosnt int BORDERHEIGHT=8;


now i've got the bounds of my screenspace (please note that since i've used constants,i have no idea what the actual coordinates of the screenspace are, and nor do i care, and nor SHOULD i care).

next, i'm going to determine by PlotSpace.

PlotSpace is exactly the same size as ScreenSpace, but with left and top at (0,0)


RECT rcPlotSpace;

converting between them is a simple matter




now, we are going to make plotspace talk to tilespace, through a tilespacewindow

to do this, we merely need to keep track of a single point, that is the corresponding point in tilespace to (0,0) in plotspace. this is an arbitrary point, and it is the key to scrolling your map. i.e. this is the value you change by whatever factor you like to scroll your map in any direction.

so, let us call this point ptTileSpaceWindow.

now, to calculate the position of the tilespace window:


RECT rcTileSpaceWindow;

now we have a method by which we can translate tilespace coordinates into plotspace coordinates




its important to note, at this point, that i'm breaking this down into more steps than it needs to be. you can translate from screen space to tilespace without utilizing plotspace, which is only included here for illustration purposed.

now, we want to determine if a given tile is within the viewable area. in order to do this, we need to know the world coordinates of the rectangle that will contain an individual tile.

the following code provides the equations for plotting staggered (offset) tilemaps as well as diagonal (diamond) tilemaps. most likely, your own equations will be similar to one of these.


//staggered map

//diagonal map

next we find the bounding rectangle of the tile.

LeftPad, etc are padding values, and may well be 0 depending on whether or not images stick out of the tile.


RECT rcTile;

now, we check to see if any of the tile bounding rect is within the tilespace window:


RECT rcIntersect;
BOOL bIntersects;
//the tile is viewable

if it is viewable, you can easily translate rcTile from tilespace to screenspace coordinates, also, you can use rcIntersect to clip the tile without too much trouble.

did i say this post would be short? i lied.

[This message has been edited by TANSTAAFL (edited August 30, 1999).]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!