DisplayTacticalCoord will now store the result instead of recalc everytime its needed.

This commit is contained in:
Justin Marshall
2020-07-22 13:34:21 -07:00
parent c123e39770
commit 3f697a2509
3 changed files with 25 additions and 7 deletions
+3 -4
View File
@@ -1241,11 +1241,10 @@ bool DisplayClass::Scroll_Map(DirType facing, int & distance, bool really)
int neighborCellX = weights[crude].x * (distance * 0.4f);
int neighbotCellY = weights[crude].y * (distance * 0.4f);
DisplayTacticalCoord newCoord = TacticalCoord;
newCoord.x += Pixel_To_Lepton(neighborCellX);
newCoord.y += Pixel_To_Lepton(neighbotCellY);
newCoord.AddPixelXY(neighborCellX, neighbotCellY);
int sx = Lepton_To_Pixel(newCoord.x);
int sy = Lepton_To_Pixel(newCoord.y);
int sx = Lepton_To_Pixel(newCoord.GetX());
int sy = Lepton_To_Pixel(newCoord.GetY());
CellClass::ConvertCoordsToIsometric(sx, sy);
sy += (ScreenWidth / 4);
sy += ScreenHeight / 2;
+15 -3
View File
@@ -10,17 +10,29 @@ DisplayTacticalCoord::DisplayTacticalCoord() {
DisplayTacticalCoord::DisplayTacticalCoord(COORDINATE coord)
{
SetFromCoordinate(coord);
SetFromCoordinate(coord);
}
COORDINATE DisplayTacticalCoord::GetCoordinate() const
{
return XY_Coord(x, y);
return coord;
}
void DisplayTacticalCoord::SetXY(int x, int y) {
this->x = x;
this->y = y;
this->coord = XY_Coord(x, y);
}
void DisplayTacticalCoord::SetFromCoordinate(COORDINATE coord)
{
//Map.Coord_To_Pixel(coord, x, y);
this->coord = coord;
x = Coord_X(coord);
y = Coord_Y(coord);
}
void DisplayTacticalCoord::AddPixelXY(int x, int y) {
int _x = this->x + Pixel_To_Lepton(x);
int _y = this->y + Pixel_To_Lepton(y);
SetXY(_x, _y);
}
+7
View File
@@ -9,7 +9,14 @@ struct DisplayTacticalCoord {
COORDINATE GetCoordinate() const;
void SetFromCoordinate(COORDINATE coord);
void SetXY(int x, int y);
int GetX() { return x; }
int GetY() { return y; }
void AddPixelXY(int x, int y);
private:
int x;
int y;
COORDINATE coord;
};