-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created and populated Movement class. Build successful
- Loading branch information
1 parent
b10d68f
commit cb36e34
Showing
2 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#pragma once | ||
|
||
#include <utils.hpp> | ||
|
||
namespace _movement { | ||
|
||
class Movement { | ||
|
||
protected: | ||
utils::Coordinate coordinate_; | ||
uint8_t direction_; | ||
|
||
public: | ||
void setCoordinate(utils::Coordinate coordinate); | ||
void setDirection(uint8_t direction); | ||
void setX(int16_t x); | ||
void setY(int16_t y); | ||
|
||
utils::Coordinate getCoordinate(); | ||
uint8_t getDirection(); | ||
int16_t getX(); | ||
int16_t getY(); | ||
|
||
void moveUp(); | ||
void moveDown(); | ||
void moveRight(); | ||
void moveLeft(); | ||
|
||
|
||
}; | ||
|
||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include<Movement.hpp> | ||
|
||
using namespace _movement; | ||
|
||
void Movement::setCoordinate(utils::Coordinate coordinate) { | ||
coordinate_.x = coordinate.x; | ||
coordinate_.y = coordinate.y; | ||
} | ||
void Movement::setDirection(uint8_t direction) { | ||
direction_ = direction; | ||
} | ||
void Movement::setX(int16_t X) { | ||
coordinate_.x = X; | ||
} | ||
void Movement::setY(int16_t Y) { | ||
coordinate_.y = Y; | ||
} | ||
|
||
utils::Coordinate Movement::getCoordinate() { | ||
return coordinate_; | ||
} | ||
uint8_t Movement::getDirection() { | ||
return direction_; | ||
} | ||
int16_t Movement::getX() { | ||
return coordinate_.x; | ||
} | ||
int16_t Movement::getY() { | ||
return coordinate_.y; | ||
} | ||
|
||
void Movement::moveUp() { | ||
coordinate_.y++; | ||
} | ||
void Movement::moveDown() { | ||
coordinate_.y--; | ||
} | ||
void Movement::moveRight() { | ||
coordinate_.x++; | ||
} | ||
void Movement::moveLeft() { | ||
coordinate_.x--; | ||
} |