Aqui:
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int a, b, x, y, dx, dy, fx, fy, maxx, maxy, ox, oy, gam, player, kkey;
player = "P";
x = 1;
y = 3;
dx = 1;
dy = 1;
ox = 0;
oy = 0;
fy = 3;
int main()
{
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
maxx = csbi.srWindow.Right - csbi.srWindow.Left + 1;
maxy = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
gam = 1;
while ((fx - 1) != maxx) {
gotoxy(fx, 2);printf("=");
fx++;
}
fx = 0;
while ((fx - 1) != maxx) {
gotoxy(fx, maxy - 1);printf("=");
fx++;
}
while (gam == 1){
gotoxy(3, 5);printf("S");
gotoxy(1, maxy);printf("Life: 100/100; Mana: 50/50; Press <I> to open the inventory.");
gotoxy(dx, dy);printf("x = %d; y = %d; ox = %d; oy = %d; key = %d ", x,y,ox,oy,b); //Esse espaço extra é pra apagar possíveis vestígios.
hidecursor();
gotoxy(x, y);printf(player);
b = _getch();
if(b == 224){
a = _getch();
b = a;
}
kkey = checka(b);
}
}
void checka(int c) {
switch (c){
case 72:
if(y - 1 == 2){
return;
} else {
y = y - 1;
oy = y + 1;
gotoxy(x, oy);printf(" ");
return;
}
break;
case 80:
//gotoxy(dx, dy);printf("Baixo");
if(y == maxy - 2){
return;
} else {
y = y + 1;
oy = y - 1;
gotoxy(x, oy);printf(" ");
return;
}
break;
case 77:
//gotoxy(dx, dy);printf("Direita");
if(x + 1 > maxx){
return;
} else {
x = x + 1;
ox = x - 1;
gotoxy(ox, y);printf(" ");
return;
}
break;
case 75:
//gotoxy(dx, dy);printf("Esquerda");
if(x - 1 == 0){
return;
} else {
x = x - 1;
ox = x + 1;
gotoxy(ox, y);printf(" ");
return;
}
break;
case 105:
drawinv();
break;
default:
return 5;
break;
}
}
void gotoxy(int x, int y){
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),(COORD){x-1,y-1});
}
void hidecursor()
{
HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO info;
info.dwSize = 100;
info.bVisible = FALSE;
SetConsoleCursorInfo(consoleHandle, &info);
}