The second problem is kind of engine specific (depending on how you store your current view location) and I'm too tired (12:30 AM EST) to answer it, so I'll let someone else help you out with that.
- Splat
The second problem is kind of engine specific (depending on how you store your current view location) and I'm too tired (12:30 AM EST) to answer it, so I'll let someone else help you out with that.
- Splat
it is a three part transformation, as well, although it can all be accomplished in a single step.
the first step is to convert from mapspace coordinates into tilespace coordinates.
your mapspace is the map itself. all implementations of a tilebased map that i've ever seen involve a two dimensional array, or a one dimensional array that acts as a two dimensional array.
so, invariably, you have a mapx and mapy, which is a tile. depending on the type of map you are using, you convert this x,y into a tilespace x,y with one of the following methods:
the iso calcs are based on the TILEWIDTH and TILEHEIGHT of a typical tile. the hex calcs are based on the mousemap's width and height. (in all honesty, you can use the mousemap width and height for iso, too, since the tile and mousemap are the same size)
Staggered Iso Map(as in Civ II):
tilespacex=mapx*TILEWIDTH+mapy*(TILEWIDTH/2);
tilespacey=mapy*(TILEHEIGHT/2);
Diagonal(or Diamond) Iso Map(as in AoE):
tilespacex=mapx*TILEWIDTH/2-mapy*TILEWIDTH/2;
tilespacey=mapx*TILEHEIGHT/2+mapy*TILEHEIGHT/2;
(based on a diagonal map where tile 0,0 is the uppermost tile)
for either of these styles for hex, use the MMWIDTH and MMHEIGHT instead of the tile's height and width
tilespace to plotspace
the second transformation is from tilespace (which represents the pixel locations for the entire map) to plotspace, which is a rectangle that is the same size as the area to which you will be blitting on the screen. in many cases, plotspace and blitspace are the same, and you can stop with this one:
somewhere in your program, you store the tilespace equivalent of the upperleft corner of your plotspace, and to convert from tilespace to plotspace, you subtract this coordinate from the tilespace x and y.
if you screenspace and plotspace are the same (meaning the entire screen), you can stop here. otherwise, you just add whatever to the coordinates to give you the proper screenspace coordinates.
this is an odd question, actually, since people seem to have more trouble converting the other way.
Get off my lawn!
/Niels
The real advantage (and not that big) is when you have complex clipping areas that are made up of many overlapping rectangles. Then, DirectDraw clippers allow you to ignore that complex aspect until later when you profile your game and its deemed that your game is bogging down on the clipping.
- Splat
primarily, though, clippers are used for windowed DX apps, where they are the most useful and update themselves automatically.
Get off my lawn!
Also please forgive any spelling,and lack of grammer its(3am right now and i just got back from a long long day and am tired)
- Splat
1. if my backbuffer is the same size as the screen, how do i blit the current section of map onto the screen without getting errors by trying to blit off the surface
2. how do i convert map coordinates into screen coordinates? do i just do:
sprite.x = spritemap.x-map.x;
sprite.y = spritemap.y-map.y;
thanks in advance
-Delta Rho
I will never go back.
And I would guess a good way to do clipping is to separately test your
x,y components. And perhaps check for exclusions first (if bitmap is
not visible on the screen, just return from the function), rather than
checking for equalities and matches.
However, that would only be good for things like units, but probably not
for background tiles since you are always blitting the visible tiles anyway.
Reaver
[This message has been edited by Reaver (edited November 12, 1999).]