Skip to content

Commit

Permalink
Point is now constexpr
Browse files Browse the repository at this point in the history
  • Loading branch information
Crayon2000 committed Jun 25, 2024
1 parent dc2a1d0 commit 06a31da
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
9 changes: 3 additions & 6 deletions source/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
/**
* Array to hold the position of each zone.
*/
static const Point Table[3][3] = {
static constexpr Point Table[3][3] = {
{Point(180, 28), Point(180, 131), Point(180, 233)},
{Point(322, 28), Point(322, 131), Point(322, 233)},
{Point(464, 28), Point(464, 131), Point(464, 233)}};
Expand Down Expand Up @@ -88,10 +88,7 @@ Game::Game(u16 GameScreenWidth, u16 GameScreenHeight) :
ExitButton[2]->SetFont(DefaultFont);
ExitButton[2]->SetLeft((ScreenWidth / 2) - ExitButton[1]->GetWidth() - 20);
ExitButton[2]->SetTop(165);
//if(!!*(u32 *)0x80001800) // that returns true for hbc, false for load-from-trucha-signed-disc. think it also returns false for tp hack
// ExitButton[2]->SetCaption("Return to HBC");
//else
ExitButton[2]->SetCaption(Lang->String("Return to Loader"));
ExitButton[2]->SetCaption(Lang->String("Return to Loader"));

MenuButton[0] = new Button();
MenuButton[0]->SetFont(DefaultFont);
Expand Down Expand Up @@ -1041,7 +1038,7 @@ void Game::CalculateFrameRate()
{
static u8 frameCount = 0;
static u32 lastTime;
u32 currentTime = ticks_to_millisecs(gettime());
const u32 currentTime = ticks_to_millisecs(gettime());

++frameCount;
if(currentTime - lastTime > 1000)
Expand Down
14 changes: 7 additions & 7 deletions source/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,28 @@ class Point
* Constructor for the Point class.
* Initializes a point at the origin (0, 0) of the coordinate space.
*/
Point() : x(0), y(0)
constexpr Point() : x(0), y(0)
{
}
/**
* Constructor for the Point class.
* @param[in] x Specifies the x-coordinate.
* @param[in] y Specifies the y-coordinate.
*/
Point(u16 x, u16 y) : x(x), y(y)
constexpr Point(u16 x, u16 y) : x(x), y(y)
{
}
/**
* Get the x position.
*/
[[nodiscard]] u16 GetX() const
[[nodiscard]] constexpr u16 GetX() const
{
return x;
}
/**
* Get the y position.
*/
[[nodiscard]] u16 GetY() const
[[nodiscard]] constexpr u16 GetY() const
{
return y;
}
Expand All @@ -53,7 +53,7 @@ class Point
* @param[in] x Specifies the x-coordinate.
* @param[in] y Specifies the y-coordinate.
*/
void SetLocation(u16 x, u16 y)
constexpr void SetLocation(u16 x, u16 y)
{
this->x = x;
this->y = y;
Expand All @@ -63,7 +63,7 @@ class Point
* @param[in] pt The Point to evaluate.
* @return If the Point meet the comparison condition, the operators return a true value. Otherwise, false is returned.
*/
bool operator ==(const Point& pt) const
constexpr bool operator ==(const Point& pt) const
{
return (x == pt.x) && (y == pt.y);
}
Expand All @@ -72,7 +72,7 @@ class Point
* @param[in] pt The Point to evaluate.
* @return If the Point meet the comparison condition, the operators return a true value. Otherwise, false is returned.
*/
bool operator !=(const Point& pt) const
constexpr bool operator !=(const Point& pt) const
{
return !(pt == *this);
}
Expand Down

0 comments on commit 06a31da

Please sign in to comment.