Hello Everyone,

Just started my intro to C++ class and was given a code to complete to help prepare me for further classes.

What I need to do it create a grid using arrays like this (which I completed):


and then somehow move the "1" to other parts of the grid.

Any tips/suggestions/links to tutorials is appreciated and thanks for helping out.

7 Years
Discussion Span
Last Post by SgtMe

So you'll obvs. have your array "Board[3][3]". And values will be "0" or "1".
You want a loop that will reprint the game board. Use 'system("cls");' on Windows to clear the console. Then reprint the board.
Each loop, the user should be asked to press a key ("W", "A", "S" or "D"). If they put in another key, don't do anything, but don't report it either. Have a variable which stores the location of the "1". Obvs., if the player presses "W", take one off the "y" value of the coord.
Have a loop that goes through your array. If it hits "1" print "1", else print "0" (or vice versa). Don't forget that when you move, change the current position to "0", THEN change the next position (the one you are moving to) to "1".

Hope this helps :) If so, please upvote. Thanks :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.