aboutsummaryrefslogtreecommitdiff
path: root/src/games/snake/Snake.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/games/snake/Snake.cpp')
-rw-r--r--src/games/snake/Snake.cpp44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/games/snake/Snake.cpp b/src/games/snake/Snake.cpp
index a5fd76c..4c6ca18 100644
--- a/src/games/snake/Snake.cpp
+++ b/src/games/snake/Snake.cpp
@@ -12,8 +12,8 @@ Snake::Snake()
m_LastMillisecondsSinceT0 = SDL_GetTicks();
m_TilesPerSecond = 4.0f;
- m_Direction = DIRECTION_RIGHT;
- m_LastAdvancedDirection = DIRECTION_RIGHT;
+ m_Direction = right;
+ m_LastAdvancedDirection = right;
m_MapWidth = 16;
m_MapHeight = 16;
@@ -84,16 +84,16 @@ void Snake::MaybeMoveSnake(float dt_in_seconds) {
// find head_pos
- if (m_Direction == DIRECTION_UP) {
+ if (m_Direction == up) {
head_pos.y += 1;
}
- else if (m_Direction == DIRECTION_DOWN) {
+ else if (m_Direction == down) {
head_pos.y -= 1;
}
- else if (m_Direction == DIRECTION_RIGHT) {
+ else if (m_Direction == right) {
head_pos.x += 1;
}
- else if (m_Direction == DIRECTION_LEFT) {
+ else if (m_Direction == left) {
head_pos.x -= 1;
}
if ((head_pos.x < 0 || head_pos.x >= m_MapWidth) ||
@@ -162,31 +162,31 @@ void Snake::ProcessEventDuringResume(SDL_Event &event) {
switch (event.type) {
case SDL_EVENT_KEY_DOWN: {
if (event.key.key == SDLK_UP) {
- if (m_LastAdvancedDirection == DIRECTION_RIGHT ||
- m_LastAdvancedDirection == DIRECTION_LEFT)
+ if (m_LastAdvancedDirection == right ||
+ m_LastAdvancedDirection == left)
{
- m_Direction = DIRECTION_UP;
+ m_Direction = up;
}
}
else if (event.key.key == SDLK_DOWN) {
- if (m_LastAdvancedDirection == DIRECTION_RIGHT ||
- m_LastAdvancedDirection == DIRECTION_LEFT)
+ if (m_LastAdvancedDirection == right ||
+ m_LastAdvancedDirection == left)
{
- m_Direction = DIRECTION_DOWN;
+ m_Direction = down;
}
}
else if (event.key.key == SDLK_RIGHT) {
- if (m_LastAdvancedDirection == DIRECTION_UP ||
- m_LastAdvancedDirection == DIRECTION_DOWN)
+ if (m_LastAdvancedDirection == up ||
+ m_LastAdvancedDirection == down)
{
- m_Direction = DIRECTION_RIGHT;
+ m_Direction = right;
}
}
else if (event.key.key == SDLK_LEFT) {
- if (m_LastAdvancedDirection == DIRECTION_UP ||
- m_LastAdvancedDirection == DIRECTION_DOWN)
+ if (m_LastAdvancedDirection == up ||
+ m_LastAdvancedDirection == down)
{
- m_Direction = DIRECTION_LEFT;
+ m_Direction = left;
}
}
else if (event.key.key == SDLK_ESCAPE) {
@@ -270,7 +270,7 @@ void Snake::Draw() {
/* draw map background */
V3F32 map_world_pos = {map_x, map_y, 0.0f};
V2F32 map_world_dim = {map_view_width, map_view_height};
- RectF32 map_world_rect = {
+ Rectangle map_world_rect = {
map_world_pos.x,
map_world_pos.y,
map_world_pos.x + map_world_dim.x,
@@ -298,7 +298,7 @@ void Snake::Draw() {
1.0f
};
V2F32 world_dim = local_dim;
- RectF32 world_rect = {
+ Rectangle world_rect = {
world_pos.x,
world_pos.y,
world_pos.x + world_dim.x,
@@ -326,7 +326,7 @@ void Snake::Draw() {
1.0f
};
V2F32 world_dim = local_dim;
- RectF32 world_rect = {
+ Rectangle world_rect = {
world_pos.x,
world_pos.y,
world_pos.x + world_dim.x,
@@ -346,7 +346,7 @@ void Snake::Draw() {
1.0f
};
V2F32 dim = {bodypart_size, bodypart_size};
- RectF32 rect = {
+ Rectangle rect = {
pos.x,
pos.y,
pos.x + dim.x,