PlaneShift
Fan Area => The Hydlaa Plaza => Topic started by: RussianVodka on September 04, 2005, 12:48:32 am
-
It may be a tad ambitious... But I\'m gona try my hand at making a game that resembles something that could be found on those old hand-held pre-gameboy things. You know those B&W ones I\'m talking about.
Here is the best example of one of \'em I could find:
(http://www.spilsbury.com/wcsstore/Spilsbury/images/products/large/1782.jpg)
But there are a few things I have a problem with.
1.) What is the command that creates a loop which is only broken when a key is pressed? Also, how would I \"return\" the key that was pressed, so that it can be passed on to some other part of the code?
2.) I\'m still going to be using command prompt, so how should I impliment the \"game board\". I was thinking of creating a two-dementional array, in which characters will be filled with a \"#\" to represent a filled space, and left blank to represent unfiled spaces.
Code would look something like this:
char board[10][10];
// Fill board with blank spaces.
for(int i=0; i<10; i++){
for(int x=0; x<10; x++){
board[i][x] = x;
}
}
//Display board.
cout << board[0][0] << board[0][1] << board[0][2] << board[0][3] ..........
//And just continue with ten rows each conaining ten \"blocks\".
Or better yet i could automate the entire thing:
//Displays board.
void displayBoard(int yAxis, int xAxis){
if(xAxis == 0){
cout << \"Invalid argument\";
return;
}
char board[yAxis][xAxis];
//Automated board display.
for(int y=0; y cout << \"\\n\";
for(int x=0; x cout << board[y][x];
}
}
}
If i do it the second way I could have a function that writes to the board, a function that displays the board, and the board array. All of which will be part of the \"Board\" class (not very creative with my names), making them easey to use.
Anyone wana share their knowledge/ideas?
-
Anyone?