Started on a larger test
This commit is contained in:
parent
cdc802476d
commit
420b504016
2 changed files with 62 additions and 0 deletions
25
src/GC/tests/game.cpp
Normal file
25
src/GC/tests/game.cpp
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#include <vector>
|
||||
|
||||
#include "player.hpp"
|
||||
|
||||
#define X_LENGTH 1000;
|
||||
#define Y_LENGTH 500;
|
||||
|
||||
class Game {
|
||||
|
||||
private:
|
||||
|
||||
std::vector<Player> players;
|
||||
Point dimensions;
|
||||
|
||||
public:
|
||||
|
||||
Game() {
|
||||
dimensions = {X_LENGTH, Y_LENGTH};
|
||||
}
|
||||
|
||||
void add_player(Player& p) {
|
||||
players.push_back(p);
|
||||
}
|
||||
|
||||
};
|
||||
37
src/GC/tests/player.hpp
Normal file
37
src/GC/tests/player.hpp
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#include <string>
|
||||
|
||||
using std::string;
|
||||
|
||||
class Player {
|
||||
|
||||
private:
|
||||
|
||||
string name;
|
||||
Point position;
|
||||
Point size;
|
||||
Point direction;
|
||||
|
||||
public:
|
||||
|
||||
Player(string n, Point pos, Point s, Point dir) {
|
||||
name = n;
|
||||
position = pos;
|
||||
size = s;
|
||||
direction = dir;
|
||||
}
|
||||
|
||||
void move() {
|
||||
position.x += direction.x;
|
||||
position.y += direction.y;
|
||||
}
|
||||
|
||||
void set_speed(int dx, int dy) {
|
||||
direction.x = dx;
|
||||
direction.y = dy;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
struct Point {
|
||||
int x, y;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue