Change Point2 to use STL arrays for predefined directions
This commit is contained in:
parent
0718a1285e
commit
ce77b2354c
|
@ -15,6 +15,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
class Point2
|
class Point2
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -24,11 +26,11 @@ class Point2
|
||||||
/// The eight cardinal and diagonal directions starting down, rotating in
|
/// The eight cardinal and diagonal directions starting down, rotating in
|
||||||
/// positive direction.
|
/// positive direction.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
static const Point2 directions[8];
|
static const std::array<Point2, 8> directions;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The four cardinal directions starting down, rotating in positive direction.
|
/// The four cardinal directions starting down, rotating in positive direction.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
static const Point2 cardinalDirections[4];
|
static const std::array<Point2, 4> cardinalDirections;
|
||||||
int x, y;
|
int x, y;
|
||||||
Point2();
|
Point2();
|
||||||
Point2(const int x, const int y);
|
Point2(const int x, const int y);
|
||||||
|
|
|
@ -23,9 +23,9 @@ const Point2 Point2::upLeft{ -1, -1 };
|
||||||
const Point2 Point2::upRight{ 1, -1 };
|
const Point2 Point2::upRight{ 1, -1 };
|
||||||
const Point2 Point2::downLeft{ -1, 1 };
|
const Point2 Point2::downLeft{ -1, 1 };
|
||||||
const Point2 Point2::downRight{ 1, 1 };
|
const Point2 Point2::downRight{ 1, 1 };
|
||||||
const Point2 Point2::directions[] = { Point2::down, Point2::downRight, Point2::right, Point2::upRight, Point2::up,
|
const std::array<Point2, 8> Point2::directions = { Point2::down, Point2::downRight, Point2::right, Point2::upRight,
|
||||||
Point2::upLeft, Point2::left, Point2::downLeft };
|
Point2::up, Point2::upLeft, Point2::left, Point2::downLeft };
|
||||||
const Point2 Point2::cardinalDirections[] = { Point2::down, Point2::right, Point2::up, Point2::left };
|
const std::array<Point2, 4> Point2::cardinalDirections = { Point2::down, Point2::right, Point2::up, Point2::left };
|
||||||
|
|
||||||
Point2::Point2()
|
Point2::Point2()
|
||||||
: Point2{ 0, 0 }
|
: Point2{ 0, 0 }
|
||||||
|
|
Loading…
Reference in New Issue