@ symbol not erasing when moving
the @ symbol won't go away like it should and yes I know it has a lot of windows specific code I couldn't find a good way around that
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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
#include <iostream>
#include <windows.h>
using namespace std;
char map[23][23];
class Player
{
public:
int x = 10;
int y = 10;
int px = 10;
int py = 10;
int hp = 100;
};
void SetMap()
{
int countx = 23;
int county = 23;
while (county > 0)
{
while (countx > 0)
{
map[countx][county] = 219;
countx--;
}
county--;
countx = 23;
}
}
void DrawScreen()
{
int countx = 23;
int county = 23;
system("CLS");
while (county > 0)
{
while (countx > 0)
{
cout << map[countx][county];
countx--;
}
county--;
countx = 23;
cout << endl;
}
}
int main()
{
Player player;
SetConsoleTitle("ASCII Quest");
SetMap();
while (true)
{
cout << "ASCII Quest" << endl << endl;
cout << "1.Play" << endl << "2.Quit" << endl;
system("pause > NULL");
system("CLS");
if (GetAsyncKeyState('1'))
{
while (TRUE)
{
map[player.px][player.py] = 219;
map[player.x][player.y] = '@';
DrawScreen();
system("Pause > NULL");
if (GetAsyncKeyState('W')) player.y++;
if (GetAsyncKeyState('A')) player.x++;
if (GetAsyncKeyState('D')) player.x--;
if (GetAsyncKeyState('S')) player.y--;
if (GetAsyncKeyState(VK_ESCAPE))
{
system("CLS");
cout << "Paused" << endl << endl << "Press any key to resume.";
system("Pause > NULL");
}
player.px = player.x;
player.py = player.y;
}
}
if (GetAsyncKeyState('2')) return(0);
}
}
|
Topic archived. No new replies allowed.