我是靠谱客的博主 微笑飞鸟,最近开发中收集的这篇文章主要介绍【Devc++】双人跑酷小游戏3.1,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

我把3.0版本的其他的更新都放在了2.0.1版本上

做成了3.1版本

#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
using namespace std;
const long long dts=4;
long long wj1x,wj1y,wj2x,wj2y,cs=0,dtbh;
bool f=1,t1=1,t2=1,sy;
long long csx[dts+1]={
	0,
	14,
	1,
	1,
	1
};
long long csy[dts+1]={
	0,
	1,
	37,
	1,
	1
};
string dt[dts+1][21]={
	{""},
	{
		"",
		"                                                                            ",
		"                                                                            ",
		"                                                                ==  ===  == ",
		"                                                        ===  ===          < ",
		"                                                  ==                      < ",
		"                                                                          < ",
		"                  ==                           ==^^^^^^^^^^^==            < ",
		"                         ======                                           < ",
		"              ==                       === =======                        < ",
		"               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^< ",
		"         ==                                                               < ",
		"                                                                          < ",
		"     ==                                                                   < ",
		"                                                 ^                         $",
		" ========>  <=== === === ==  = === = == === ==== ^ ====  === == = == = =====",
		"                                                                            ",
		"                                                                            ",
		"                                                                            ",
		"                                                                            ",
		"                                                                            ",
	},
	{
		"",
		"                              >                   <      =              =   ",
		"                              >                   <      =              =   ",
		"        =                     >                   <      =        =     =   ",
		" ^^^^^   =                    >     ===           <      =        ==    =   ",
		"         <=                   >               = =^       =         ===  =   ",
		"         < =                   ^^^^^^^^^^^^^^^    <      =$             =   ",
		"         <  =                                     <      =            ===   ",
		"      ^^^<   =                 ==              ^^^       =^^^^^^^^==    =   ",
		"         <    =                  =          ^^^          =============  =   ",
		"         <     =                  ===    ==  <                          =   ",
		"         <     ======^^^^^^^^^^^^^   ^^^^  ^^            ================   ",
		"         <                                                                  ",
		" ^^^^    <         ==                                ==                     ",
		"         <        =                                                         ",
		"         <       =                               ==                         ",
		" ==== ^^^       =                                                           ",
		"               =                             ==                             ",
		"     ==========                     =======                                 ",
		"                                                                            ",
		"                                                                            "
	},
	{
		"",
		"                                                                           =",
		"                                                                           =",
		"                                                                           =",
		" ====^=====^=====^=====^=====^=====^=====^=====^=====^=====^=====^=====^== =",
		"                                                                           =",
		"                                        =====      <>                      =",
		"                                             =           <>         <>     =",
		"   ==============================^^^^^^^^^^^^=============================^=",
		"        <                                                                  =",
		"        <             ==                                   ==              =",
		"        <            =                                    =                =",
		" ^^^    <           =                                    =                 =",
		"        <          =                                    =                  =",
		"        <         =                                    =                   =",
		"    ^^^^<        =                                    =                    =",
		"        <       =                                    =                     =",
		"        <      =                                    =                      =",
		"              =                                    =                       =",
		" ==============                               =====                       $=",
		"                                                                           ="
	},
	{
		"",
		"   <                                                                       =",
		"   <                                                                       =",
		"   <                                                                       =",
		"   <                                                                       =",
		"   <               =============================                           =",
		"   <               =          =    =           = =====================     =",
		"   <               ==  ==     =   $=       ==  = =                    ==   =",
		"   <               =   =      =    =       =   = =                         =",
		"   <               =  ==  ^^^^==           =  == =                       ===",
		"   <               =   =      =       ^^^^^=   = =              ===  ===   =",
		"   <               ==  =      ===============  = =                         =",
		"   <               =   =^^                     = =           ==            =",
		"   <               = =========================== =             ===         =",
		"   <               =                             =               =         =",
		"   <    ^          ===============================               =         =",
		"   <   =>                                                        ===       =",
		"      ==>                                                                ===",
		" ====================================================================      =",
		"                                                                           =",
		"                                                                           ="
	}
};
void csh()
{
	f=1,t1=1,t2=1;
	cs=0;
	return ;
}
void color(int c)
{
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), c);
}
void gb() 
{
    CONSOLE_CURSOR_INFO cursor;
    cursor.bVisible=FALSE;
    cursor.dwSize=sizeof(cursor);
    HANDLE handle=GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleCursorInfo(handle, &cursor);
}
void out();
void in();
void lx();
void js();
int main()
{
	srand(time(0));
	color(240);
	system("mode con cols=75 lines=20");
	gb();
	while(1)
	{
		csh();
		dtbh=rand()%dts+1;
		wj1x=wj2x=csx[dtbh];
		wj1y=wj2y=csy[dtbh];
		while(f)
		{
			system("cls");
			out();
			in();
			js();
			if(cs==1)
			lx();
			Sleep(10);
			if(cs==1)cs=-1;
			cs++;
		}
		system("cls");
		if(!sy)
		{
			color(9);
			system("cls");
			cout<<"*赢了!";
			cout<<"n按Enter结束";
			char t=getch();
			while(t!=13)t=getch();
			color(153);
		}
		else
		{
			color(12);
			system("cls");
			cout<<"+赢了!";
			cout<<"n按Enter结束";
			char t=getch();
			while(t!=13)t=getch();
			color(204);
		}
		system("cls");
	}
	return 0;
}
void out()
{
	for(long long i=1;i<=19;i++)
	{
		for(long long j=1;j<=75;j++)
		{
			if(i==wj1x&&j==wj1y)
			{
				color(9);
				cout<<"*";
			}
			else
			if(i==wj2x&&j==wj2y)
			{
				color(12);
				cout<<"+";
			}
			else
			if(dt[dtbh][i][j]=='$')
			{
				color(10);
				cout<<"$";
			}
			else
			{
				color(240);
				cout<<dt[dtbh][i][j];
			}
		}
		cout<<endl;
	}
	return ;
}
void in()
{
	if(GetKeyState('A')<0&&(dt[dtbh][wj1x][wj1y-1]==' '||dt[dtbh][wj1x][wj1y-1]=='$')&&wj1y-1>0)
	{
		wj1y--;
	}
	if(GetKeyState('D')<0&&(dt[dtbh][wj1x][wj1y+1]==' '||dt[dtbh][wj1x][wj1y+1]=='$')&&wj1y-1<=100)
	{
		wj1y++;
	}
	if(GetKeyState('W')<0&&(dt[dtbh][wj1x-1][wj1y]==' '||dt[dtbh][wj1x-1][wj1y]=='$')&&t1)
	{
		wj1x--;
		for(long long i=1;i<=2;i++)
		if(dt[dtbh][wj1x-1][wj1y]==' ')wj1x--;
		t1=0;
	}
	if(GetKeyState(37)<0&&(dt[dtbh][wj2x][wj2y-1]==' '||dt[dtbh][wj2x][wj2y-1]=='$')&&wj2y-1>0)
	{
		wj2y--;
	}
	if(GetKeyState(39)<0&&(dt[dtbh][wj2x][wj2y+1]==' '||dt[dtbh][wj2x][wj2y+1]=='$')&&wj1y-1<=100)
	{
		wj2y++;
	}
	if(GetKeyState(38)<0&&(dt[dtbh][wj2x-1][wj2y]==' '||dt[dtbh][wj2x-1][wj2y]=='$')&&t2)
	{
		wj2x--;
		for(long long i=1;i<=2;i++)
		if(dt[dtbh][wj2x-1][wj2y]==' ')wj2x--;
		t2=0;
	}
	return ;
}
void lx()
{
	if(dt[dtbh][wj1x+1][wj1y]==' '||dt[dtbh][wj1x+1][wj1y]=='$')wj1x++;
	else t1=1;
	if(dt[dtbh][wj2x+1][wj2y]==' '||dt[dtbh][wj2x+1][wj2y]=='$')wj2x++;
	else t2=1;
	return ;
}
void js()
{
	if(dt[dtbh][wj1x][wj1y]=='$')
	{
		f=0;
		sy=0;
	}
	if(dt[dtbh][wj2x][wj2y]=='$')
	{
		f=0;
		sy=1;
	}
	if(wj1x==20)
	{
		wj1x=csx[dtbh];wj1y=csy[dtbh];
	}
	if(wj2x==20)
	{
		wj2x=csx[dtbh];wj2y=csy[dtbh];
	}
	if(dt[dtbh][wj1x+1][wj1y]=='^')
	{
		wj1x=csx[dtbh];wj1y=csy[dtbh];
	}
	if(dt[dtbh][wj2x+1][wj2y]=='^')
	{
		wj2x=csx[dtbh];wj2y=csy[dtbh];
	}
	if(dt[dtbh][wj1x][wj1y+1]=='<')
	{
		wj1x=csx[dtbh];wj1y=csy[dtbh];
	}
	if(dt[dtbh][wj2x][wj2y+1]=='<')
	{
		wj2x=csx[dtbh];wj2y=csy[dtbh];
	}
	if(dt[dtbh][wj1x][wj1y-1]=='>')
	{
		wj1x=csx[dtbh];wj1y=csy[dtbh];
	}
	if(dt[dtbh][wj2x][wj2y-1]=='>')
	{
		wj2x=csx[dtbh];wj2y=csy[dtbh];
	}
	return ;
}

最后

以上就是微笑飞鸟为你收集整理的【Devc++】双人跑酷小游戏3.1的全部内容,希望文章能够帮你解决【Devc++】双人跑酷小游戏3.1所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(41)

评论列表共有 0 条评论

立即
投稿
返回
顶部