#include <iostream.h>
#include <windows.h>
#include <winuser.h>
#include <conio.h>
#include <time.h>
#include <stdio.h>
#include <string.h>
using namespace std;
HANDLE hStdout;
void level()
{
cout << endl << ###################################;
cout << endl << #OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO#;
cout << endl << #OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO#;
cout << endl << #OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO#;
cout << endl << #OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO#;
cout << endl << #OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO#;
cout << endl << #OOOOOOOOOOOOOOO*OOOOOOOOOOOOOOOOO#;
cout << endl << #OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO#;
cout << endl << #OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO#;
cout << endl << #OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO#;
cout << endl << #OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO#;
cout << endl << #OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO#;
cout << endl << #OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO#;
cout << endl << ###################################;
}
void color(int x, int y)
{
hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hStdout, x | y);
}
void cursor()
{
HANDLE hScreenBuf = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cci;
GetConsoleCursorInfo(hScreenBuf, &cci);
cci.bVisible= FALSE;
SetConsoleCursorInfo(hScreenBuf, &cci);
}
void locate(int y, int x)
{
COORD point;
point.X = x; point.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), point);
}
char screen(int y, int x)
{
char character;
CHAR_INFO buffer;
COORD bufferSize = {1, 1};
COORD bufferCoord = {0, 0};
SMALL_RECT region = {x, y, x, y};
ReadConsoleOutput(GetStdHandle(STD_OUTPUT_HANDLE), &buffer, bufferSize, bufferCoord, &region);
character = buffer.Char.AsciiChar;
return character;
}
int getkey() {
const int EXT1= 0, EXT2= 224;
if(kbhit()) {
int input= getch();
if((input == EXT1) || (input == EXT2))
input= getch() << 8;
return input;
} else
return 0;
}
class pos
{
public:
int x;
int y;
int point;
void ausgabe()
{
locate(y,x);
cout << @;
locate(30,10);
cout << point;
}
int gehe()
{
int taste = 0;
while (taste == 0)
{
taste = getkey();
}
if (taste == 0x4800)
{
y--;
char z = screen(y,x);
if (z ==->#')
{
y++;
}
if (z ==->O')
{
point++;
}
}
if (taste == 0x5000)
{
y++;
char z = screen(y,x);
if (z ==->#')
{
y--;
}
if (z ==->O')
{
point++;
}
}
if (taste == 0x4b00)
{
x--;
char z = screen(y,x);
if (z ==->#')
{
x++;
}
if (z ==->O')
{
point++;
}
}
if (taste == 0x4d00)
{
x++;
char z = screen(y,x);
if (z ==->#')
{
x--;
}
if (z ==->O')
{
point++;
}
}
return taste;
}
void clear()
{
point=0;
x=10;
y=10;
}
void check()
{
char z =->->;
z = screen(y - 1,x);
if ( z ==->@')
{
locate(y - 1,x);
cout << ;
}
z = screen(y + 1,x);
if ( z ==->@')
{
locate(y + 1,x);
cout << ;
}
z = screen(y,x - 1);
if ( z ==->@')
{
locate(y,x - 1);
cout << ;
}
z = screen(y,x + 1);
if ( z ==->@')
{
locate(y,x + 1);
cout << ;
}
}
};
int main()
{
cursor();
level();
pos I;
I.clear();
I.ausgabe();
int esc = 0;
while(esc != 0x001b)
{
esc = I.gehe();
I.ausgabe();
I.check();
}
return 0;
}