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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
|
#include <iostream>
#include <windows.h>
#include <conio.h>
#include <iomanip>
using namespace std;
const char PLAY=16;
const char STOP=-2;
const char UP=72;
const char DOWN=80;
const char LEFT=75;
const char RIGHT=77;
const char ENTER=13;
const char SPACE=32;
void gotoxy (short x, short y);
void map(int s[10][4]);
void sprite(short, short, int);
int main()
{
//Fullscreen
HANDLE hConsole;
COORD size;
HWND hWnd;
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
size = GetLargestConsoleWindowSize(hConsole);
SetConsoleScreenBufferSize(hConsole,size);
SetConsoleTitle("test");
hWnd = FindWindow(NULL,"test");
ShowWindow(hWnd,SW_MAXIMIZE);
//Hiding Cursor
CONSOLE_CURSOR_INFO CursoInfo;
CursoInfo.dwSize = 1;
CursoInfo.bVisible = false;
SetConsoleCursorInfo(hConsole, &CursoInfo);
int test[10][4]={ 5, 6, 7, 13, 13, 13, 13, 13, 13, 13,
8, 11, 10, 13, 13, 13, 13, 13, 13, 13,
13, 1, 13, 13, 13, 13, 13, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 13, 13};
int i,j;
char x;
for(;;)
{
map(test);
x=getch(); //check here whether input is UP, DOWN, LEFT or RIGHT
//move player according to x
system ("cls");
}
}
void map(int s[10][4])
{
short i, j;
//
for (i=0; i<10; i++)
{
for (j=0; j<4; j++)
{
sprite(j*10+1, i*10+1, s[i][j]);
}
}
}
void sprite(short j, short i, int x)
{
int a;
switch(x)
{
case 1:
for (a=0; a<10; a++, i++)
{
gotoxy(i,j);
cout<<"PLYR FRONT";
}
break;
case 2:
for (a=0; a<10; a++, i++)
{
gotoxy(i,j);
cout<<"PLYR LEFT";
}
break;
case 3:
for (a=0; a<10; a++, i++)
{
gotoxy(i,j);
cout<<"PLYR RIGHT";
}
break;
case 4:
for (a=0; a<10; a++, i++)
{
gotoxy(i,j);
cout<<"PLYR BACK";
}
break;
case 5:
for (a=0; a<10; a++, i++)
{
gotoxy(i,j);
cout<<" ROOF1 ";
}
break;
case 6:
for (a=0; a<10; a++, i++)
{
gotoxy(i,j);
cout<<" ROOF2 ";
}
break;
case 7:
for (a=0; a<10; a++, i++)
{
gotoxy(i,j);
cout<<" ROOF3 ";
}
break;
case 8:
for (a=0; a<10; a++, i++)
{
gotoxy(i,j);
cout<<" WALL1 ";
}
break;
case 9:
for (a=0; a<10; a++, i++)
{
gotoxy(i,j);
cout<<" WALL2 ";
}
break;
case 10:
for (a=0; a<10; a++, i++)
{
gotoxy(i,j);
cout<<" WALL3 ";
}
break;
case 11:
for (a=0; a<10; a++, i++)
{
gotoxy(i,j);
cout<<" DOOR ";
}
break;
case 12:
for (a=0; a<10; a++, i++)
{
gotoxy(i,j);
cout<<" TREE ";
}
break;
case 13:
for (a=0; a<10; a++, i++)
{
gotoxy(i,j);
cout<<" GROUND ";
}
break;
default:
for (a=0; a<10; a++, i++)
{
gotoxy(i,j);
cout<<"SPRITERROR";
}
break;
}
}
void gotoxy(short x, short y)
{
COORD pos = {x, y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
|