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

📄 a.cpp

📁 此程序是一个按键打气球的小游戏
💻 CPP
📖 第 1 页 / 共 2 页
字号:

		    if(time==3) 
				KillTimer(hwnd,ID_TIMER11);

			time++;
			
			return 0;


		
		case 12:

			KillTimer(hwnd,ID_TIMER0);
			KillTimer(hwnd,ID_TIMER1);
			KillTimer(hwnd,ID_TIMER2);
			KillTimer(hwnd,ID_TIMER3);
			KillTimer(hwnd,ID_TIMER4);
			KillTimer(hwnd,ID_TIMER5);
			KillTimer(hwnd,ID_TIMER6);
			KillTimer(hwnd,ID_TIMER7);
			KillTimer(hwnd,ID_TIMER8);
			KillTimer(hwnd,ID_TIMER9);

			return 0;

		case 13:

			Timer13Flag++;
			SetTimer(hwnd,ID_TIMER0,Timer[0],NULL);
			SetTimer(hwnd,ID_TIMER1,Timer[1],NULL);
			SetTimer(hwnd,ID_TIMER2,Timer[2],NULL);
			SetTimer(hwnd,ID_TIMER3,Timer[3],NULL);
			SetTimer(hwnd,ID_TIMER4,Timer[4],NULL);
			SetTimer(hwnd,ID_TIMER5,Timer[5],NULL);
			SetTimer(hwnd,ID_TIMER6,Timer[6],NULL);
			SetTimer(hwnd,ID_TIMER7,Timer[7],NULL);
			SetTimer(hwnd,ID_TIMER8,Timer[8],NULL);
			SetTimer(hwnd,ID_TIMER9,Timer[9],NULL);

			SetTimer(hwnd,ID_TIMER11,60000,NULL);
			return 0;
		
		}
		
		
	case WM_PAINT:

		hdc=BeginPaint(hwnd,&ps);
			
		
		GetClientRect(hwnd,&recttemp);
		BitBlt(hdc,0,0,recttemp.right,recttemp.bottom,hMem,0,0,SRCCOPY);


		EndPaint(hwnd,&ps);
	

		return 0;
	
	case WM_KEYDOWN:
			
			BigSmallWriteFlag=0;
			if(Timer13Flag==0) return 0;
			hdc=GetDC(hwnd);
			CapsLockState=GetKeyState(VK_CAPITAL);
			ShiftState=GetKeyState(VK_SHIFT);
			
			if(CapsLockState==0&&ShiftState>0||CapsLockState==1&&ShiftState<0||CapsLockState==0&&ShiftState==0)
			{
				key=wParam+32-97;
				BigSmallWriteFlag=1;
			}
			else if(CapsLockState==1&&ShiftState>0||CapsLockState==0&&ShiftState<0)
			{
				key=wParam-39;
				BigSmallWriteFlag=2;
			}
			else  key=52;

			for(i=0;i<10;i++)
			{
				if(BitmapValue[i]==key)
				{
					rectflag[i]=1;
					KillTimer(hwnd,i);
					SetTimer(hwnd,i,10,NULL);
					SendMessage(Burstballoonhwnd,WM_TIMER,15,0);
					return 0;
				}

			}
			return 0;

	case WM_DESTROY:

		PostQuitMessage(0);

		return 0;

	}

	return DefWindowProc(hwnd,message,wParam,lParam);
}

void InitBalloon(HDC hMemBitmap[57],HBITMAP hBitmap[63])
{
	for(int i=0;i<57;i++)
	{
		hMemBitmap[i]=CreateCompatibleDC(NULL);
		SelectObject(hMemBitmap[i],hBitmap[i]);
	}
}
int  GetRand(int Number,int Super)
{
	static int			m;
	static int			first;
	int					i;
	int					j=0;
	int					k;
	int					l;
	static int			temp[110];

	int					mm;

	if(m>=(100+Super))
	{
		first=0;
		m=0;
	}
	if(first==0)
	{
		first++;
		srand( (unsigned)time( NULL ) );
		for( i =0;i<100;i++ )
		{
			temp[i]=rand()%Number;
		}
	}
		
	if(!Super)
		return temp[m++];

	srand((unsigned)time(NULL));
	i=100;
	while(j<Super)
	{
		k=rand()%51;
		if(k<=25)
			continue;
		else
		{
			temp[i++]=k;
			j++;
		}
	}

	srand((unsigned)time(NULL));

	for( i =100;i<100+Super;i++ )
	{
		mm=m;
		if(m>=99) break;
		k=rand()%100;
		if(k<=m) 
		{
			i--;
			continue;
		}
		l=temp[k];
		temp[k]=temp[i];
		temp[i]=l;
	}
	return temp[m++];
}
void OnPaint(HDC hdc,int flag,RECT *Furect,RECT ClientRect,RECT rect,int rectnumber,int ButtonHeight,int cxSource,int cySource,HDC hMemBitmap,HBITMAP hBitmap[63],HDC hMemory1,HDC hMemory3,HDC hMem)
{

	if(rectnumber>=7&&(rect.top+cySource>ClientRect.bottom-ButtonHeight))
	{
		cySource=ClientRect.bottom-ButtonHeight-rect.top;
		if(cySource<=32)
		{
			BitBlt(hMemory3,0,0,cxSource,cySource,hMem,rect.left,rect.top,SRCCOPY);
			BitBlt(hMemory3,0,0,cxSource,cySource,hMemory1,0,0,SRCPAINT);
			BitBlt(hMemory3,0,0,cxSource,cySource,hMemBitmap,0,0,SRCAND);
			BitBlt(hdc,rect.left,rect.top,cxSource,cySource,hMemory3,0,0,SRCCOPY);
		}
	}
	if(cySource>32)
	{
		if(flag!=1)
		{
			if(rectnumber<3||rectnumber>7)
			{
				if(Furect->top>=-46)
					StretchBlt(hdc,Furect->left,Furect->bottom-10,cxSource,10,hMem,Furect->left,Furect->top+cySource-10,cxSource,10,SRCCOPY);
				if(Furect->top<-46&&Furect->top>=-56)
					BitBlt(hdc,Furect->left,40,cxSource,10,hMem,Furect->left,40,SRCCOPY);
			}
			else
				StretchBlt(hdc,Furect->left,Furect->bottom-10,cxSource,10,hMem,Furect->left,Furect->top+cySource-10,cxSource,10,SRCCOPY);
		}
		
		Furect->left=rect.left;
		Furect->top=rect.top;
		Furect->right=Furect->left+cxSource;
		Furect->bottom=Furect->top+cySource;

		
		BitBlt(hMemory3,0,0,cxSource,cySource,hMem,rect.left,rect.top,SRCCOPY);
		BitBlt(hMemory3,0,0,cxSource,cySource,hMemory1,0,0,SRCPAINT);
		BitBlt(hMemory3,0,0,cxSource,cySource,hMemBitmap,0,0,SRCAND);
		if(rectnumber<3||rectnumber>7)
		{
			if(rect.top<40&&(cySource-(40-rect.top))>0) 
				BitBlt(hdc,rect.left,40,cxSource,cySource-(40-rect.top),hMemory3,0,cySource-(cySource-(40-rect.top)),SRCCOPY);
			else if(rect.top>40)
			BitBlt(hdc,rect.left,rect.top,cxSource,cySource,hMemory3,0,0,SRCCOPY);
		}
		else
			BitBlt(hdc,rect.left,rect.top,cxSource,cySource,hMemory3,0,0,SRCCOPY);
	}

	
}


void BalloonBurst(HWND hwnd,HDC hdc,HDC hMem,HBITMAP hBitmap[63],RECT ClientRect,RECT *rect,int ButtonHeight,HDC hMemory2,HDC hMemory4,HDC hMemory5,int cxSource,int cySource,HDC hMemBitmap[57],int IDTIMER,RECT *Furect,int Timer,int *rectflag)
{
	if(IDTIMER>=7&&(rect->top+cySource>ClientRect.bottom-ButtonHeight))
	{
		cySource=ClientRect.bottom-ButtonHeight-rect->top;
		if(cySource<=0) 
		{
			(*rectflag)=0;
			return ;
		}
	}

	if((*rectflag)==1)
	{

		BitBlt(hMemory4,0,0,cxSource,cySource,hMem,rect->left-10,rect->top,SRCCOPY);
		BitBlt(hMemory4,0,0,cxSource,cySource,hMemory2,0,0,SRCPAINT);
		BitBlt(hMemory4,0,0,cxSource,cySource,hMemBitmap[52],0,0,SRCAND);
		if(IDTIMER<3||IDTIMER>7)
		{
			if(rect->top<40)
			{
				if((cySource-(40-rect->top))<0)
				{
					(*rectflag)++;
					return ;
				}
				BitBlt(hdc,rect->left-10,40,cxSource,cySource-(40-rect->top),hMemory4,0,cySource-(40-rect->top),SRCCOPY);
			}
			else
			BitBlt(hdc,rect->left-10,rect->top,cxSource,cySource,hMemory4,0,0,SRCCOPY);
		}
		else
			BitBlt(hdc,rect->left-10,rect->top,cxSource,cySource,hMemory4,0,0,SRCCOPY);
		(*rectflag)++;

	}
	else if((*rectflag)==2)
	{
	
		BitBlt(hMemory4,0,0,cxSource,cySource,hMem,rect->left-10,rect->top,SRCCOPY);
		BitBlt(hMemory4,0,0,cxSource,cySource,hMemory5,0,0,SRCPAINT);
		BitBlt(hMemory4,0,0,cxSource,cySource,hMemBitmap[54],0,0,SRCAND);

		if(IDTIMER<3||IDTIMER>7)
		{
			if(rect->top<40)
			{
				if((cySource-(40-rect->top))<0) 
				{
					(*rectflag)++;
					return ;
				}
				BitBlt(hdc,rect->left-10,40,cxSource,cySource-(40-rect->top),hMemory4,0,cySource-(40-rect->top),SRCCOPY);
			}
			else
			BitBlt(hdc,rect->left-10,rect->top,cxSource,cySource,hMemory4,0,0,SRCCOPY);
		}
		else
			BitBlt(hdc,rect->left-10,rect->top,cxSource,cySource,hMemory4,0,0,SRCCOPY);

		(*rectflag)++;
		
	}
	
	else if((*rectflag)==3)
	{
		if(IDTIMER<3||IDTIMER>7)
		{
			if(rect->top<40)
			{
				if((cySource-(40-rect->top))<0)
				{
					rect->top=600;
	
					Furect->top=600;	
					Furect->bottom=rect->bottom;

					(*rectflag)=0;

					SetTimer(hwnd,IDTIMER,Timer,NULL);
					return ;
				}
				StretchBlt(hdc,rect->left-10,40,cxSource,cySource-(40-rect->top),hMem,rect->left-10,40,cxSource,cySource-(40-rect->top),SRCCOPY);
			}
			else
				StretchBlt(hdc,rect->left-10,rect->top,cxSource,cySource,hMem,rect->left-10,rect->top,cxSource,cySource,SRCCOPY);
		}
		else
			StretchBlt(hdc,rect->left-10,rect->top,cxSource,cySource,hMem,rect->left-10,rect->top,cxSource,cySource,SRCCOPY);
	   
		rect->top=600;
	
		Furect->top=600;	
		Furect->bottom=rect->bottom;

		(*rectflag)=0;

		SetTimer(hwnd,IDTIMER,Timer,NULL);
	}

}



void GetRandNumber(int Timer[10],int RandNum,int ArrayNo)
{
	int i,j=1;
	srand( (unsigned)time( NULL ) );
	for(i=0;i<10;i++)
	{
		j=(rand())%RandNum;
		if(j==0)
		{
			while(1)
			{
				j=(rand())%RandNum;
				if(j>0) break;
			};
		}
		if(ArrayNo>10)
		   	Timer[i]=j;
		else if(ArrayNo==i)
		{
			Timer[i]=j;
			return ;
		}
	}
}

⌨️ 快捷键说明

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