Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your help!

We need 7 developers from Canada and 17 more from Australia to help us complete a research survey.

Support our site by taking a quick sponsored survey and win a chance at a $50 Amazon gift card. Click here to get started!

finite coords..what the..?

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:


Posted 30 August 1999 - 04:27 PM

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!!



#2 TANSTAAFL   Moderators   -  Reputation: 1158


Posted 30 August 1999 - 04:27 PM

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).]

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.