   Ascii Roguelike
  Hello iv been working on a text based game for a while now an i wanted to make it ascii based. All im trying to do right now is getting my array to show the map i have a little code. But its not working right. It wants me to press enter everytime an it build pieces of it at a time. If someone can send me in the right direction would be nice also im using c++ thanks.#include <iostream>#include <stdlib.h>using namespace std;int main(){  int i;  int j;  char board[10][15] = {"##############",   "#  #",    "#  #",    "#  #","# #","# #","# #","##############"};  for(i = 0; i < 10; ++i)  { for(j = 0; j < 15; ++j)  cout<<board[j];  system("pause");    }}  [Edited by - Schade on May 19, 2010 8:30:38 PM]
  Thats suppose to be a square.   ;Quote:Original post by SchadeIt wants me to press enter everytime an it build pieces of it at a time.Take a closer look at where the system("PAUSE"); line is inside your code.Quote:Thats suppose to be a square.Please post code with [source][/source] tags in order to preserve formatting.  See forum's FAQ for additional details.   ;  system("pause") will pause your program until the user provides some input. You shouldn't call it every line unless you want to pause the program on every line. Also, you should put your source code snippets into [ source ] tags. Just pasting them into a post will remove important spacing information.   ;  sorry about the code forgot to put source at the beginning. Also should i remove the system("pause"); im not sure what to do with it.;  well i see theres a hundred views an not one reply stating how to set it up.   ;  Remove the system("PAUSE"). You want to use std::cout to print the whole map at a time.I would also use <ctsdlib> rather than the old <stdlib.h> one. But that's not important.You might also want to move the 10 and 15 to constant variables. If you wanted to change it to being 11 high, then you've got to change all the figures.Also, currently the map would be printed on one line since there's no line breaks.Just some things that might help. :)#include <iostream>#include <cstdlib>//These could make it easier in the long run.const int BOARD_HEIGHT = 10;const int BOARD_WIDTH = 15;int main(){  int i;  int j;  char board[10][15] = {"##############",    "#  #",    "#  #",    "#  #","#  #","# #","#  #","##############"};  for(i = 0; i < BOARD_HEIGHT; ++i)  { for(j = 0; j < BOARD_WIDTH; ++j) {  std::cout << board[j]; //You can use using namespace std and cout, //Or not use it and use std::cout. Doesn't make a difference, really. This is just how //I do it.  }    }return 0; }  One problem you might run into is it will display the board and close quickly. To stop this, look for a button that says 'Start without debugging' or something. I believe it is Ctrl+F5 on Visual Studio.Good luck!   ;  You'll want to do something like this:for(i = 0; i < height; ++i){  for(j = 0; j < width; ++j)  {    cout << board[j];  }  cout << endl;}system("pause");Don't have the pause in the middle of your display loop, or it will pause after every line.  You also need to be outputting a new line character if you want to display on multiple lines.Have a look at this: http://www.adom.de/misc/qhack.php3 it'll show you how to set up a really basic roguelike game.   ;  Thank you very much. Iv actually been trying to find something basic. Also should i use conio to setup keyboard or should i use a different lib. I have a text based game all in c++ im trying to change it to ascii but im just messing around setting up the display before i start changing all of my code.Also could some on point me in a direction for adding @ so i can move it around for my player.[Edited by - Schade on May 19, 2010 8:57:46 PM];  The way you're outputting is a bit weird too...board is an array of char*s (basically an array of C strings representing horizontal lines in your map).What this means is that to output the map, you could simply do:for(i = 0; i < 10; i++){   cout << board;}(basically outputting one whole line at a time, rather than doing it character-by-character)Also, remember that you need to add a newline at the end of each line in your output, otherwise it'll write the whole map on a single line.cout << board << endl;Yet another thing worth pointing out is that you're addressing your board with the y coordinate first, and the x coordinate second (i is y, j is x)... Not a problem if you're conscious of it, but traditionally, the order is x, then y.Regarding adding @ for the character, the trick is usually to keep a buffer (an array) that you'll use as a canvas; every frame, you'll draw your level on the canvas, then the characters and other objects, leaving the original map untouched. Then output that canvas to the screen.Oh, and something that you'll probably figure out later: making a game where you "write on a canvas" is harder than a "classic" text-based console game with "standard" console i/o. Using cout (or printf) will make refreshes between frames extremely slow and clunky. Also, input handling without events (using cin or other input methods) won't give the desired results if for instance you want to move your character using the arrows.What's recommended instead is to get a handle to the console output buffer and write there directly... For input, get a handle to the console input buffer so you can capture keyboard events; you can get millisecond-precision that way. Downside to using handles is that the implementation is OS-dependent, so if you're looking to support multiple OSes, well... Guess you'll worry about that when you get there :)