From cb36e345c7152c96faa8bde5eb31e60e1efa01fb Mon Sep 17 00:00:00 2001 From: MicheleMichetti Date: Sun, 25 Feb 2024 17:22:36 +0100 Subject: [PATCH] Created and populated Movement class. Build successful --- game/include/Movement.hpp | 32 +++++++++++++++++++++++++++++ game/src/Movement.cpp | 43 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 game/include/Movement.hpp create mode 100644 game/src/Movement.cpp diff --git a/game/include/Movement.hpp b/game/include/Movement.hpp new file mode 100644 index 0000000..0c35b61 --- /dev/null +++ b/game/include/Movement.hpp @@ -0,0 +1,32 @@ +#pragma once + +#include + +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(); + + +}; + +}; \ No newline at end of file diff --git a/game/src/Movement.cpp b/game/src/Movement.cpp new file mode 100644 index 0000000..d400e37 --- /dev/null +++ b/game/src/Movement.cpp @@ -0,0 +1,43 @@ +#include + +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--; +} \ No newline at end of file