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

📄 mygame.cpp

📁 基于C++的RPG小游戏
💻 CPP
📖 第 1 页 / 共 5 页
字号:
				vxg.push_back(xgtemp);
				player1.PPos.x =100;
				player1.PPos.y=221;
				player1.pmovidx=8;
				player1.health=500;
				player1.movestate =0;
				player1.playerstate =0;
				player1.bulltp=2;
				player1.bullpw=3;
				player1.boom=9;
				rl.xgPos.x  =66;
				rl.xgPos .y =226;
				player1.zd.clear ();

			}

		}
		b.rboss.left=b.x+40;
		b.rboss.top=b.y+60;
		b.rboss.right=b.rboss.left+190;
		b.rboss.bottom=b.rboss.top+220;
		for (itbul=player1.zd.begin();itbul!=player1.zd.end();itbul++)
		{
			bullet temp;
			temp=*itbul;
			if (temp.status!=BULLET_UNABLE)
			{
				RECT r1;
				r1.left =temp.Pos.x;
				r1.right=r1.left+temp.width;
				r1.top=temp.Pos.y;
				r1.bottom=r1.top+temp.height;

				if (msIsIntersectRect( &r1,&b.rboss ))
				{
						if (temp.type==1)
						{
							xg xgtemp(48,32,b.x+40,temp.Pos.y,11,11,6);
							vxg.push_back(xgtemp);
						}
						if (temp.type==2)
						{
							xg xgtemp(43,43,b.x+40,temp.Pos.y,9,3,7);
							vxg.push_back(xgtemp);
						}
						if (temp.type==0)
						{
							xg xgtemp(8,8,b.x+30,temp.Pos.y-8,6,6,8);
							vxg.push_back(xgtemp);
							xg xgtemp1(8,8,b.x+45,temp.Pos.y,6,6,8);
							vxg.push_back(xgtemp1);
							xg xgtemp2(8,8,b.x+40,temp.Pos.y+8,6,6,8);
							vxg.push_back(xgtemp2);
						}
						temp.status=BULLET_UNABLE;
			
			}
			}
			(*itbul)=temp;
			
		}



		RECT r1;
		r1.left=player1.PPos.x;
		r1.top=player1.PPos.y;
		r1.right=r1.left+player1.width;
		r1.bottom=r1.top+player1.height;
		if (msIsIntersectRect( &r1,&b.rboss ))
		{
			mboom1->Play();
			xg xgtemp(54,50,player1.PPos.x,player1.PPos.y,10,10,3);
			vxg.push_back(xgtemp);
			player1.PPos.x =100;
			player1.PPos.y=221;
			player1.pmovidx=8;
			player1.health=500;
			player1.movestate =0;
			player1.playerstate =0;
			player1.bulltp=2;
			player1.bullpw=3;
			player1.boom=9;
			rl.xgPos.x  =66;
			rl.xgPos .y =226;
			player1.zd.clear ();
		}
		GetGraphics()->DrawBitmapMMX( b.x,b.y ,pboss , SCREENBUFFER,true );



	}

	for (itbul=player1.zd.begin ();itbul!=player1.zd .end ();itbul++)
		{
		bullet temp;
		temp=*itbul;
		static int idx=0;
		int dx,dy;

		
		if (temp.type==0)
		{
		int py=0;
		py=rand();
		py+=90;
		if (py>16440) py=1;
		else py=-1; 
		if (temp.Pos.x>=640) 
		{
			temp.status=BULLET_UNABLE;
		}
		temp.Pos.x+=32;
		temp.Pos.y+=(int((temp.Pos.x-player1.PPos.x)/150)*py);
		}
		if (temp.type==1)
		{
			
			if (temp.power==0)
			{
			dy=0;
			dx=20;
			temp.Pos.y+=dy;
			}
			if (temp.power==1)
			{
			if (idx==0) {dy=-3;dx=15;}
			if (idx==1) {dy=0;dx=20;}
			if (idx==2) {dy=3;dx=15;}
			idx++;
			temp.Pos.y+=dy;
			if (idx==3) idx=0;
			}
			if (temp.power==2)
			{
				if (idx==0) {dy=-3;dx=15;}
				if (idx==1) {dy=0;dx=20;}
				if (idx==2) {dy=3;dx=15;}
				idx++;
				temp.Pos.y+=dy;
				if (idx==3) idx=0;
			}
			if (temp.power==3)
			{
				if (idx==0) {dy=-3;dx=16;}
				if (idx==1) {dy=-1;dx=18;}
				if (idx==2) {dy=1;dx=18;}
				if (idx==3) {dy=3;dx=16;}
				idx++;
				temp.Pos.y+=dy;
				if (idx==4) idx=0;
			}
			temp.Pos.x+=dx;
			if ((temp.Pos.x>640)||(temp.Pos.y<0)||(temp.Pos.y>480)) temp.status=BULLET_UNABLE;
		}
		if (temp.type==2)
		{
			if (temp.power==0)
			{
				dy=0;
				dx=50;
				temp.Pos.y+=dy;
				temp.Pos.x+=dx;
			}
			if (temp.power==1)
			{
				if (idx==0) {dy=40;temp.Pos.y-=dy;dx=(int)sqrt((double)abs(temp.Pos.y-temp.dy));temp.Pos.x+=2*dx;}
				if (idx==1) {dy=0;dx=50;temp.Pos.y+=dy;temp.Pos.x+=dx;}
				if (idx==2) {dy=40;temp.Pos.y+=dy;dx=(int)sqrt((double)abs(temp.Pos.y-temp.dy));temp.Pos.x+=2*dx;}
				idx++;
				if (idx==3) idx=0;
			}
			if (temp.power==2)
			{
				if (idx==0) {dy=40;temp.Pos.y-=dy;dx=(int)sqrt((double)abs(temp.Pos.y-temp.dy));temp.Pos.x+=2*dx;}
				if (idx==1) {dy=0;dx=50;temp.Pos.y+=dy;temp.Pos.x+=dx;}
				if (idx==2) {dy=40;temp.Pos.y+=dy;dx=(int)sqrt((double)abs(temp.Pos.y-temp.dy));temp.Pos.x+=2*dx;}
				if (idx==3) {dy=0;dx=-50;temp.Pos.y+=dy;temp.Pos.x+=dx;}
				idx++;
				if (idx==4) idx=0;
			}
			if (temp.power==3)
			{
				if (idx==0) {dy=40;temp.Pos.y-=dy;dx=(int)sqrt((double)abs(temp.Pos.y-temp.dy));temp.Pos.x+=2*dx;}
				if (idx==1) {dy=0;dx=50;temp.Pos.y+=dy;temp.Pos.x+=dx;}
				if (idx==2) {dy=40;temp.Pos.y+=dy;dx=(int)sqrt((double)abs(temp.Pos.y-temp.dy));temp.Pos.x+=2*dx;}
				if (idx==3) {dy=0;dx=-50;temp.Pos.y+=dy;temp.Pos.x+=dx;}
				idx++;
				if (idx==4) idx=0;
			}

			if ((temp.Pos.x<0)||(temp.Pos.x>640)||(temp.Pos.y<0)||(temp.Pos.y>480)) temp.status=BULLET_UNABLE;
		}

		(*itbul)=temp;
		}
	for (itbul=player1.zd.begin ();itbul!=player1.zd .end ();itbul++)
		{
		bullet temp;
		temp=*itbul;
		if(temp.status==BULLET_NORMAL)
		{
		if (temp.type==0)
		{
			if ((temp.power==0)||(temp.power==2))
			{
				temp.drect .left =0;
				temp.drect .right =32;
				temp.drect .top =8;
				temp.drect .bottom =15;
			}
			if ((temp.power==1)||(temp.power==3))
			{
				temp.drect .left =0;
				temp.drect .right =32;
				temp.drect .top =16;
				temp.drect .bottom =23;
			}
			GetGraphics()->DrawBitmapMMX( temp.Pos.x,temp.Pos.y ,bull[temp.type ] , SCREENBUFFER, &temp.drect,true );

		}
		if (temp.type==1)
		{
			
			if ((temp.power==0)||(temp.power==1))
			{
				temp.drect .left =16;
				temp.drect .right =31;
				temp.drect .top =0;
				temp.drect .bottom =15;
				
			}
			if ((temp.power==2)||(temp.power==3))
			{
				temp.drect .left =32;
				temp.drect .right =47;
				temp.drect .top =0;
				temp.drect .bottom =15;
				
			}
			GetGraphics()->DrawBitmapMMX( temp.Pos.x,temp.Pos.y ,bull[temp.type ] , SCREENBUFFER, &temp.drect,true );
		}
		if (temp.type==2)
		{
			temp.animidx=retran(4);
			if ((temp.power==0)||(temp.power==1)||(temp.power==2))
			{
//				if (temp.animidx==temp.maxframe)temp.animidx =0;
				temp.drect .left =temp.animidx*temp.width;
				temp.drect .right =temp.drect.left+temp.width;
				temp.drect .top =0;
				temp.drect .bottom =temp.drect .top+temp.height;
//				temp.animidx++;
			}
			if (temp.power==3)
			{
//				if (temp.animidx==temp.maxframe)temp.animidx =0;
				temp.drect .left =temp.animidx*temp.width;
				temp.drect .right =temp.drect.left+temp.width;
				temp.drect .top =40;
				temp.drect .bottom =temp.drect .top+temp.height;
//				temp.animidx++;
			}

			GetGraphics()->DrawBitmapMMX( temp.Pos.x,temp.Pos.y ,bull[temp.type ] , SCREENBUFFER, &temp.drect,true );
		}
		}
		(*itbul)=temp;
		}

		
	
	for (itpen=planeenemy.begin();itpen!=planeenemy.end();itpen++)
	{
		Cpenemy tempp;
		tempp=*itpen;
		if (tempp.enemystate!=ENEMY_STATUS_DEAD)
		{
		
		if (tempp.movetype==0)
		{
			tempp.PPos.x-=tempp.speed;
		}
		if (tempp.movetype==3)
		{
			tempp.PPos.x-=2;
			tempp.PPos.y+=4;
		}
		if (tempp.movetype==4)
		{
			tempp.PPos.x-=3;
			tempp.PPos.y-=4;
		}
		if (tempp.movetype==5)
		{
			tempp.PPos.x-=1;
			tempp.PPos.y+=6;
		}
		if (tempp.movetype==1)
		{
			tempp.PPos.x-=tempp.speed;
			tempp.PPos.y-=1;
		}
		if (tempp.movetype==2)
		{
			static int a=0;
			if (a==0)
			{tempp.PPos.x-=5;}
			if (a==2)
			{tempp.PPos.x-=5;}
			if (a==4)
			{tempp.PPos.x-=6;}
			if (a==6)
			{tempp.PPos.x-=6;}
			if (a==8)
			{tempp.PPos.x-=7;}
			if (a==10)
			{tempp.PPos.x-=7;}
			if (a==12)
			{tempp.PPos.x-=8;}
			if (a==14)
			{tempp.PPos.x-=8;}
			if (a==16)
			{tempp.PPos.x-=9;}
			if (a==18)
			{tempp.PPos.x-=9;}
			if (a==20)
			{tempp.PPos.x-=10;}
			if (a==22)
			{tempp.PPos.x-=10;}
			if (a==24)
			{tempp.PPos.x-=11;}
			if (a==26)
			{tempp.PPos.x-=11;}
			if (a==28)
			{}

			if (a==32)
			{tempp.PPos.x+=11;}
			if (a==34)
			{tempp.PPos.x+=11;}
			if (a==36)
			{tempp.PPos.x+=10;}
			if (a==38)
			{tempp.PPos.x+=10;}
			if (a==40)
			{tempp.PPos.x+=9;}
			if (a==42)
			{tempp.PPos.x+=9;}
			if (a==44)
			{tempp.PPos.x+=8;}
			if (a==46)
			{tempp.PPos.x+=8;}
			if (a==48)
			{tempp.PPos.x+=7;}
			if (a==48)
			{tempp.PPos.x+=7;}
			if (a==50)
			{tempp.PPos.x+=6;}
			if (a==52)
			{tempp.PPos.x+=6;}
			if (a==54)
			{tempp.PPos.x+=5;}
			if (a==58)
			{tempp.PPos.x+=5;}
			if (a==60)
			{tempp.enemystate=ENEMY_STATUS_DEAD;a=0;}
				tempp.PPos.y-=5;
			a++;


		}
		}
		if(tempp.enemystate!=ENEMY_STATUS_DEAD)
		{
		
		if (tempp.enemytype==0)
		{
		tempp.bulidx++;
		if ((tempp.bulidx==tempp.bullettim)&&(tempp.PPos.x>(player1.PPos.x+50)))
		{
			tempp.bulidx=0;
			bullet bul(16,16,15,tempp.PPos.x-16,tempp.PPos.y+23,3,1,6,5);
			if(bul.movtype==1)
			{
				float sin,cos,dist,a,b;
				a=tempp.PPos.x-player1.PPos.x-(player1.width/2);
				b=tempp.PPos.y+42-player1.PPos.y-17;
				dist=(float)(sqrt(pow(a,2)+pow(b,2)));
				cos=a/dist;
				sin=b/dist;
				bul.dx=-int(bul.speed*cos);
				bul.dy=-int(bul.speed*sin);
			}
			bul.status=BULLET_NORMAL;
			tempp.zd.push_back(bul);	
		}
		}
		if (tempp.enemytype==1)
		{
		tempp.bulidx++;
		if ((tempp.bulidx==tempp.bullettim)&&(tempp.PPos.x>(player1.PPos.x+50)))
		{
			tempp.bulidx=0;
			bullet bul(16,16,15,tempp.PPos.x-16,tempp.PPos.y+42,4,2,6,10);
			bul.status=BULLET_NORMAL;
			bullet bul1(16,16,15,tempp.PPos.x-16,tempp.PPos.y+42,4,2,6,10);
			bul1.status=BULLET_NORMAL;
			bullet bul2(16,16,15,tempp.PPos.x-16,tempp.PPos.y+42,4,2,6,10);
			bul2.status=BULLET_NORMAL;
			tempp.zd.push_back(bul);
			tempp.zd.push_back(bul1);
			tempp.zd.push_back(bul2);
		}
		}
		if (tempp.enemytype==2)
		{
			tempp.bulidx++;
			if (tempp.bulidx==tempp.bullettim)
			{
				tempp.bulidx=0;
				bullet bul(16,16,15,tempp.PPos.x-16,tempp.PPos.y+17,5,1,6,10);
				float sin,cos,dist,a,b;
				a=tempp.PPos.x-player1.PPos.x-(player1.width/2);
				b=tempp.PPos.y+42-player1.PPos.y-17;
				dist=(float)(sqrt(pow(a,2)+pow(b,2)));
				cos=a/dist;
				sin=b/dist;
				bul.dx=-int(bul.speed*cos);
				bul.dy=-int(bul.speed*sin);
				bul.status=BULLET_NORMAL;
				tempp.zd.push_back(bul);
			}
		}
		if (tempp.enemytype==4)
		{
			tempp.bulidx++;
			if (tempp.bulidx==tempp.bullettim)
			{
				tempp.bulidx=0;
				bullet bul(40,9,25,tempp.PPos.x-40,tempp.PPos.y+12,6,2,2,20);
				bul.status=BULLET_NORMAL;
				bullet bul1(40,9,25,tempp.PPos.x-40,tempp.PPos.y+12,6,2,2,20);
				bul.status=BULLET_NORMAL;
				bullet bul2(40,9,25,tempp.PPos.x-40,tempp.PPos.y+12,6,2,2,20);
				bul.status=BULLET_NORMAL;
				tempp.zd.push_back(bul);
				tempp.zd.push_back(bul1);
				tempp.zd.push_back(bul2);
			}
		}
		if (tempp.enemytype==5)
		{
			tempp.bulidx++;
			if (tempp.bulidx==tempp.bullettim)
			{
				tempp.bulidx=0;
				bullet bul(16,16,25,tempp.PPos.x+16,tempp.PPos.y+17,7,2,1,10);
				bul.status=BULLET_NORMAL;
				bullet bul1(16,16,25,tempp.PPos.x+16,tempp.PPos.y+17,7,2,1,10);
				bul.status=BULLET_NORMAL;
				bullet bul2(16,16,25,tempp.PPos.x+16,tempp.PPos.y+17,7,2,1,10);
				bul.status=BULLET_NORMAL;
				bullet bul3(16,16,25,tempp.PPos.x+16,tempp.PPos.y+17,7,2,1,10);
				bul.status=BULLET_NORMAL;
				tempp.zd.push_back(bul);
				tempp.zd.push_back(bul1);
				tempp.zd.push_back(bul2);
				tempp.zd.push_back(bul3);
			}
		}
		if (tempp.enemytype==6)
		{
			tempp.bulidx++;
			if (tempp.bulidx==tempp.bullettim)
			{
				tempp.bulidx=0;
				bullet bul(32,4,25,tempp.PPos.x+32,tempp.PPos.y+40,8,2,2,15);
				bul.status=BULLET_NORMAL;
				bullet bul1(32,4,25,tempp.PPos.x+32,tempp.PPos.y+50,8,2,2,15);
				bul.status=BULLET_NORMAL;
				bullet bul2(32,4,25,tempp.PPos.x+32,tempp.PPos.y+60,8,2,2,15);

⌨️ 快捷键说明

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