⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 czdemo.cpp

📁 gamecode 很不错的小游戏源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
						mymenu.ShowtMenu("购买了通行证!",tchoice,1);
						mygame.ppnum--;
						GL_GamePicShowSilence();
						Flip();
						return;
					}
					else if(mygame.cmnum<=0)
					{
						MyMenus mymenu(360,260,"pics/menu.fim",280,120,GetRect(0,0,280,120));
						char* tchoice[]={"确定"};	
						PressKey(VK_RETURN,1);
						mymenu.ShowtMenu("没有通行证了!",tchoice,1);
						soldout=true;
						shopshow();//刷新菜单
						Blt(pBBuf,x+120+count*140,y+60,choice,GetRect(0,0,28,27),true);
						Flip();
						break;
					}
				}
				break;
			case REMODICE:
				{
					remodice *rm=new remodice;
					tool=(MyTool*)rm;
					if(mygame.rdnum>0 && players[playerid].BuyTools(tool,playerid))
					{
						MyMenus mymenu(360,260,"pics/menu.fim",280,120,GetRect(0,0,280,120));
						char* tchoice[]={"确定"};	
						PressKey(VK_RETURN,1);
						mymenu.ShowtMenu("购买了摇控色子!",tchoice,1);
						//测试:
						mygame.rdnum--;//减1
						GL_GamePicShowSilence();
						Flip();
						return;
					}
					else if(mygame.cmnum<=0)
					{
						MyMenus mymenu(360,260,"pics/menu.fim",280,120,GetRect(0,0,280,120));
						char* tchoice[]={"确定"};	
						PressKey(VK_RETURN,1);
						mymenu.ShowtMenu("没有摇控色子了!",tchoice,1);
						soldout=true;
						shopshow();//刷新菜单
						Blt(pBBuf,x+120+count*140,y+60,choice,GetRect(0,0,28,27),true);
						Flip();
						break;
					}
				}
				break;
			case STOPCARD:
				{
					stopcard *sc=new stopcard;
					tool=(MyTool*)sc;
					if(mygame.stcnum>0 && players[playerid].BuyTools(tool,playerid))
					{
						MyMenus mymenu(360,260,"pics/menu.fim",280,120,GetRect(0,0,280,120));
						char* tchoice[]={"确定"};	
						PressKey(VK_RETURN,1);
						mymenu.ShowtMenu("购买了停留卡!",tchoice,1);
						mygame.stcnum--;
						GL_GamePicShowSilence();
						Flip();
						return;
					}
					else if(mygame.cmnum<=0)
					{
						MyMenus mymenu(360,260,"pics/menu.fim",280,120,GetRect(0,0,280,120));
						char* tchoice[]={"确定"};	
						PressKey(VK_RETURN,1);
						mymenu.ShowtMenu("没有停留卡了!",tchoice,1);
						soldout=true;
						shopshow();//刷新菜单
						Blt(pBBuf,x+120+count*140,y+60,choice,GetRect(0,0,28,27),true);
						Flip();
						break;
					}
				}
				break;
			case SUPERCAR:
				{
					supercar *sca=new supercar;
					tool=(MyTool*)sca;
					if(mygame.scnum>0 && players[playerid].BuyTools(tool,playerid))
					{
						MyMenus mymenu(360,260,"pics/menu.fim",280,120,GetRect(0,0,280,120));
						char* tchoice[]={"确定"};	
						PressKey(VK_RETURN,1);
						mymenu.ShowtMenu("购买了高级轿车!",tchoice,1);
						mygame.scnum--;
						GL_GamePicShowSilence();
						Flip();
						return;
					}
					else if(mygame.cmnum<=0)
					{
						MyMenus mymenu(360,260,"pics/menu.fim",280,120,GetRect(0,0,280,120));
						char* tchoice[]={"确定"};	
						PressKey(VK_RETURN,1);
						mymenu.ShowtMenu("没有高级轿车了!",tchoice,1);
						soldout=true;
						shopshow();//刷新菜单
						Blt(pBBuf,x+120+count*140,y+60,choice,GetRect(0,0,28,27),true);
						Flip();
						break;
					}
				}
				break;
			case TORTCARD:
				{
					tortcard *tt=new tortcard;
					tool=(MyTool*)tt;
					if(mygame.tcnum>0 && players[playerid].BuyTools(tool,playerid))
					{
						MyMenus mymenu(360,260,"pics/menu.fim",280,120,GetRect(0,0,280,120));
						char* tchoice[]={"确定"};	
						PressKey(VK_RETURN,1);
						mymenu.ShowtMenu("得到了乌龟卡!",tchoice,1);
						mygame.tcnum--;
						GL_GamePicShowSilence();
						Flip();
						return;
					}
					else if(mygame.cmnum<=0)
					{
						MyMenus mymenu(360,260,"pics/menu.fim",280,120,GetRect(0,0,280,120));
						char* tchoice[]={"确定"};	
						PressKey(VK_RETURN,1);
						mymenu.ShowtMenu("没有乌龟卡了!",tchoice,1);
						soldout=true;
						shopshow();//刷新菜单
						Blt(pBBuf,x+120+count*140,y+60,choice,GetRect(0,0,28,27),true);
						Flip();
						break;
					}
				}
				break;
			case BUYCARD:
				{
					buycard *bc=new buycard;
					tool=(MyTool*)bc;
					if(mygame.bcnum>0 && players[playerid].BuyTools(tool,playerid))
					{
						MyMenus mymenu(360,260,"pics/menu.fim",280,120,GetRect(0,0,280,120));
						char* tchoice[]={"确定"};	
						PressKey(VK_RETURN,1);
						mymenu.ShowtMenu("得到了收购卡!",tchoice,1);
						mygame.bcnum--;
						GL_GamePicShowSilence();
						Flip();
						return;
					}
					else if(mygame.bcnum<=0)
					{
						MyMenus mymenu(360,260,"pics/menu.fim",280,120,GetRect(0,0,280,120));
						char* tchoice[]={"确定"};	
						PressKey(VK_RETURN,1);
						mymenu.ShowtMenu("没有收购卡了!",tchoice,1);
						soldout=true;
						shopshow();//刷新菜单
						Blt(pBBuf,x+120+count*140,y+60,choice,GetRect(0,0,28,27),true);
						Flip();
						break;
					}
				}
				break;
			}//如果不能够买的话,分情况显示信息:
			if(players[PlayerID].toolindex>=8)
			{
				MyMenus mymenu(360,260,"pics/menu.fim",280,120,GetRect(0,0,280,120));
				char* tchoice[]={"确定"};	
				PressKey(VK_RETURN,1);
				mymenu.ShowtMenu("您的口袋已经装满了!",tchoice,1);
				GL_GamePicShowSilence();
				Flip();
				dochoose=false;
			}
			else if(soldout==false)
			{
				MyMenus mymenu(360,260,"pics/menu.fim",280,120,GetRect(0,0,280,120));
				char* tchoice[]={"确定"};	
				PressKey(VK_RETURN,1);
				mymenu.ShowtMenu("请带够钱再来吧!",tchoice,1);
				GL_GamePicShowSilence();
				Flip();
				dochoose=false;
			}	

		}
		if(GetAsyncKeyState(VK_CONTROL) )
		{
			PressKey(VK_CONTROL,1);
			dochoose=false;
			GL_GamePicShowSilence();
			Flip();
		}
	}//while
	return;
}

//更新回合选单
//传入id,返回是否能用工具,返回是否能收购
inline void showm(int playerid,bool& canuset,bool& canbuy)
{
	GL_GamePicShowSilence();
	int x=4*32;
	int y=6*32;
	if(players[playerid].tools.listlength()<1)
		canuset=false;
	else
		canuset=true;

	//canbuy=true;//这里的条件要改为由一些情况决定
	bool hasbc=false;//是否有收购卡
	MyTool *temp=new MyTool;
	for (int i=1;i<=players[playerid].tools.listlength();i++)
	{
		players[playerid].tools.getelem(i,temp);
		if(temp->kind==BUYCARD)
		{
			hasbc=true;
			break;
		}
	}
	if(players[playerid].GetExp()>20 && hasbc==true)//收购需要20点以上信誉
	{
		canbuy=true;
	}
	else 
		canbuy=false;

	Blt(pBBuf,x,y,select,GetRect(0,0,620,150),false);
	Blt(pBBuf,x+123,y+45,go,GetRect(0,0,120,55),false);
	if(true==canuset)
		Blt(pBBuf,x+283,y+45,uset,GetRect(0,0,120,55),false);
	if(true==canbuy)
		Blt(pBBuf,x+447,y+45,buy,GetRect(0,0,120,55),false);
	return;
}

bool chooseborf(int playerid,int currentid)
{
	PressKey(VK_RETURN,1);
	bool haschoose=false;
	int cx=6*32+20+190+98;//choice x,y小手指的位置
	int cy=6*32+50+50;
	//显示所选的thechoice的建筑
	bool hasbu=false;//是否有建筑
	bool hasfa=false;//是否有工厂
	int *recordkind=new int[6];//记录每个选项的种类
	for(int i=0;i<6;i++)
		recordkind[i]=-1;//表示不存在东西
	//	int choicei=0;//choice index ->recordkind的index值
	int Num=_showbuilding(playerid ,hasbu,hasfa,recordkind);
	Blt(pBBuf,cx,cy,choice,GetRect(0,0,28,27),true);//小手指
	Flip();
	bool dochoose=true;
	int thechoice=0;
	int count=0;
	while (dochoose)
	{
		PressKey(VK_CONTROL,1);//吸收Ctrl
		PressKey(VK_RETURN,1);
		PressKey(VK_UP,1);
		PressKey(VK_DOWN,1);
		if( Num!=1 && GetAsyncKeyState(VK_RIGHT) )	//下一项
		{
			PressKey(VK_RIGHT,1);
			thechoice=(thechoice+1)%Num;
			count=(count+1)%Num;
			showbuilding(playerid,hasbu,hasfa);//刷新菜单
			if(count>=3)
			{
				cy=6*32+50+50+150;
				cx=6*32+20+190+98-3*(96+43);
			}
			else
			{
				cx=6*32+20+190+98;
				cy=6*32+50+50;
			}
			Blt(pBBuf,cx+count*(96+43),cy,choice,GetRect(0,0,28,27),true);
			PlayDirectSound(selectsnd);
			Flip();
		}
		if( Num!=1 && GetAsyncKeyState(VK_LEFT) )//上一项
		{
			PressKey(VK_LEFT,1);
			if( thechoice==0 ) 
			{
				thechoice=Num-1;
				count=Num-1;
			}
			else 
			{
				thechoice--;
				count--;
			}
			if(count>=3)
			{
				cy=6*32+50+50+150;
				cx=6*32+20+190+98-3*(96+43);
			}
			else
			{
				cx=6*32+20+190+98;
				cy=6*32+50+50;
			}
			showbuilding(playerid,hasbu,hasfa);//刷新菜单
			Blt(pBBuf,cx+count*(96+43),cy,choice,GetRect(0,0,28,27),true);
			PlayDirectSound(selectsnd);
			Flip();
		}
		if( GetAsyncKeyState(VK_RETURN) )	//确定
		{
			PressKey(VK_RETURN,1);
			int posibility=rand()%100;//收购成功可能性(除房子以外)
			switch (recordkind[thechoice])
			{
			case 0:
				{
					int choice1;
					MyMenus mymenu(360,260,"pics/menu.fim",280,120,GetRect(0,0,280,120));
					char* tchoice[]={"确定","取消"};	
					PressKey(VK_RETURN,1);
					choice1=mymenu.ShowtMenu("收购住房?",tchoice,2);
					long costmoney=(long)2*getfactorycost(BUIGROUND);
					if(choice1==0 && players[currentid].GetMoney()>costmoney)//决定收购
					{
						int si=1;//搜索索引
						MyBuilding tempb;
						while(si<=maps.pbuilding.listlength())
						{							
							maps.pbuilding.getelem(si,tempb);
							if(tempb.owner==playerid)
							{
								if(maps.ChangeOwnerB(tempb.x,tempb.y,playerid,currentid))
								{
									
									players[currentid].buildingnum++;
									players[currentid].ChangeMoney(-costmoney);
									players[playerid].buildingnum--;
									players[playerid].ChangeMoney((long)(costmoney*0.7));
								}								
								haschoose=true;
								PlayDirectSound(success);
								char* info="收购住房成功!";
								MyMessage::PutMSG(SHOWMSG,info);
								mymessage.RunMSG();
								dochoose=false;
								break;
							}
							si++;
						}
						
					}
					else if(choice1==1)
					{
						showbuilding(playerid,hasbu,hasfa);//刷新菜单
						Blt(pBBuf,cx+count*(96+43),cy,choice,GetRect(0,0,28,27),true);
						Flip();
					}
					else if(players[currentid].GetMoney()<costmoney)
					{
						shownomoney();
						showbuilding(playerid,hasbu,hasfa);//刷新菜单
						Blt(pBBuf,cx+count*(96+43),cy,choice,GetRect(0,0,28,27),true);
						Flip();
					}
				}
				break;
			case BUILDFACTORY0:
				{
					int choice1;
					MyMenus mymenu(360,260,"pics/menu.fim",280,120,GetRect(0,0,280,120));
					char* tchoice[]={"确定","取消"};	
					PressKey(VK_RETURN,1);
					choice1=mymenu.ShowtMenu("收购汽车厂?",tchoice,2);
					long costmoney=(long)2*getfactorycost(BUILDFACTORY0);
					if(posibility<75 && choice1==0 && players[currentid].GetMoney()>costmoney)//决定收购
					{
						MyTool *temp=new MyTool;
						for(int i=1;i<=players[currentid].tools.listlength();i++)
						{
							players[currentid].tools.getelem(i,temp);
							if(temp->kind==BUYCARD)
							{
								players[currentid].UseTool(i);
								mygame.bcnum++;
								break;
							}
						}//先使用卡片
						int si=1;//搜索索引
						MyFactory tempf;
						while(si<=maps.pfactory.listlength())
						{							
							maps.pfactory.getelem(si,tempf);
							if(tempf.kind==recordkind[thechoice] && tempf.owner==playerid)
							{
								if(maps.ChangeOwnerF(tempf.x,tempf.y,playerid,currentid))
								{
									
									players[currentid].factorynum++;
									players[currentid].ChangeMoney(-costmoney);											
									players[playerid].factorynum--;
									players[playerid].ChangeMoney((long)(costmoney*0.7));
								}
								haschoose=true;
								PlayDirectSound(success);
								char* info="收购汽车厂成功!";
								MyMessage::PutMSG(SHOWMSG,info);
								mymessage.RunMSG();
								dochoose=false;
								break;
							}
							si++;
						}
						
					}
					else if(choice1==1)
					{
						showbuilding(playerid,hasbu,hasfa);//刷新菜单
						Blt(pBBuf,cx+count*(96+43),cy,choice,GetRect(0,0,28,27),true);
						Flip();
					}
					else if(players[currentid].GetMoney()<costmoney)
					{
						shownomoney();
						//	showbuilding(playerid,hasbu,hasfa);//刷新菜单
						//	Blt(pBBuf,cx+count*(96+43),cy,choice,GetRect(0,0,28,27),true);
						Flip();
						dochoose=false;
						haschoose=false;
						break;
					}
					else if(posibility>=75)
					{
						PlayDirectSound(fail);
						char* info="收购汽车厂失败!";
						MyMessage::PutMSG(SHOWMSG,info);
						mymessage.RunMSG();
						//	showbuilding(playerid,hasbu,hasfa);//刷新菜单
						//	Blt(pBBuf,cx+count*(96+43),cy,choice,GetRect(0,0,28,27),true);
						//	Flip();
						dochoose=false;
						haschoose=false;
						break;
					}
				}
				break;
			case BUILDFACTORY1:
				{
					int choice1;
					MyMenus mymenu(360,260,"pics/menu.fim",280,120,GetRect(0,0,280,120));
					char* tchoice[]={"确定","取消"};	
					PressKey(VK_RETURN,1);
					choice1=mymenu.ShowtMenu("收购食品厂?",tchoice,2);
					long costmoney=(long)2*getfactorycost(BUILDFACTORY1);
					if(posibility<75 && choice1==0 && players[currentid].GetMoney()>costmoney )//决定收购
					{
						MyTool *temp=new MyTool;
						for(int i=1;i<=players[currentid].tools.listlength();i++)
						{
							players[currentid].tools.getelem(i,temp);
							if(temp->kind==BUYCARD)
							{
								players[currentid].UseTool(i);
								m

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -