代码
#include"bits/stdc++.h" //Devc++的,vsc++没有
#include<windows.h>
#include<stdio.h>
#include<conio.h>
#define kd(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
#define sys system
#define cls system("cls")
#define pause sys("pause")
using namespace std;
double juli(double x1,double y1,double x2,double y2){
int lsbl=pow(max(x1,x2)-min(x1,x2),2)+pow(max(y1,y2)-min(y1,y2),2);
return sqrt(lsbl);
}
bool neice=0;
void print(){
cerr<<"1.剑士 hp:100 att:7 1技能:劈砍\n";
cerr<<"2.咒术师 hp:75 att:10 1技能:诅咒\n";
cerr<<"3.链魂者 hp:75 att:7 1技能:链魂 2技能:魂破(使用1技能后再用一次发动)\n";
cerr<<"4.忍者 hp:65 att:10 1技能:斩 2技能:隐身(被动)\n";
cerr<<"5.次非 hp:95 att:7 1技能:寒极\n";
}
void gotoxy(int x, int y){//覆盖清屏 ,从指定行列覆盖
COORD pos={(short)x,(short)y};
HANDLE hOut=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hOut, pos);
}
string shenying="关";
bool vip=0;
bool game_std(){
cls;
int hp=1,hp2=1,att=1,att2=1,bh,bh2,i=0,le=0,le2=0,liani=0,hai=0,hi=0;
bool winter1=1,zhou=0,lian=0,yin1,yin2;
int y1i=0,y2i=0;
int x1=5,y1=5,x2=6,y2=6;
print();
cerr<<"玩家1:";
in:cin>>bh;
switch(bh){
case 1:
hp=100,att=7;
break;
case 2:
hp=75,att=10;
break;
case 3:
hp=75,att=7;
break;
case 4:
hp=65,att=10;
break;
case 5:
hp=95,att=7;
break;
default:
goto in;
break;
}
cerr<<"玩家2:";
in2:cin>>bh2;
switch(bh2){
case 1:
hp2=100,att2=7;
break;
case 2:
hp2=75,att2=10;
break;
case 3:
hp2=75,att2=7;
break;
case 4:
hp2=65,att2=10;
break;
case 5:
hp2=95,att2=7;
break;
default:
goto in2;
break;
}
while(1){
if(hp<=0||hp2<=0){/*胜负*/
if(hp<=0){
winter1=0;
}
break;
}
/*正常*/
if(zhou){
i++;
}
if(i>=15){
if(bh==2)
hp2-=30;
else
hp-=30;
i=0;
zhou=0;
}
if(lian){
liani++;
}
if(liani>=100){
lian=0,liani=0;
}
if(bh==4){
if(y1i>=300){
y1i=0,yin1=!yin1;
}else y1i++;
}
if(bh2==4){
if(y2i>=300){
y2i=0,yin2=!yin2;
}else y2i++;
}
if(hai){
if(hi>=60){
hai=0;
hi=0;
}else{
hi++;
}
}
if(le){
if(time(NULL)-le>=20){
le=0;
}
}
if(le2){
if(time(NULL)-le2>=20){
le2=0;
}
}
for(int i=0;i<10;i++){
for(int i1=0;i1<30;i1++){
if(x1==i&&y1==i1){
if(!yin1){
if(lian)cerr<<"①";
else cerr<<"1 ";}
else cerr<<" ";
}else if(x2==i&&y2==i1){
if(!yin2){
if(lian)cerr<<"②";
else cerr<<"2 ";}
else cerr<<" ";
}else cerr<<" ";
}
cerr<<endl;
}
for(int i=0;i<30;i++){
cerr<<"-";
}
cerr<<endl;
cerr<<"玩家1:\n";
cerr<<"hp="<<hp;
cerr<<"\natt="<<att;
cerr<<"\n英雄:";
switch(bh){
case 1:
cerr<<"剑士\n";
break;
case 2:
cerr<<"咒术师\n";
break;
case 3:
cerr<<"链魂师\n";
break;
case 4:
cerr<<"忍者\n";
break;
case 5:
cerr<<"次非 \n";
break;
default:
//TODO
break;
}
cerr<<"技能:";
switch(bh){
case 1:
cerr<<"劈砍\n";
break;
case 2:
cerr<<"诅咒\n";
break;
case 3:
cerr<<"1技能:链魂 2技能:魂破\n";
break;
case 4:
cerr<<"1技能:斩 2技能:隐身(被动)\n";
break;
case 5:
cerr<<"技能:寒极\n";
break;
default:
//TODO
break;
}
if(le){
cerr<<"冷却中\n";
}
cerr<<"玩家2:\n";
cerr<<"hp="<<hp2;
cerr<<"\natt="<<att2;
cerr<<"\n英雄:";
switch(bh2){
case 1:
cerr<<"剑士\n";
break;
case 2:
cerr<<"咒术师\n";
break;
case 3:
cerr<<"链魂师\n";
break;
case 4:
cerr<<"忍者\n";
break;
case 5:
cerr<<"次非\n";
break;
default:
//TODO
break;
}
cerr<<"技能:";
switch(bh2){
case 1:
cerr<<"劈砍\n";
break;
case 2:
cerr<<"诅咒\n";
break;
case 3:
cerr<<"1技能:链魂 2技能:魂破\n";
break;
case 4:
cerr<<"1技能:斩 2技能:隐身(被动)\n";
break;
case 5:
cerr<<"技能:寒极\n";
break;
default:
//TODO
break;
}
if(le2){
cerr<<"冷却中\n";
}
if(hai==1){
goto end1;
}
if(kd('W')){
x1--;
}
if(kd('S')){
x1++;
}
if(kd('A')){
y1--;
}
if(kd('D')){
y1++;
}
if(kd('1')){
switch(bh){
case 1:
if(!le){
if(juli(x1,y1,x2,y2)<=5){
hp2-=25;
if(juli(x1,y1,x2,y2)<=3){
hp2-=25;
}
}
le=time((NULL));
}
break;
case 2:
if(!le){
zhou=1;
le=time(NULL);
}
break;
case 3:
if(lian){
lian=0;
hp2-=30;
le=time(NULL);
}else{
if(!le){
lian=1;le=time(NULL);
Sleep(500);
}
}
break;
case 4:
if(!le){
cls;
x1=x2;
y1=y2;
yin1=1;
y1i=0;
hp2-=(hp2/4);
gotoxy(60,15);
cerr<<"斩!";
Sleep(1000);
cls;
le2=time(0);
le=time(0);
}
break;
case 5:
if(!le){
le2=time(0)+20;
le=time(0);
hai=2;
cls;
gotoxy(60,15);
cerr<<"风萧萧兮易水寒,壮士一去兮不复还!\n";
Sleep(1000);
cls;
}
break;
default:
//TODO
break;
}
}
if(kd('Q')){
if(juli(x1,y1,x2,y2)<=5||(lian&&bh==3)){
hp2-=att;
}
yin1=0;
}
if(hai==2){
goto end2;
}
end1:if(kd(VK_UP)){
x2--;
}
if(kd(VK_DOWN)){
x2++;
}
if(kd(VK_LEFT)){
y2--;
}
if(kd(VK_RIGHT)){
y2++;
}
if(kd(VK_NUMPAD1)){
switch(bh2){
case 1:
if(!le2){
if(juli(x1,y1,x2,y2)<=5){
hp-=25;
if(juli(x1,y1,x2,y2)<=3){
hp-=25;
}
}
le2=time((NULL));
}
break;
case 2:
if(!le2){
zhou=1;
le2=time(NULL);
}
break;
case 3:
if(lian){
lian=0;
hp-=30;
le2=time(NULL);
}else{
if(!le){
lian=1;le2=time(NULL);
Sleep(500);
}
}
break;
case 4:
if(!le2){
cls;
x2=x1;
y2=y1;
yin2=1;
y2i=0;
hp-=(hp/4);
gotoxy(60,15);
cerr<<"斩!";
Sleep(1000);
cls;
le2=time(0);
le=time(0);
}
break;
case 5:
if(!le2){
le2=time(0)+20;
le=time(0);
hai=1;
cls;
gotoxy(60,15);
cerr<<"风萧萧兮易水寒,壮士一去兮不复还!\n";
Sleep(1000);
cls;
}
break;
default:
//TODO
break;
}
}
if(kd(VK_NUMPAD0)){
if(juli(x1,y1,x2,y2)<=5||(lian&&bh2==3)){
hp-=att2;
}
yin2=0;
}
if(shenying=="开"){
Beep(1046,100);
}
end2:cls;
}
Sleep(1000);
return winter1;
}
bool game_jishu(){
cls;
int hp=95,hp2=95,att=3,att2=3;
bool winter1=1;
int x1=5,y1=5,x2=6,y2=6;
while(1){
if(hp<=0||hp2<=0){/*胜负*/
if(hp<=0){
winter1=0;
}
break;
}
/*正常*/
for(int i=0;i<10;i++){
for(int i1=0;i1<30;i1++){
if(x1==i&&y1==i1){
cerr<<"1 ";
}else if(x2==i&&y2==i1){
cerr<<"2 ";
}else cerr<<" ";
}
cerr<<endl;
}
for(int i=0;i<30;i++){
cerr<<"-";
}
cerr<<endl;
cerr<<"玩家1:\n";
cerr<<"hp="<<hp<<"\n";
cerr<<"玩家2:\n";
cerr<<"hp="<<hp2<<endl;
if(kd('W')){
x1--;
}
if(kd('S')){
x1++;
}
if(kd('A')){
y1--;
}
if(kd('D')){
y1++;
}
if(kd('Q')){
if(juli(x1,y1,x2,y2)<=5){
hp2-=att;
}
}
if(kd(VK_UP)){
x2--;
}
if(kd(VK_DOWN)){
x2++;
}
if(kd(VK_LEFT)){
y2--;
}
if(kd(VK_RIGHT)){
y2++;
}
if(kd(VK_NUMPAD0)){
if(juli(x1,y1,x2,y2)<=5){
hp-=att2;
}
}
if(shenying=="开"){
Beep(1046,100);
}
cls;
}
Sleep(1000);
return winter1;
}
void game(){
cls;
Sleep(500);
cerr<<"模式:\n";
cerr<<"1.标准\n";
cerr<<"2.无技能\n";
int ms=0;
in:cin>>ms;
switch(ms){
case 1:
if(game_std()){
cls;
cerr<<"玩家1获胜!!!\n";
}else{
cls;
cerr<<"玩家2获胜!!!\n";
}
pause;
break;
case 2:
if(game_jishu()){
cls;
cerr<<"玩家1获胜!!!\n";
}else{
cls;
cerr<<"玩家2获胜!!!\n";
}
pause;
break;
default:
goto in;
break;
}
}
int main(){
string peise="黑白";
while(1){
if(vip){
sys("color 76");
cerr<<"您是尊贵的VIP用户\n";
}
cerr<<"谁与争锋1.0.0.2版\n\n ";
cerr<<"1.开始游戏\n ";
cerr<<"2.游戏详情\n ";
cerr<<"3.作者的话\n ";
cerr<<"4.公告\n ";
cerr<<"5.设置\n ";
getch();
if(kd('1')||kd(VK_NUMPAD1)){
game();
}
if(kd('2')||kd(VK_NUMPAD2)){
cls;
Sleep(500);
cerr<<"开始制作日期:2023.7.18\n";
cerr<<"结束日期:2023.7.18\n";
cerr<<"版本:1.0.2.0\n";
cerr<<"作者:杨某一辰\n";
cerr<<"感谢:脏脏包\n";
pause;
cls;
cerr<<"玩家1:wasd移动\nq射击\n1放技能\n";
cerr<<" 玩家2↑←↓→:移动\n数字0射击\n数字1放技能\n";
pause;
}
if(kd('3')||kd(VK_NUMPAD3)){
cls;
Sleep(500);
cerr<<"希望大家玩的开心!\n";
cerr<<"作者:杨某一辰\n";
cerr<<"感谢:脏脏包\n";
cerr<<"1.进入主页 0.返回\n";
int lsbl_kd_3;
cin>>lsbl_kd_3;
if(lsbl_kd_3){
sys("start https://blog.csdn.net/langhat?type=lately");
sys("start https://blog.csdn.net/weixin_57427186?type=blog");
Sleep(500);
SetCursorPos(1522,280);
Sleep(500);
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
Sleep(10);
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
}
}
if(kd('4')||kd(VK_NUMPAD4)){
cls;
cerr<<"版本1.0.0.0(2023.7.11-2023.7.12)\n";
cerr<<"无公告\n\n";
cerr<<"版本1.0.0.1(2023.7.14)\n";
cerr<<"更新主界面:公告,设置;更新 新角色:链魂师\n链魂师和咒术师一局只有一个人能用!!!(不然会出BUG!)\n\n";
cerr<<"版本1.0.2.0(2023.7.18)\n";
cerr<<"更新角色:忍者!本次是大更新!更新了一点玩法!\n\n";
cerr<<"版本1.0.2.1(2013.7.19):\n";
cerr<<"更新角色:次非!这是一个近战类型的角色!可以冰冻别人!\n更新了一个新模式!\n在这感谢脏脏包指出了程序中的Bug!\n\n";
pause;
}
if(kd('5')||kd(VK_NUMPAD5)){
cls;
Sleep(500);
cerr<<"1.配色:"<<peise<<"\n";
cerr<<"2.声音:"<<shenying<<"\n";
cerr<<"3.VIP设置\n";
cerr<<"4.内测开启"<<endl;
int lsbl_kd5;
cin>>lsbl_kd5;
switch(lsbl_kd5){
case 1:{
cls;
cerr<<"当前配色:"<<peise<<"\n";
cerr<<"1.黑白 2.白黑 3.自定义\n";
cin>>lsbl_kd5;
switch(lsbl_kd5){
case 1:
sys("color 0f");
peise="黑白";
break;
case 2:
sys("color f0");
peise="白黑";
break;
case 3:cls;{
char th1,th2;
bool th1b=0,th2b=0;
cerr<<"0 = 黑色 8 = 灰色\n\
1 = 蓝色 9 = 淡蓝色\n\
2 = 绿色 A = 淡绿色\n\
3 = 浅绿色 B = 淡浅绿色\
4 = 红色 C = 淡红色\n\
5 = 紫色 D = 淡紫色\n\
6 = 黄色 E = 淡黄色\n\
7 = 白色 F = 亮白色(大写!)\n";
cerr<<"背景色:";
cin>>lsbl_kd5;
if(lsbl_kd5>='A'&&lsbl_kd5<='F'){
th1=lsbl_kd5;
th1b=1;
}
cerr<<"前景色:";
int lsbl_kd5_case3;
cin>>lsbl_kd5_case3;
if(lsbl_kd5_case3>='A'&&lsbl_kd5_case3<='F'){
th2=lsbl_kd5_case3;
th2b=1;
}
char str[12]{};
if(th1b){
if(th2b){
sprintf(str,"color %c%c",th1,th2);
}else{
sprintf(str,"color %c%d",th1,lsbl_kd5_case3);
}
}else{
if(th2b){
sprintf(str,"color %d%c",lsbl_kd5,th2);
}else{
sprintf(str,"color %d%d",lsbl_kd5,lsbl_kd5_case3);
}
}
sys(str);
peise="自定义";
break;}
default:
//TODO
break;
}
break;}
case 2:{
cerr<<"声音:"<<shenying<<endl;
cerr<<"(y/n)";
char ch=getch();
if(ch=='y'||ch=='Y')
shenying="开";
else
shenying="关";
break;}
case 3:{
string name;
cerr<<"你的名字:";
cin>>name;
if(name=="杨某一辰"||name=="留在记忆里的一抹残影"||name=="脏脏包"){
cerr<<"您已开启VIP\n";
vip=1;
}
break;}
case 4:
cerr<<"已开启!";
neice=1;
Sleep(1000);
break;
default:
break;
}
}
cls;
}
}
更新内容
更新角色:次非!这是一个近战类型的角色!可以冰冻别人!
还更新了一个新模式!
后文
给个赞呗!
你们的赞是对我最大的写文章的动力!