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
|
#include <iostream>
#include "windows.h"
#include <dos.h>
#include <stdio.h>
#include <conio.h>
using namespace std;
struct Color
{
int color;
Color(int color_): color(color_) {}
Color operator + (const Color & other) const { return Color(this->color | other.color); }
};
#define FORE_LIGHT(color) const Color cfl##color##_ = FOREGROUND_##color | FOREGROUND_INTENSITY;
#define BACK_LIGHT(color) const Color cbl##color##_ = BACKGROUND_##color | BACKGROUND_INTENSITY;
#define FORE_DARK(color) const Color cfd##color##_ = FOREGROUND_##color;
#define BACK_DARK(color) const Color cbd##color##_ = BACKGROUND_##color;
FORE_LIGHT(RED) FORE_LIGHT(GREEN) FORE_LIGHT(BLUE)
BACK_LIGHT(RED) BACK_LIGHT(GREEN) BACK_LIGHT(BLUE)
FORE_DARK (RED) FORE_DARK (GREEN) FORE_DARK (BLUE)
BACK_DARK (RED) BACK_DARK (GREEN) BACK_DARK (BLUE)
const Color cdefault_ = cfdRED_ + cfdGREEN_ + cfdBLUE_;
std::ostream & operator << (std::ostream & os, Color c)
{
return SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), c.color), os;
}
char map[20][40] = {
"#######################################",
"#@ X XXXXX XX #",
"# X XX XXXX XXX#",
"# XXXXXXXXXXXXX XXXXXXXX XX #",
"# XX XXX XXXXX #",
"# XXXX XXX XXXX X XX X #",
"# X XXXX XX X X XX X #",
"# XX X X XX X X XX X X #",
"# XX X X XX X XX X X #",
"# XX X XX X XXXXXXX X #",
"# X XXXXX XXXXXX #",
"#X X X X X XXXXX X #",
"#X X XXX X X XXXXX X X #",
"#X X X X XXXX X X #",
"# X XX X XXXX X XX X X #",
"# XXXXXX X X X XX #",
"# X X XXXX X XXXX#",
"# XXXXXXXX X X X F#",
"#######################################"
};
int x=1;
int y=1;
int y3=19;
int x3=39;
bool game_running = true;
int main()
{
while(game_running == true){
system("cls");
for(int display=0; display<20; display++){
cout << map[display] << endl;
}
system("pause>nul");
if(GetAsyncKeyState(VK_DOWN)){
int y2 = y+1;
if (map[y2][x] == ' '){
map[y][x] = ' ';
y++;
map[y][x] = '@';
}
}
if(GetAsyncKeyState(VK_UP)){
int y2 = y-1;
if (map[y2][x] == ' '){
map[y][x] = ' ';
y--;
map[y][x] = '@';
}
}
if(GetAsyncKeyState(VK_RIGHT)){
int x2 = x+1;
if (map[y][x2] == ' '){
map [y][x] = ' ';
x++;
map[y][x] = '@';
}
}
if(GetAsyncKeyState(VK_LEFT)){
int x2 = x-1;
if (map[y][x2] == ' '){
map [y][x] = ' ';
x--;
map[y][x] = '@';
}
}
if(GetAsyncKeyState(VK_ESCAPE)){
game_running = false;
}
level2:
cout << "test" << endl;
}
system("cls");
Sleep(50);
cout << cflRED_ + cflGREEN_ << "Game Over!" << cflRED_ << "Game Over!" << cflGREEN_ << "Game Over!" << cflBLUE_ << "Game Over!" << cflRED_ + cflGREEN_ << "Game Over!" << cflRED_ << "Game Over!" << cflGREEN_ << "Game Over!" << cflBLUE_ << "Game Over!" << cflRED_ + cflGREEN_ << "Game Over!" << cflRED_ << "Game Over!" << cflGREEN_ << "Game Over!" << cflBLUE_ << "Game Over!" << cflRED_ + cflGREEN_ << "Game Over!" << cflRED_ << "Game Over!" << cflGREEN_ << "Game Over!" << cflBLUE_ << "Game Over!" << endl;
system("cls");
cout << cflGREEN_ + cflBLUE_ << " v0.1 alpha" << endl;
Sleep(10000);
system("cls");
return 0;
}
|