Moving Character

I have a board where a character is. I need to ask the user whether they want to move it up, down, left right. They are allowed to enter 3 move per turn. like up, up, left. How do I do this?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

const int COL = 17;
const int ROW = 17;

void initializeBoard(char [][COL], int, int);
void displayBoard(char [][COL], int, int);
int main()
{
    char board[ROW][COL];
 initializeBoard(board, ROW, COL);
    displayBoard(board, ROW, COL);

    return 0;
}

void initializeBoard(char theBoard [][COL], int row, int col)
{
    for(int r = 0; r < ROW; r++)
    {
        for(int c = 0; c < COL; c++)
        {
            theBoard[r][c] = '.'; //250
        }
    }

    for(int c = 0; c < COL; c++)
    {
        theBoard[0][c] = '__'; // 205
        theBoard[ROW-1][c] = '__'; //205
    }
    for(int r = 0; r < row; r++)
    {
        theBoard[r][0] = '|'; //186
        theBoard[r][COL-1] = '|'; //186
    }
    theBoard[0][0] = '   '  ; //201
    theBoard[0][COL-1] = '   '; //187
    theBoard[ROW-1][0] = '   '; //200
    theBoard[ROW-1][col-1] = '   '; //188

}

//Prints Board
void displayBoard(char theBoard [][COL], int row, int col)
{
    for(int r = 0; r < ROW; r++)
    {
        for(int c = 0; c < COL; c++)
        {
            cout << theBoard[r][c];// << ' ';
        }
        cout << endl;
    }
}
#include<conio.h>

getch()
google it out bored to type
anyway. .
int a;
a=getch();
cout<<a<<endl;
//test it
if(a==somenumber)
{}
you can't do it without conio.h?
I'm using a mac
well u cant include windows then either :S?
for getkeystate();


well idk try to google it out
try http://stackoverflow.com/questions/9547868/is-there-a-way-to-get-user-input-without-pressing-the-enter-key
Last edited on
Topic archived. No new replies allowed.