Skip to content

Commit

Permalink
Created and populated Movement class. Build successful
Browse files Browse the repository at this point in the history
  • Loading branch information
MicheleMichetti committed Feb 25, 2024
1 parent b10d68f commit cb36e34
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
32 changes: 32 additions & 0 deletions game/include/Movement.hpp
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();


};

};
43 changes: 43 additions & 0 deletions game/src/Movement.cpp
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--;
}

0 comments on commit cb36e34

Please sign in to comment.