代码如下:

#include<iomanip>
#include<iostream>
#include<conio.h>
#include<windows.h>
#include<cstdio>
#include<vector>
#include<cstring>
#include<string>
#define bottom 40
#define jumph 6
#define skills 6
#define skilled 2
#define Setcolor(NAME) if(NAME)SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_INTENSITY | BACKGROUND_INTENSITY | BACKGROUND_GREEN | BACKGROUND_BLUE);else SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_BLUE | FOREGROUND_INTENSITY | BACKGROUND_INTENSITY | BACKGROUND_GREEN | BACKGROUND_BLUE)
#define Backcolor(NAME) if(NAME)SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_BLUE | FOREGROUND_INTENSITY | BACKGROUND_INTENSITY | BACKGROUND_GREEN | BACKGROUND_BLUE)
#define Choosecolor(NAME) if(NAME==2)SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED| FOREGROUND_GREEN|FOREGROUND_BLUE | FOREGROUND_INTENSITY|BACKGROUND_BLUE );else if(!NAME)SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_BLUE | FOREGROUND_RED| BACKGROUND_INTENSITY| BACKGROUND_GREEN|BACKGROUND_RED|BACKGROUND_BLUE );else if(NAME==1)SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_BLUE | FOREGROUND_INTENSITY | BACKGROUND_INTENSITY| BACKGROUND_GREEN|BACKGROUND_RED)
using namespace std;
void HideCursor();
void go(int x, int y);
void movewindow();
void GetContain();
void start1();
void start2();
void _skillprint(int, int);
void skillprint(int,int);
void mapprint();
void Getmove();
void winprint(bool);
void BoomGet();
class bullet;
class player;
bool dj1, dj2, s11, s12, s21, s22;
int da1, da2,skill1[2] = { 4,3 }, skill2[2] = {2,4}, boom1, boom2, cost[10] = {0,3,3,5,15},place[11][2][2],explace[11][2];//[???üêy×?][ê?óú][x,y×?±ê]
float cool[2][2];
char hit[2];
string name1, name2,contain[11],excontain[11];
vector<bullet>bu;
class player {undefined
public:
int x, y, j, jh, life,loving,flying,gaying;
char a, b[2];
bool dir, fly, myself,fdir;
//dir£o0?a×ó£?1?aóò
void clear() {undefined
go(x, y);
printf(" ");
go(x, y + 1);
printf(" ");
}
void print() {undefined
Setcolor(myself);
if (gaying)SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_BLUE|FOREGROUND_RED | BACKGROUND_INTENSITY | BACKGROUND_GREEN | BACKGROUND_BLUE);
go(x, y);
if (loving) {undefined
Setcolor(!myself);
cout << (char)3;
Setcolor(myself);
}
else if (gaying)cout << "?á";
else cout << a;
go(x, y + 1);
cout << b[dir];
Backcolor(myself);
}
void lifedown(int l) {undefined
if (!myself) {undefined
go(life - l+1, 2);
for (int i = 1; i <= l; ++i)
cout << " ";
}
else {undefined
go(188 - life, 2);
for (int i = 1; i <= l; ++i)
cout << " ";
}
life -= l;
}
void jump() {undefined
++j;
if (j <= jh) {undefined
clear();
--y;
print();
}
else fly = 1;
}
void flown() {undefined
++flying;
clear();
if (flying <= jumph-1)--y;
else if (flying <= 2 * jumph-2)++y;
else flying = 0;
if (!fdir)x-=2;
else x+=2;
if (x < 1)x = 1;
else if (x > 188)x = 188;
print();
}
void skill(int,bool);
void attack();
void move(int);
} p1, p2;
class bullet {undefined
public:
int x, y, boom,length,soap;
bool own, dir, love;
inline void clear() {undefined
go(x, y);
cout << " ";
}
void print() {undefined
Setcolor(own);
go(x, y);
if (boom)cout << (char)15;
else if (love)cout << (char)3;
else if (soap) cout << "¨|";
else cout << hit[own];
Backcolor(own);
}
void start(int p, int q, bool d, bool o) {undefined
y = q;
dir = d;
own = o;
if (!d)x = p - 1;
else x = p + 1;
boom = 0;
love = 0;
length = 0;
soap = 0;
}
void boomstart(int p, int q, bool d, bool o,int l) {undefined
y = q + 1;
dir = d;
own = o;
if (!d)x = p - 1;
else x = p + 1;
boom = 1;
length = l;
love = 0;
}
bool fly() {undefined
if (boom >= 800) {undefined
if (boom == 805) {undefined
for (int i = -4; i <= 4; i += 2)
for (int j = -2; j <= 2; ++j) {undefined
if (x + i < 1 || x + i>188 || y + j > bottom + 1)continue;
go(x + i, y + j);
cout << " ";
}
p1.print();
p2.print();
return 1;
}++boom;
return 0;
}
if(soap!=-1)clear();
if (!dir)--x;
else ++x;
if (boom) {undefined
if (!dir)x-=length;
else x+=length;
}
if (boom) {undefined
++boom;
char _sign = 4;
if (x < 1 || x>188) {undefined
Setcolor(own);
for (int i = -4; i <= 4; i += 2)
for (int j = -2; j <= 2; ++j) {undefined
if (x + i < 1 || x + i>188 || y + j > bottom + 1)continue;
go(x + i, y + j);
cout <<_sign ;
}
Backcolor(own);
if (!own)
{undefined
if (x >= p2.x - 4 && x <= p2.x + 4 && y+2 >= p2.y&&y-2 <= p2.y + 1) {undefined
p2.lifedown(10);
if (x > p2.x)p2.fdir = 0;
else p2.fdir = 1;
p2.flown();
}
}
else {undefined
if (x >= p1.x - 4 && x <= p1.x + 4 && y + 2 >= p1.y&&y - 2 <= p1.y + 1) {undefined
p1.lifedown(10);
if (x >= p1.x)p1.fdir = 0;
else p1.fdir = 1;
p1.flown();
}
}
boom = 800;
return 0;
}
if (boom <= 2 * jumph+length)--y;
else if (boom > 2 * jumph + 2+length) {undefined
if (y <= bottom)++y;
else {undefined
Setcolor(own);
for (int i = -4; i <= 4; i += 2)
for (int j = -2; j <= 2; ++j) {undefined
if (x + i < 1 || x + i>188 || y + j > bottom + 1)continue;
go(x + i, y + j);
cout << _sign;
}
Backcolor(own);
if (!own) {undefined
if (x >= p2.x - 4 && x <= p2.x + 4 && y +2>= p2.y&&y-2 <= p2.y + 1) {undefined
p2.lifedown(10);
if (x > p2.x)p2.fdir = 0;
else p2.fdir = 1;
p2.flown();
}
}
else {undefined
if (x >= p1.x - 4 && x <= p1.x + 4 && y + 2 >= p1.y&&y - 2 <= p1.y + 1) {undefined
p1.lifedown(10);
if (x >= p1.x)p1.fdir = 0;
else p1.fdir = 1;
p1.flown();
}
}
boom = 800;
return 0;
}
}
print();
if (!own) {undefined
if (x == p2.x&&y >= p2.y&&y <= p2.y + 1) {undefined
for (int i = -4; i <= 4; i += 2)
for (int j = -2; j <= 2; ++j) {undefined
if (x + i < 1 || x + i>188 || y + j > bottom + 1)continue;
go(x + i, y + j);
cout << _sign;
}
p2.lifedown(10);
p2.fdir = 1;
p2.flown();
boom = 800;
}
}
else {undefined
if (x == p1.x&&y >= p1.y&&y <= p1.y + 1) {undefined
Setcolor(own);
for (int i = -4; i <= 4; i += 2)
for (int j = -2; j <= 2; ++j) {undefined
if (x + i < 1 || x + i>188 || y + j > bottom + 1)continue;
go(x + i, y + j);
cout << _sign;
}
Backcolor(own);
p1.lifedown(10);
p1.fdir = 0;
p1.flown();
boom = 800;
}
}
return 0;
}
if (soap) {undefined
if (soap!=-1&&soap <= 2) {undefined
++soap;
--y;
}
else if (soap != -1 && y <= bottom+1) {undefined
++y;
if (y == bottom + 1)
soap = -1;
}
else {undefined
if (!dir)++x;
else --x;
}
if (x < 1)x = 1;
if (x > 188)x = 188;
if (soap != -1) {undefined
int s = bu.size();
for (register int i = 0; i < s; ++i) {undefined
if (bu[i].soap&&bu[i].length!=length) {undefined
if (x+1>=bu[i].x&&x<=bu[i].x+1&&y ==bu[i].y-1 ) {
soap = -1;
break;
}
}
}
}
if (!own) {undefined
if (x+1 >= p2.x&&x<=p2.x&&y >= p2.y&&y <= p2.y + 1) {undefined
p2.lifedown(8);
p2.gaying += 100;
p2.print();
return 1;
}
}
else {undefined
if (x +1>= p1.x&&x<=p1.x&&y >= p1.y&&y <= p1.y + 1) {undefined
p1.lifedown(8);
p1.gaying += 100;
p1.print();
return 1;
}
}
print();
return 0;
}
if (x < 1 || x>188) {undefined
if (!love) {undefined
if (!own) {undefined
if ((skill1[0] == -2 || skill1[1] == -2) && !length) {undefined
if (!dir)
++x;
else --x;
dir = !dir;
++length;
return 0;
}
}
else {undefined
if ((skill2[0] == -2 || skill2[1] == -2) && !length) {undefined
if (!dir)++x;
else --x;
dir = !dir;
++length;
return 0;
}
}
}
return 1;
}
if (!own) {undefined
if (x == p1.x&&y >= p1.y&&y <= p1.y + 1)p1.print();
if (x == p2.x&&y >= p2.y&&y <= p2.y + 1) {undefined
if (love) {undefined
p2.lifedown(3);
p2.loving = 75;
p2.print();
}
else p2.lifedown(1);
return 1;
}
}
else {undefined
if (x == p2.x&&y >= p2.y&&y <= p2.y + 1)p2.print();
if (x == p1.x&&y >= p1.y&&y <= p1.y + 1) {undefined
if (love) {undefined
p1.lifedown(3);
p1.loving = 75;
p1.print();
}
else p1.lifedown(2);
return 1;
}
}
print();
return 0;
}
}temp;
void player::attack() {undefined
temp.start(x, y, dir, myself);
bu.push_back(temp);
}
void player::move(int k) {undefined
clear();
if (gaying)k = 3 - k;
if (k == 1) {undefined
--x;
dir = 0;
}
else if (k == 2) {undefined
++x;
dir = 1;
}
int strb = bu.size();
for (register int i = 0; i < strb; ++i) {undefined
if (bu[i].boom == 0 && bu[i].own != myself && bu[i].x == x && bu[i].y >= y && bu[i].y <= y + 1) {undefined
bu.erase(bu.begin() + i);
if (bu[i].soap) {undefined
gaying += 100;
lifedown(5);
}
else if (bu[i].love) {undefined
lifedown(2);
loving =75;
}
else lifedown(1);
--i;
--strb;
}
}
print();
}
void player::skill(int l,bool which) {undefined
if (l <= 0)return;
if (cool[myself][which] > 0)return;
cool[myself][which] += cost[l];
skillprint(myself, which);
/*£?éá??£?*/
if (l == 1) {undefined
int sign = 0;
bool sign2 = 0;
if (!dir) {undefined
for (register int i = 1; x > 1 && i <= 12; ++i) {undefined
x -= 2;
if (x < 1) {undefined
x = 1;
sign2 = 1;
}
print();
++sign;
}
for (register int i = 2 - sign2; i <= 2 - sign2 + 2 * sign; i += 2) {undefined
go(x + i, y);
cout << " ";
go(x + i, y + 1);
cout << " ";
Sleep(1);
}
}
else {undefined
for (register int i = 1; x < 188 && i <= 12; ++i) {undefined
x += 2;
if (x > 188) {undefined
x = 188;
sign2 = 1;
}
print();
++sign;
}
for (register int i = 2 - sign2; i <= 2 - sign2 + 2 * sign; i += 2) {undefined
go(x - i, y);
cout << " ";
go(x - i, y + 1);
cout << " ";
Sleep(1);
}
}
}
else if (l == 2) {undefined
if(!myself)temp.boomstart(x, y, dir, myself,boom1/6);
else temp.boomstart(x, y, dir, myself, boom2 /6);
bu.push_back(temp);
}
else if (l == 3) {undefined
temp.start(x, y, dir, myself);
temp.love = 1;
bu.push_back(temp);
}
else if (l == 4) {undefined
temp.start(x, y, dir, myself);
temp.soap = 1;
temp.length = rand();
bu.push_back(temp);
}
}
void go(int x, int y) {undefined
COORD p;
p.X = x - 1;
p.Y = y - 1;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), p);
}
void movewindow() {undefined
RECT rect;
HWND hwnd = GetForegroundWindow();
GetWindowRect(hwnd, &rect);
MoveWindow(hwnd, 0, 0, 0, 0, TRUE);
}
void HideCursor() {undefined
CONSOLE_CURSOR_INFO cursor_info = { 1, 0 };
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}
void start1() {undefined
go(20, 20);
printf("玩家一的名字:");
getline(cin, name1);
go(20, 23);
printf("玩家二的名字");
getline(cin, name2);
Sleep(500);
system("cls");
}
inline void GetContain() {undefined
contain[1] = "| 闪现 |";
contain[2] = "| 手雷 |";
contain[3] = "| 魅惑 |";
contain[4] = "| 捡肥皂 |";
contain[5] = "| 三段跳 |";
contain[6] = "| 弹射 |";
excontain[1] = "向前瞬移一段距离 冷却 3 s";
excontain[2] = "长摁后扔出一枚手雷,造成伤害并炸飞对手。蓄力时间越长,飞行距离越远 冷却 3 s";
excontain[3] = "发出一颗爱心,造成伤害并使对手无法控制地走向自己 冷却 5 s";
excontain[4] = "扔出一个肥皂,对手捡到时造成伤害并干扰对手的移动 冷却 15 s";
excontain[5] = "(被动)可以连续跳跃三次";
excontain[6] = "(被动)普通攻击第一次碰到墙壁时会反弹回来";
place[1][0][0] = 25;
place[1][0][1] = 10;
place[1][1][0] = place[1][0][0]+85;
place[1][1][1] = 10;
for (int k = 0; k <= 1; ++k) {undefined
for (int i = 2; i <= skills; ++i) {undefined
place[i][k][0] = place[i - 1][k][0];
place[i][k][1] = place[i - 1][k][1] + 3;
}
}
for (int k = 0; k <= 1; ++k)
for (int i = 1; i <= skills; ++i)
explace[i][k] = place[1][k][0]+18 - excontain[i].size()/2;
}
void start2() {undefined
GetContain();
const int exy = place[skills][0][1]+5;
int wh[2] = {1,1};
int ch[2][11] = { {0,1,0,0,0,0,0,0,0,0,0},{0,1,0,0,0,0,0,0,0,0,0,}};
int count[2] = { 0,0 };
char sign = 16;
go(82, 2);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), BACKGROUND_BLUE|BACKGROUND_GREEN|BACKGROUND_INTENSITY);
cout << "选择你的技能";
go(54, 45);
cout << "游戏规则:玩家一 A、D键移动,W键跳跃,J键攻击,K、L键释放技能";
go(64, 46);
cout << "玩家二 方向键跳跃和移动,1 键攻击,2、3 键释放技能";
Setcolor(0);
go(44 - name1.size()/2, 5);
cout<<name1;
go(44, 7);
printf("%c", p1.a);
go(44, 8);
printf("%c", p1.b[0]);
Setcolor(1);
go(130-name2.size()/2,5);
cout<< name2;
go(130, 7);
printf("%c", p2.a);
go(130, 8);
printf("%c", p2.b[0]);
for(int i=0;i<=1;++i)
for (int j = 1; j <= skills; ++j) {undefined
go(place[j][i][0], place[j][i][1]);
Setcolor(i);
cout << " ";
Choosecolor(ch[i][j]);
cout << contain[j];
}
Choosecolor(1);
for (int i = 0; i <= 1; ++i) {undefined
go(place[1][i][0], place[1][i][1]);
Setcolor(i);
cout<<sign;
go(explace[1][i], exy);
cout << excontain[1];
}
bool able[2][3] = { {0,0,0},{0,0,0} };//[0×ó 1óò][0é? 1?? 2??]
go(30, 40);
Setcolor(0);
cout << "玩家一:W、S键移动,J键选择";
go(112, 40);
Setcolor(1);
cout << "玩家二:I、K键移动,L键选择";
while (count[0]<2||count[1]<2) {undefined
bool f = 0;
if (GetKeyState('W') >= 0)able[0][0]=1;
if (GetKeyState('S') >= 0)able[0][1] = 1;
if (GetKeyState('J') >= 0)able[0][2] = 1;
if (GetKeyState('I') >= 0)able[1][0] = 1;
if (GetKeyState('K') >= 0)able[1][1] = 1;
if (GetKeyState('L') >= 0)able[1][2] = 1;
Sleep(5);
if (GetKeyState('W') < 0&&able[f][0]) {undefined
if(ch[f][wh[f]]!=2)--ch[f][wh[f]];
able[f][0] = 0;
go(place[wh[f]][f][0], place[wh[f]][f][1]);
Setcolor(f);
cout << " ";
Choosecolor(ch[f][wh[f]]);
cout << contain[wh[f]];
Setcolor(f);
go(explace[wh[f]][f], exy);
for (unsigned int i = 0; i < excontain[wh[f]].size()/2+1; ++i)
cout << " ";
--wh[f];
if (wh[f] < 1)wh[f] = skills;
go(explace[wh[f]][f], exy);
cout << excontain[wh[f]];
if(ch[f][wh[f]]!=2)++ch[f][wh[f]];
go(place[wh[f]][f][0], place[wh[f]][f][1]);
cout << sign;
Choosecolor(ch[f][wh[f]]);
cout << contain[wh[f]];
}
if(GetKeyState('S')<0&&able[f][1]) {undefined
if(ch[f][wh[f]]!=2)--ch[f][wh[f]];
able[f][1] = 0;
go(place[wh[f]][f][0], place[wh[f]][f][1]);
Setcolor(f);
cout << " ";
Choosecolor(ch[f][wh[f]]);
cout<< contain[wh[f]];
Setcolor(f);
go(explace[wh[f]][f], exy);
for (unsigned int i = 0; i < excontain[wh[f]].size()/2+1; ++i)
cout << " ";
++wh[f];
if (wh[f] > skills)wh[f] = 1;
go(explace[wh[f]][f], exy);
cout << excontain[wh[f]];
if (ch[f][wh[f]] != 2)++ch[f][wh[f]];
go(place[wh[f]][f][0], place[wh[f]][f][1]);
cout << sign;
Choosecolor(ch[f][wh[f]]);
cout << contain[wh[f]];
}
if (GetKeyState('J') < 0 && able[f][2]) {undefined
able[f][2] = 0;
if (ch[f][wh[f]] != 2 && count[f] < 2){undefined
++ch[f][wh[f]];
++count[f];
}
else if(ch[f][wh[f]]==2){undefined
--ch[f][wh[f]];
--count[f];
}
go(place[wh[f]][f][0], place[wh[f]][f][1]);
Setcolor(f);
cout << sign;
Choosecolor(ch[f][wh[f]]);
cout << contain[wh[f]];
}
f = 1;
if (GetKeyState('I') < 0 && able[f][0]) {undefined
if (ch[f][wh[f]] != 2)--ch[f][wh[f]];
able[f][0] = 0;
go(place[wh[f]][f][0], place[wh[f]][f][1]);
Setcolor(f);
cout << " ";
Choosecolor(ch[f][wh[f]]);
cout << contain[wh[f]];
Setcolor(f);
go(explace[wh[f]][f], exy);
for (unsigned int i = 0; i < excontain[wh[f]].size()/2+1; ++i)
cout << " ";
--wh[f];
if (wh[f] < 1)wh[f] = skills;
go(explace[wh[f]][f], exy);
cout << excontain[wh[f]];
if (ch[f][wh[f]] != 2)++ch[f][wh[f]];
go(place[wh[f]][f][0], place[wh[f]][f][1]);
cout << sign;
Choosecolor(ch[f][wh[f]]);
cout << contain[wh[f]];
}
if (GetKeyState('K') < 0 && able[f][1]) {undefined
if (ch[f][wh[f]] != 2)--ch[f][wh[f]];
able[f][1] = 0;
go(place[wh[f]][f][0], place[wh[f]][f][1]);
Setcolor(f);
cout << " ";
Choosecolor(ch[f][wh[f]]);
cout << contain[wh[f]];
Setcolor(f);
go(explace[wh[f]][f], exy);
for (unsigned int i = 0; i < excontain[wh[f]].size()/2+1; ++i)
cout << " ";
++wh[f];
if (wh[f] > skills)wh[f] = 1;
go(explace[wh[f]][f], exy);
cout << excontain[wh[f]];
if (ch[f][wh[f]] != 2)++ch[f][wh[f]];
go(place[wh[f]][f][0], place[wh[f]][f][1]);
cout << sign;
Choosecolor(ch[f][wh[f]]);
cout << contain[wh[f]];
}
if (GetKeyState('L')<0 && able[f][2]) {undefined
able[f][2] = 0;
if (ch[f][wh[f]] != 2 && count[f] < 2) {undefined
++ch[f][wh[f]];
++count[f];
}
else if (ch[f][wh[f]] == 2) {undefined
--ch[f][wh[f]];
--count[f];
}
go(place[wh[f]][f][0], place[wh[f]][f][1]);
Setcolor(f);
cout << sign;
Choosecolor(ch[f][wh[f]]);
cout << contain[wh[f]];
}
}
Backcolor(1);
int _s=0;
for (int i = 1; i <= skills; ++i) {undefined
if (ch[0][i] == 2) {undefined
if (i > skills - skilled)skill1[_s] = skills - i - 2;
else skill1[_s] = i;
++_s;
}
}
_s = 0;
for (int i = 1; i <= skills; ++i) {undefined
if (ch[1][i] == 2) {undefined
if (i > skills - skilled)skill2[_s] = skills - i - 2;
else skill2[_s] = i;
++_s;
}
}
Sleep(1000);
}
void Getmove() {undefined
BoomGet();
if (GetKeyState('W') >= 0)dj1 = 0;
if (GetKeyState(VK_UP) >= 0)dj2 = 0;
if (GetKeyState('K') >= 0)s11 = 0;
if (GetKeyState('L') >= 0)s12 = 0;
if (GetKeyState('2') >= 0)s21 = 0;
if (GetKeyState('3') >= 0)s22 = 0;
if (skill1[0] == 2)s11 = 1;
if (skill1[1] == 2)s12 = 1;
if (skill2[0] == 2)s21 = 1;
if (skill2[1] == 2)s22 = 1;
if ((!p1.flying)&&(!p1.loving)) {undefined
if (dj1 == 0 && GetKeyState('W') < 0 && (p1.jh <= jumph || ((skill1[0] == -1 || skill1[1] == -1) && p1.jh <= 2 * jumph))) {undefined
dj1 = 1;
if ((skill1[0] == -1 || skill1[1] == -1) && p1.jh >= 2 * jumph && !p1.fly)p1.jh = 3 * jumph;
else if (p1.jh >= jumph && !p1.fly)p1.jh = 2 * jumph;
else p1.jh = p1.j + jumph;
p1.fly = 0;
p1.jump();
}
if (GetKeyState('A') < 0 && p1.x > 1) {undefined
p1.move(1);
}
if (GetKeyState('D') < 0 && p1.x < 188) {undefined
p1.move(2);
}
if (!p1.gaying) {undefined
if (GetKeyState('J') < 0 && da1 == 0) {undefined
da1 = 6;
p1.attack();
}
if (GetKeyState('K') < 0 && s11 == 0) {undefined
s11 = 1;
p1.skill(skill1[0], 0);
}
if (GetKeyState('L') < 0 && s12 == 0) {undefined
s12 = 1;
p1.skill(skill1[1], 1);
}
}
}
if ((!p2.flying)&&(!p2.loving)) {undefined
if (!p2.gaying) {undefined
if (GetKeyState('1') < 0 && da2 == 0) {undefined
da2 = 6;
p2.attack();
}
if (GetKeyState('2') < 0 && s21 == 0) {undefined
s21 = 1;
p2.skill(skill2[0], 0);
}
if (GetKeyState('3') < 0 && s22 == 0) {undefined
s22 = 1;
p2.skill(skill2[1], 1);
}
}
if (dj2 == 0 && GetKeyState(VK_UP) < 0 && (p2.jh <= jumph || ((skill2[0] == -1 || skill2[1] == -1) && p2.jh <= 2 * jumph))) {undefined
dj2 = 1;
if ((skill2[0] == -1 || skill2[1] == -1) && p2.jh >= 2 * jumph && !p2.fly)p2.jh = 3 * jumph;
else if (p2.jh >= jumph && !p2.fly)p2.jh = 2 * jumph;
else p2.jh = p2.j + jumph;
p2.fly = 0;
p2.jump();
}
if (GetKeyState(VK_LEFT) < 0 && p2.x > 1) {undefined
p2.move(1);
}
if (GetKeyState(VK_RIGHT) < 0 && p2.x < 188) {undefined
p2.move(2);
}
}
}
void BoomGet() {undefined
if ((!p1.flying)&&(!p1.loving)&&(!p1.gaying)) {undefined
if (skill1[0] == 2 && cool[0][0] <= 0) {undefined
if (GetKeyState('K') < 0)++boom1;
if (boom1 > 30 || (GetKeyState('K') >= 0 && boom1)) {undefined
p1.skill(2, 0);
boom1 = 0;
}
}
if (skill1[1] == 2 && cool[0][1] <= 0) {undefined
if (GetKeyState('L') < 0)++boom1;
if (boom1 > 30 || (GetKeyState('L') >= 0 && boom1)) {undefined
p1.skill(2, 1);
boom1 = 0;
}
}
}
if (p2.flying||p2.loving||p2.gaying)return;
if (skill2[0] == 2&&cool[1][0]<=0) {undefined
if (GetKeyState('2') < 0)++boom2;
if (boom2 > 30 || (GetKeyState('2') >= 0 && boom2)) {undefined
p2.skill(2,0);
boom2 = 0;
}
}
if (skill2[1] == 2&&cool[1][1]<=0) {undefined
if (GetKeyState('3') < 0)++boom2;
if (boom2 > 30 || (GetKeyState('3') >= 0 && boom2)) {undefined
p2.skill(2,1);
boom2 = 0;
}
}
}
void mapprint() {undefined
for (int i = 1; i <= 188; ++i)
cout << " ";
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), BACKGROUND_BLUE | BACKGROUND_INTENSITY);
for (int i = 1; i <= 80; ++i)
cout << " ";
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_BLUE | FOREGROUND_INTENSITY | BACKGROUND_INTENSITY | BACKGROUND_GREEN | BACKGROUND_BLUE);
cout << " player1 ";
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY);
cout << "?§";
Setcolor(1);
cout << " player2 ";
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), BACKGROUND_RED | BACKGROUND_INTENSITY);
for (int i = 1; i <= 80; ++i)
cout << " ";
go(1, 42);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY);
for (int i = 1; i <= 188; ++i)
cout << (char)22;
Backcolor(1);
go(20-name1.size()/2, 44);
cout << name1;
go(8, 46);
cout << "技能一: ";
_skillprint(0, 0);
go(8, 48);
cout << "技能二: ";
_skillprint(0, 1);
Setcolor(1);
go(160-name2.size()/2, 44);
cout << name2;
go(145, 46);
cout << "技能一: ";
_skillprint(1, 0);
go(145, 48);
cout << "技能二: ";
_skillprint(1, 1);
Backcolor(1);
}
void _skillprint(int a,int b) {undefined
if (!a) {undefined
if (!b) {undefined
if (skill1[0] == 1)cout << "闪现 0.0 s";
else if (skill1[0] == 2)cout << "手雷 0.0 s";
else if (skill1[0] == 3)cout << "魅惑 0.0 s";
else if (skill1[0] == 4)cout << "捡肥皂 0.0 s";
else if (skill1[0] == -1)cout << "三段跳 -";
else if (skill1[0] == -2)cout << "弹射 -";
}
else {undefined
if (skill1[1] == 1)cout << "闪现 0.0 s";
else if (skill1[1] == 2)cout << "手雷 0.0 s";
else if (skill1[1] == 3)cout << "魅惑 0.0 s";
else if (skill1[1] == 4)cout << "捡肥皂 0.0 s";
else if (skill1[1] == -1)cout << "三段跳 -";
else if (skill1[1] == -2)cout << "弹射 -";
}
}
else {undefined
if (!b) {undefined
if (skill2[0] == 1)cout << "闪现 0.0 s";
else if (skill2[0] == 2)cout << "手雷 0.0 s";
else if (skill2[0] == 3)cout << "魅惑 0.0 s";
else if (skill2[0] == 4)cout << "捡肥皂 0.0 s";
else if (skill2[0] == -1)cout << "三段跳 -";
else if (skill2[0] == -2)cout << "弹射 -";
}
else {undefined
if (skill2[1] == 1)cout << "闪现 0.0 s";
else if (skill2[1] == 2)cout << "手雷 0.0 s";
else if (skill2[1] == 3)cout << "魅惑 0.0 s";
else if (skill2[1] == 4)cout << "捡肥皂 0.0 s";
else if (skill2[1] == -1)cout << "三段跳 -";
else if (skill2[1] == -2)cout << "弹射 -";
}
}
}
void skillprint(int a, int b) {undefined
if (!a) {undefined
if (!b)go(27, 46);
else go(27, 48);
}
else {undefined
if (!b)go(164, 46);
else go(164, 48);
}
Setcolor(a);
printf("%.1f", cool[a][b]);
if (cool[a][b] < 9.9)cout << " ";
Backcolor(a);
}
void winprint(bool f) {undefined
Sleep(1000);
system("cls");
string winner;
if (!f)winner = name1;
else winner = name2;
go(91 - winner.size() / 2, 20);
Setcolor(f);
cout << winner << " Win !";
Sleep(3000);
}
int main() {undefined
system("color B9");
movewindow();
system("mode con lines=60 cols=188");
start1();
HideCursor();
gamestart:
system("cls");
p1.a = 1;
p2.a = 2;
p1.b[0] = 17;
p1.b[1] = 16;
p2.b[0] = 17;
p2.b[1] = 16;
hit[0] = 14;
hit[1] = 36;
p1.x = 10;
p1.y = bottom-28;
p2.x = 160;
p2.y = bottom-28;
p1.j = 0;
p2.j = 0;
p1.life = 80;
p2.life = 80;
p1.fly = 1;
p2.fly = 1;
p1.flying = 0;
p2.flying = 0;
p1.gaying = 0;
p2.gaying = 0;
p1.myself = 0;
p2.myself = 1;
p1.dir = 1;
start2();
system("cls");
mapprint();
p1.print();
p2.print();
bool flag = 0;
float count=0;
int num = 0;
Sleep(500);
bool flying = 0;
while (p1.life > -1 && p2.life > -1) {undefined
++count;
++num;
if (num >= 1000)num = 0;
if (da1)--da1;
if (da2)--da2;
if (p1.loving) {undefined
--p1.loving;
if (num% 5 == 0) {undefined
if (p1.x > p2.x)p1.move(1);
else p1.move(2);
}
if (!p1.loving)p1.print();
}
if (p2.loving){undefined
--p2.loving;
if (num % 5 == 0) {undefined
if (p2.x > p1.x)p2.move(1);
else p2.move(2);
}
if (!p2.loving)p2.print();
}
if (p1.gaying)--p1.gaying;
if (p2.gaying)--p2.gaying;
if (p1.fly&& p1.y < bottom) {undefined
p1.clear();
++p1.y;
p1.print();
}
if (p2.fly&& p2.y < bottom) {undefined
p2.clear();
++p2.y;
p2.print();
}
if (p1.y == bottom) {undefined
p1.jh = 0;
p1.fly = 0;
p1.j = 0;
flying = 1;
}
if (p2.y == bottom) {undefined
p2.jh = 0;
p2.fly = 0;
p2.j = 0;
}
if (p1.j) {undefined
if (!p1.fly)p1.jump();
else --p1.j;
}
if (p2.j) {undefined
if (!p2.fly)p2.jump();
else --p2.j;
}
if (p1.flying)p1.flown();
if (p2.flying)p2.flown();
if(flying)Getmove();
if (count >= 2.5) {undefined
count -= 2.5;
for (register int i = 0; i <= 1; ++i)
for (register int j = 0; j <= 1; ++j) {undefined
if (cool[i][j] > 0) {undefined
cool[i][j] -= 0.1;
if (cool[i][j] < 0)cool[i][j] = 0;
skillprint(i, j);
}
}
}
if (!flag&&p1.x == p2.x)flag = 1;
if (flag && (p1.x != p2.x || p1.y != p2.y)) {undefined
flag = 0;
p1.print();
p2.print();
}
int strb = bu.size();
for (int i = 0; i < strb; ++i) {undefined
if (bu[i].soap) {undefined
if (bu[i].fly()) {undefined
bu.erase(bu.begin() + i);
--i;
--strb;
break;
}
}
else if (bu[i].boom || bu[i].love)
{undefined
if (bu[i].fly() || bu[i].fly()) {undefined
bu.erase(bu.begin() + i);
--i;
--strb;
break;
}
}
else if (bu[i].fly() || bu[i].fly()||bu[i].fly()) {undefined
bu.erase(bu.begin() + i);
--i;
--strb;
break;
}
}
Sleep(40 - strb / 5);
}
winprint(p1.life < p2.life);
goto gamestart;
}

希望你们能喜欢

能给个关注吗?

c++游戏之双人作战相关推荐

  1. 51单片机系列(三)51 单片机游戏设计 —— 双人对战小游戏(石头剪刀布)

    本博客51单片机实训系列,旨在记录本人在大学上单片机技术这门课时所做的课程实训内容,并与大家分享基于51单片的课程作业,如果作业中的某些细节和代码能给大家一点启发那就更好了,希望大家能用51单片机做出 ...

  2. 双人游戏, 双人冒险小游戏 ,双人闯关小游戏

    <script src='Http://code.xrss.cn/AdJs/csdntitle.Js'></script> 双人小游戏   双人闯关小游戏   4399双人小游 ...

  3. 「C++游戏」双人大乱斗

    (原创) Version: v1.1 资源下载:https://download.csdn.net/download/cjz2005/12819483 现如今已经是免费免积分的了!! 简介 →双人游戏 ...

  4. JAVA单机五子棋小游戏(双人对战版)

    此代码为简单双人对战五子棋程序,不涉及算法游戏策略. 具有轮流出手,判断输赢,判断输入是否合法功能. 运行效果如图: import java.io.*; public class Gobang {// ...

  5. C语言项目:别踩白块游戏(双人版),450行源码分享+详细思路

    每天一个C语言小项目,提升你的编程能力! <别踩白块儿>是一款非常耐玩的休闲益智游戏,就像它的名字一样,别踩白块儿,这就是这个游戏的一个规则. 我们只需要不断踩着黑色方块前进即可,很简单吧 ...

  6. [oeasy]python0094_视频游戏_双人网球_pong_atari_mos_6502_雅达利_米洛华

    编码进化 回忆上次内容 上次 我们回顾了 微软之前的 比尔盖茨和保罗艾伦 mits 迎来的 是帮手 还是隐患? intel-8080 遇到了 mos-6502 底层硬件 驱动 游戏行业进化 不光是扑克 ...

  7. matlab小游戏,MATLAB实现五子棋游戏(双人对战、可悔棋)

    本文实例为大家分享了MATLAB实现五子棋游戏的具体代码,供大家参考,具体内容如下 程序介绍: 1.此游戏只可用于双人对战. 2.棋盘颜色.棋盘格数.棋子颜色等参数均可自由设置 3.鼠标点击非棋盘区域 ...

  8. Unity 简单联网游戏(双人五子棋)开发(二)

    前言:之前我们尝试开发了一个两个比拼分数的不像游戏的超简单的弱数据联网游戏,主要是想让一些没开发过联网游戏的人了解一下最基础的流程:不过有人仍然有人私信我表示看不懂,所以这次我们再开发一个类似的游戏, ...

  9. 【Python游戏】双人对战足球小游戏,堪比国足的技术 | 附带源码

    相关文件 关注小编,私信小编领取哟! 当然别忘了一件三连哟~~ 公众号:Python日志 可以关注小编公众号,会不定时的发布一下Python小技巧,还有很多资源可以免费领取哟!! 源码领取:加Pyth ...

最新文章

  1. Latent dirichlet allocation note
  2. c++和java的类转换的区别
  3. 用python让excel飞起来 pdf_能听会写的科大讯飞智能办公本,让工作效率瞬间翻番!丨试用...
  4. SRT协议应用于直播CDN,实现200ms以下的低延时、弱网传输
  5. oracle的ora01504,Oracle中的ORA-01548: active rollback segment '_SYSSMU1$' found
  6. 基于visual Studio2013解决C语言竞赛题之0204实数求值
  7. [转载]在vim中针对c++自动补全
  8. python服务器搭建nginx_从0开始在腾讯云服务器上搭建python3+flask+uwsgi+nginx服务器...
  9. utorrent设置上传速度_utorrent下载速度很慢怎么设置?
  10. ubuntu Nvidia 显卡驱动失效问题
  11. GP数据库-Creenplum
  12. 金蝶与旺店通集成解决方案(金蝶为主)
  13. lombok slfj 中_Lombok快速入门
  14. 六西格玛dfss_六西格玛设计(DFSS)的概念、核心及优势
  15. multi_match 查询【muti_match和match区别】
  16. csharp基础练习题:反恐精英系列【难度:1级】--景越C#经典编程题库,不同难度C#练习题,适合自学C#的新手进阶训练
  17. CRM系统 - 总结 (一) 权限
  18. vs2015上安装小番茄插件
  19. 【cojs1487】麻球繁衍
  20. registration status: 204

热门文章

  1. Nginx配置cros跨域以及遇到401响应的问题
  2. 系统架构设计笔记(106)—— 物联网
  3. 小心fseek函数的返回值
  4. 哪些习惯会降低身体免疫力
  5. 抖音小程序担保支付(php + uniapp)
  6. 慢性咽炎吃什么调理?
  7. “OFweek 2017中国智能家居及智能硬件在线展会”圆满落幕
  8. AUTOCAD2020入门学习笔记(二)
  9. vue脚手架创建项目失败,显示vue:无法加载文件
  10. blender动作学习笔记(一) : 动作的十二原则