#include
#include
#include <windows.h>
#include <conio.h>
using namespace std;
int SIZ = 20;
HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE);
COORD coord;
HANDLE hCon;
enum Color { DARKBLUE = 1, DARKGREEN, DARKTEAL, DARKRED, DARKPINK, DARKYELLOW, GRAY, DARKGRAY, BLUE, GREEN, TEAL, RED, PINK, YELLOW, WHITE };
void SetColor(Color c) {
if (hCon == NULL)
hCon = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hCon, c);
}
SYSTEMTIME sys;
//sys.wYear,sys.wMonth,sys.wDay,sys.wHour,sys.wMinute, sys.wSecond,sys.wMilliseconds,sys.wDayOfWeek
struct PLAYER {
int x, y;
int hp;
int gun;
int direct;
} p1, p2;
int map[1005][1005];
int abs(int x) {
if (x < 0) return -x;
return x;
}
void locate(int x, int y) {
coord.X = y - 1;
coord.Y = x - 1;
SetConsoleCursorPosition(hout, coord);
}
void print_map() {
locate(1, 1);
SetColor(GRAY);
for (int i = 1; i <= SIZ; i++) cout << “■”;
locate(SIZ, 1);
for (int i = 1; i <= SIZ; i++) cout << “■”;
for (int i = 2; i < SIZ; i++) {
locate(i, 1);
cout << “■”;
locate(i, SIZ * 2 - 1);
cout << “■”;
}
locate(SIZ + 1, 1);
SetColor(WHITE);
}
void create_tree(int x, int y) {
map[x][y] = map[x + 1][y] = map[x - 1][y] = map[x][y + 1] = map[x][y - 1] = 2;
}
void use_map(int x) {
if (x == 1) {
SIZ = 20;
SetColor(DARKGREEN);
map[16][6] = map[15][6] = map[17][6] = map[16][7] = map[16][5] = map[14][13] = map[13][12] = map[13][13] = 2;
for (int i = 2; i < SIZ; i++) {
for (int j = 2; j < SIZ; j++) {
if (map[i][j] == 2) {
locate(i, j * 2 - 1);
cout << “■”;
}
}
}
SetColor(GRAY);
for (int i = 5; i <= 15; i++) {
map[i
用C++创作出来的双人枪战小游戏
最新推荐文章于 2025-06-16 20:01:50 发布