Skip to content

Instantly share code, notes, and snippets.

@Lumaio
Created June 25, 2014 23:01
Show Gist options
  • Save Lumaio/3a6e55c72c8ebb95476b to your computer and use it in GitHub Desktop.
Save Lumaio/3a6e55c72c8ebb95476b to your computer and use it in GitHub Desktop.
This is rather interesting
#include <iostream>
#include <stdio.h>
#include <conio.h>
#include "Room.h"
#include "System.h"
#include "Player.h"
int main(int argc, char **argv)
{
System *sys = new System();
Player *player = new Player(1, 1, "Lumaio");
for (int i = 0; i < 49; i++) {
for (int j = 0; j < 49; j++) {
sys->map[i][j]=new Room();
}
}
Room *r = sys->map[1][1];
int dirs[4];
dirs[0]=1;
dirs[1]=2;
dirs[2]=3;
dirs[3]=4;
printf("hello world\n");
r->setDirections(dirs);
std::cout << player->getName() << std::endl;
_getch();
return 0;
}
#include "Player.h"
#include <iostream>
Player::Player(int x, int y, std::string name)
{
this->setX(x);
this->setY(y);
this->setName(name);
}
Player::~Player()
{
}
void Player::setName(std::string name)
{
this->name=name;
}
void Player::setX(int x)
{
this->x=x;
}
void Player::setY(int y)
{
this->y=y;
}
int Player::getX()
{
return this->x;
}
int Player::getY()
{
return this->y;
}
std::string Player::getName()
{
return this->name;
}
#include <iostream>
#ifndef PLAYER_H
#define PLAYER_H
class Player
{
private:
int x;
int y;
std::string name;
public:
Player(int x, int y, std::string name);
~Player();
void setName(std::string);
void setX(int x);
void setY(int y);
int getX();
int getY();
std::string getName();
};
#endif // PLAYER_H
#include "Room.h"
Room::Room()
{
}
Room::~Room()
{
}
void Room::setDirections(int dirs[4])
{
this->dir=dirs;
}
int *Room::getDirections()
{
return this->dir;
}
#ifndef ROOM_H
#define ROOM_H
class Room
{
private:
int EAST=0;
int WEST=1;
int NORTH=2;
int SOUTH=3;
int *dir;
public:
Room();
~Room();
void setDirections(int dirs[4]);
int *getDirections();
};
#endif // ROOM_H
#include "Room.h"
#ifndef SYSTEM_H
#define SYSTEM_H
class System
{
public:
System();
~System();
Room *map[50][50];
};
#endif // SYSTEM_H
#include "System.h"
#include "Room.h"
System::System()
{
}
System::~System()
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment