0

Good evening.

My programming teacher asked a bare bones version of mine-sweeper. We are using text mode, not graphic. The problem is we have to draw the board (with ascii art, obviously I'll use +, - and |, every position refers to a corresponding value of a multidimensional array), read a position from the player and put an appropriate character on the specified location, i.e. the player enters C5 and, in the corresponding cell, I have to put a X if there is a mine, a point if there are no mines in the cells around or a number which means how many mines are around the position. I don't need to expand the selected cell automatically, as the original game do, I only have to write in the selected position. How can I write in a specified position after drawing the board? I mean, (i.e.) F4 is on the 20th column and the 13th row, how can I say cout << "X" << 20th, 13th; or cout << "3" << 20th, 13th;? Obviously, after writing the character, I have to put back the prompt on the position where the player has to insert the new attempt to read again with cin, but the solution is the same as before.

Thank you very much for your help. Alex

Alex
  • 1
  • There is nothing in the language standard for doing this, so you will have to use some OS-specific code. So what OS? – Bo Persson Nov 15 '16 at 20:25
  • You can only display the whole board (in easy mode, ie no ncurses etc). When the user makes a move, reprint the whole thing with the change incorporated. For a move F4, you would make the F column of the 4 row that value as you loop through your multidimensional array. – code11 Nov 15 '16 at 20:26
  • _@Alex_ `ncurses` is a good choice for portable applications. – πάντα ῥεῖ Nov 15 '16 at 20:28
  • The course is Introduction to Programming, I can't use ncurses, I can only use the standard library :-( . The system is Linux, the Lab in the University uses Debian, running a virtual machine which runs Ubuntu Mate. Every time a new course starts, Ubuntu is deleted and reinstalled. I'll redraw the board every time. Thank you. – Alex Nov 15 '16 at 20:48

0 Answers0