i want the charcter i display in the grid to move upwards when i press 'w' & downwards when i press's' & right when in press'd' & left when i press 'a',,,,i have written a code that doesnt work can anyone help me to find out what is the wrong
// Project !!!.cpp : Defines the entry point for the console application.
//
#include <iostream>
#include <conio.h>
#include <cstdlib>
using namespace std;
class Critter
{protected:
int x;
int y;
char z;
char board[20][20];
public:
Critter() {};
void setBoard ()
{
for (int j=0; j<20; j++)
{
board[0][j] = '@';
board[19][j] = '@';
}
for (int i=0; i<20; i++)
{
board[i][0] = '@';
board[i][19] = '@';
}
for (int j=1; j<19; j++)
{
for (int i=1; i<19; i++)
{
board[i][j] = ' ';
}
cout<<endl;
}
}
void displayBoard()
{
for (int i=0; i<20; i++)
{
for (int j=0; j<20; j++)
{
cout<< board[i][j];
}
cout<<endl;
}
}
int set1st(int x, int y, char z)
{
int l = x;
int m = y;
char n = z;
setBoard();
board[l][m] = n;
displayBoard();
return x,y;
};
void move(){
int t = 1;
t = getch();
if(t == 'w') moveup (x, y);
if(t == 's') movedown (x, y);
if(t == 'd') moveright(x, y);
if(t == 'a') moveleft (x, y);
};
void moveup(int x, int y)
{
x = x;
y = y - 1;
set1st(x, y, 'X');
};
void movedown(int x, int y)
{
x = x;
y = y + 1;
};
void moveright(int x, int y)
{
x = x + 1;
y = y;
};
void moveleft(int x, int y)
{
x = x - 1;
y = y;
};
/*void breed();
void starve();*/
};
/*class Predator : public Critter
{
};
class Prey : public Critter
{
};*/
int main()
{
Critter c;
c.set1st(5, 5, 'X');
while(true)
{
c.move();
system ("CLS");
}
return 0;
}