Last active
August 29, 2015 14:11
-
-
Save wand125/9dfe1172ee3b510af94e to your computer and use it in GitHub Desktop.
Direction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* ゲーム内の方向を表すコードの一部 | |
*/ | |
enum Direction { | |
kRight, | |
kUp, | |
kLeft, | |
kDown, | |
kDirectionCount | |
}; | |
typedef struct { | |
S32 x; | |
S32 y; | |
} TilePosition; | |
class Tile { | |
public: | |
static const TilePosition kDirToPos[(int)kDirectionCount]; | |
static TilePosition GetDelta(Direction dir); | |
}; | |
const TilePosition Tile::kDirToPos[(int)kDirectionCount] = { | |
{1,0},{0,1},{-1,0},{0,-1} | |
}; | |
TilePosition Tile::GetDelta(Direction dir) | |
{ | |
return kDirToPos[(int)dir]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment