Well... I was fooling around with C++, and I decided to make a game that was like the ones they had on the old hand-held systems... You know the ones... They had games like tetris, space invaders, and some driving games... Well, anyways.
I was just practicing, and I made this:
http://upl.silentwhisper.net/uplfolders/upload5/CollisionTest.zipIt\'s just a small \"game\" in which you move around the \'x\' and colide with the \'o\' characters.
Later on I decided to make an engine so that I could make the upcoming games a tad faster.
But while making it I ran into a problem... Should I keep using one class as I am now, or whould I break it up into many classes (controls, board, counters, etc.)? Which would be more C++ish in this situation?
Here is the code:
P.S. What else do you think I should add?
P.S.S. Didn\'t add too many comments, so if you have any questions just ask.
//Game Engine
#include
#include
using namespace std;
class Game {
char board[200][200];
int boardLength;
int boardHight;
int xPosition;
int yPosition;
int xSpawn;
int ySpawn;
int xMax;
int yMax;
int xMin;
int yMin;
int moveNum;
char moveL;
char moveR;
char moveU;
char moveD;
char aux1;
char aux2;
char aux3;
char aux4;
char playerSymbol;
public:
//Get private values
char get_moveL(){ return moveL;}
char get_moveR(){ return moveR;}
char get_moveU(){ return moveU;}
char get_moveD(){ return moveD;}
char get_aux1(){ return aux1;}
char get_aux2(){ return aux2;}
char get_aux3(){ return aux3;}
char get_aux4(){ return aux4;}
int get_xPosition(){ return xPosition;}
int get_yPosition(){ return yPosition;}
int get_moveNum(){ return moveNum;}
char get_playerSymbol(){ return playerSymbol;}
//Set Controls;
void set_moveL(char x){moveL = x;}
void set_moveR(char x){moveR = x;}
void set_moveU(char x){moveU = x;}
void set_moveD(char x){moveD = x;}
void set_aux1(char x){aux1 = x;}
void set_aux2(char x){aux2 = x;}
void set_aux3(char x){aux3 = x;}
void set_aux4(char x){aux4 = x;}
//Set board parameters
void set_boardSize(int x=0, int y=0){
boardLength = x;
boardHight = y;
}
//Set how far palyer can move
void set_boundries(int xl=boardLength, int yl=boardHight,
int xs=0, int ys=0){
xMax = xl;
yMax = yl;
xMin = xs;
yMin = ys;
}
//Set player spawn position
void set_spawn(int x=0, int y=0){
xSpawn = x;
ySpawn = y;
}
//Set player symbol
void set_playerSymbol(char p){playerSymbol = p}
void set_playerSymbol(int p){playerSymbol = p}
//Set number of moves.
void set_moveNum(int num){moveNum = num;}
/*Spawns barriers.
void spawnBarriers(){
int x;
int y;
for(int i=0; i<10; i++){
x = (rand()%9);
y = (rand()%9);
board[y][x] = \'o\';
}
}
*/
//Create a \"clean\" board.
void makeBoard(){
for(int i=0; i for(int x=0; x board[i][x] = \' \';
}
}
}
//Shows the board.
void showBoard(){
for(int i=0; i
for(int i=boardHight; i>(-1); i--){
cout << \"\\n|\";
for(int x=0; x cout << board[i][x];
}
cout << \"|\";
}
cout << \"\\n\";
for(int i=0; i }
//Resets Position.
void resetPosition(){
xPosition = xSpawn;
yPosition = ySpawn;
}
//Fills a sqare;
void fillPosition(){
board[yPosition][xPosition] = playerSymbol;
}
/*Checks for barriers
bool detectBarrier(char d){
if(d==moveL){
if(board[yPosition][xPosition-1]==\'o\') return true;
}
else if(d==moveR){
if(board[yPosition][xPosition+1]==\'o\') return true;
}
else if(d==moveU){
if(board[yPosition+1][xPosition]==\'o\') return true;
}
else if(d==moveD){
if(board[yPosition-1][xPosition]==\'o\') return true;
}
else return false;
}
*/
//Moves a character in a direction.
void movePosition(char direction){
if(direction == moveL){
if(xPosition == xMin){
return;
}
board[yPosition][xPosition] = \' \';
xPosition--;
moveNum++;
}
else if(direction == moveR){
if(xPosition == xMax){
return;
}
board[yPosition][xPosition] = \' \';
xPosition++;
moveNum++;
}
else if(direction == moveU){
if(yPosition == yMax){
return;
}
board[yPosition][xPosition] = \' \';
yPosition++;
moveNum++;
}
else if(direction == moveD){
if(yPosition == yMin){
return;
}
board[yPosition][xPosition] = \' \';
yPosition--;
moveNum++;
}
else cout << \"INVALID ARGUMENT\";
}
//TO BE CONTINUED.
};
void clear(){
system(\"cls\");
}
int main()
{
}