Isometric coordinate conversion is now only applied to rendering the tiles.

This commit is contained in:
Justin Marshall
2020-06-27 09:49:41 -07:00
parent 2a74c0750e
commit 4e1be3e1cb
3 changed files with 38 additions and 44 deletions
+18 -12
View File
@@ -1756,17 +1756,6 @@ bool DisplayClass::Coord_To_Pixel(COORDINATE coord, int &x, int &y) const
if ((int)yoff <= TacLeptonHeight + EDGE_ZONE*2) {
x = Lepton_To_Pixel(xoff)-CELL_PIXEL_W*2;
y = Lepton_To_Pixel(yoff)-CELL_PIXEL_H*2;
// jmarshall - isometric
int tileWidth = CELL_PIXEL_W;
int tileHeight = CELL_PIXEL_H;
int sx = (x / CELL_PIXEL_W) * (tileWidth / 2) - (y / CELL_PIXEL_W) * (tileWidth / 2);
int sy = (x / CELL_PIXEL_W) * (tileHeight / 2) + (y / CELL_PIXEL_W) * (tileHeight / 2);
x = sx + (CELL_PIXEL_W / 2);
y = sy + (CELL_PIXEL_W / 2);
x = x + (ScreenWidth / 2);
// jmarshall end
return(true);
}
}
@@ -2323,6 +2312,19 @@ ObjectClass * DisplayClass::Cell_Object(CELL cell, int x, int y) const
}
}
// jmarshall - isometric
void DisplayClass::ConvertCoordsToIsometric(int& x, int& y) {
int tileWidth = CELL_PIXEL_W;
int tileHeight = CELL_PIXEL_H;
int sx = (x / CELL_PIXEL_W) * (tileWidth / 2) - (y / CELL_PIXEL_W) * (tileWidth / 2);
int sy = (x / CELL_PIXEL_W) * (tileHeight / 2) + (y / CELL_PIXEL_W) * (tileHeight / 2);
x = sx + (CELL_PIXEL_W / 2);
y = sy + (CELL_PIXEL_W / 2);
x = x + (ScreenWidth / 2);
}
// jmarshall end
/***********************************************************************************************
* DisplayClass::Redraw_Icons -- Draws all terrain icons necessary. *
@@ -2360,6 +2362,8 @@ void DisplayClass::Redraw_Icons(void)
int ypixel;
if (Coord_To_Pixel(coord, xpixel, ypixel)) {
ConvertCoordsToIsometric(xpixel, ypixel);
CellClass * cellptr = &(*this)[coord];
/*
@@ -2390,7 +2394,7 @@ void DisplayClass::Redraw_Icons(void)
void DisplayClass::Redraw_OIcons(void)
{
for (int y = -Coord_YLepton(TacticalCoord); y <= TacLeptonHeight; y += CELL_LEPTON_H) {
for (int x = -Coord_XLepton(TacticalCoord); x <= TacLeptonWidth; x += CELL_LEPTON_W) {
for (int x = -Coord_XLepton(TacticalCoord); x <= TacLeptonWidth; x += CELL_LEPTON_W) {
COORDINATE coord = Coord_Add(TacticalCoord, XY_Coord(x, y));
CELL cell = Coord_Cell(coord);
coord = Coord_Whole(Cell_Coord(cell));
@@ -2405,6 +2409,8 @@ void DisplayClass::Redraw_OIcons(void)
if (Coord_To_Pixel(coord, xpixel, ypixel)) {
CellClass * cellptr = &(*this)[coord];
// ConvertCoordsToIsometric(xpixel, ypixel);
/*
** If there is a portion of the underlying icon that could be visible,
** then draw it. Also draw the cell if the shroud is off.
+7 -4
View File
@@ -41,11 +41,11 @@
struct Image_t;
// jmarshall - isometric
#define ICON_PIXEL_W 48
#define ICON_PIXEL_H 24
#define ICON_PIXEL_W 24
#define ICON_PIXEL_H 12
// jmarshall end
#define ICON_LEPTON_W 512
#define ICON_LEPTON_H 256
#define ICON_LEPTON_W 256
#define ICON_LEPTON_H 128
#define CELL_PIXEL_W ICON_PIXEL_W
#define CELL_PIXEL_H ICON_PIXEL_H
#define CELL_LEPTON_W ICON_LEPTON_W
@@ -222,6 +222,9 @@ class DisplayClass: public MapClass
*/
int TacPixelX;
int TacPixelY;
// jmarshall
static void ConvertCoordsToIsometric(int& x, int& y);
// jmarshall end
/*
** This is the coordinate that the tactical map should be in at next available opportunity.