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

📄 score.cpp

📁  ?跳舞机的源代码 自己修改一下 编译没有问题
💻 CPP
字号:
//score.cpp
#include<windows.h>
#include<ddraw.h>
#pragma comment(lib,"ddraw")
#pragma comment(lib,"winmm")
extern WPARAM wParam;
extern LPDIRECTDRAWSURFACE lpDDSBack,lpDDHelp,lpDDMum,lpDDHit,lpDDStart,lpDDSelect;
extern bool help;
extern int hit,score;
int framemum=0,framehhy1=0,framehhy2=0,framehhy3=0,framesit=0;//framehhy1个位,framehhy2十位,framehhy3百位
int frames1=0,frames2=0,frames3=0,frames4=0,frames5=0;
int framehit=0;

void HELP()
{
	static RECT rect;
	::SetRect(&rect,0,0,324,240);
	if(help)
	{
		lpDDSBack->BltFast(600,400,lpDDHelp,&rect,DDBLTFAST_WAIT);
	}
}

int AdjustMum(int hit)
{
	static int framehhy;
	switch(hit)
	{
	case 0:
		framehhy=9;break;
	case 1:
		framehhy=8;break;
	case 2:
		framehhy=7;break;
	case 3:
		framehhy=6;break;
	case 4:
		framehhy=5;break;
	case 5:
		framehhy=4;break;
	case 6:
		framehhy=3;break;
	case 7:
		framehhy=2;break;
	case 8:
		framehhy=1;break;
	case 9:
		framehhy=0;break;
	}//end of switch
	return framehhy;
}

void MumSit(int framehhy0,int framesit)  
{
	static DWORD Time=timeGetTime();
	static RECT rect;
	if(timeGetTime()-Time>120)
	{
		framemum++;
		if(framemum>3)framemum=0;
		rect.top=0+framehhy0*50;rect.left=0+framemum*50;rect.right=50+framemum*50;rect.bottom=50+framehhy0*50;
		lpDDSBack->BltFast(950-framesit*50,250,lpDDMum,&rect,DDBLTFAST_WAIT|DDBLTFAST_SRCCOLORKEY);
		Time=timeGetTime();
	}
	else
	{
		lpDDSBack->BltFast(950-framesit*50,250,lpDDMum,&rect,DDBLTFAST_WAIT|DDBLTFAST_SRCCOLORKEY);
	}
}

void MumSit1(int framehhy0,int framesit)  
{
	static DWORD Time=timeGetTime();
	static RECT rect;
	if(timeGetTime()-Time>120)
	{
		framemum++;
		if(framemum>3)framemum=0;
		rect.top=0+framehhy0*50;rect.left=0+framemum*50;rect.right=50+framemum*50;rect.bottom=50+framehhy0*50;
		lpDDSBack->BltFast(950-framesit*50,250,lpDDMum,&rect,DDBLTFAST_WAIT|DDBLTFAST_SRCCOLORKEY);
		Time=timeGetTime();
	}
	else
	{
		lpDDSBack->BltFast(950-framesit*50,250,lpDDMum,&rect,DDBLTFAST_WAIT|DDBLTFAST_SRCCOLORKEY);
	}
}

void MumSit2(int framehhy0,int framesit)  
{
	static DWORD Time=timeGetTime();
	static RECT rect;
	if(timeGetTime()-Time>120)
	{
		framemum++;
		if(framemum>3)framemum=0;
		rect.top=0+framehhy0*50;rect.left=0+framemum*50;rect.right=50+framemum*50;rect.bottom=50+framehhy0*50;
		lpDDSBack->BltFast(950-framesit*50,250,lpDDMum,&rect,DDBLTFAST_WAIT|DDBLTFAST_SRCCOLORKEY);
		Time=timeGetTime();
	}
	else
	{
		lpDDSBack->BltFast(950-framesit*50,250,lpDDMum,&rect,DDBLTFAST_WAIT|DDBLTFAST_SRCCOLORKEY);
	}
}

void SH()//显示‘HIT’‘SCORE’
{
	static DWORD Time=timeGetTime();
	static RECT rect,rect1;
	if(timeGetTime()-Time>500)
	{
		framehit++;
		if(framehit>1)framehit=0;
		rect.top=0;rect.left=0+framehit*125;rect.right=125+framehit*125;rect.bottom=58;
		rect1.top=59;rect1.left=0+framehit*125;rect1.right=125+framehit*125;rect1.bottom=115;
		lpDDSBack->BltFast(710,250,lpDDHit,&rect,DDBLTFAST_WAIT|DDBLTFAST_SRCCOLORKEY);
		lpDDSBack->BltFast(710,170,lpDDHit,&rect1,DDBLTFAST_WAIT|DDBLTFAST_SRCCOLORKEY);
		Time=timeGetTime();
	}
	else
	{
		lpDDSBack->BltFast(710,250,lpDDHit,&rect,DDBLTFAST_WAIT|DDBLTFAST_SRCCOLORKEY);
		lpDDSBack->BltFast(710,170,lpDDHit,&rect1,DDBLTFAST_WAIT|DDBLTFAST_SRCCOLORKEY);
	}
}
	

void ShowHit()
{
	SH();
	framehhy1=AdjustMum(hit%10);//个位
	MumSit(framehhy1,0);

    framehhy2=AdjustMum(((hit-hit%10)/10)%10);//十位
	MumSit1(framehhy2,1);

	framehhy3=AdjustMum((hit-((hit-hit%10)/10)%10*10-hit%10)/100);//百位
	MumSit2(framehhy3,2);
}

void ShowS(int frames0,int framesit)//显示分数的每一位的通用函数
{
	static RECT rect;
	rect.top=0+frames0*50;rect.left=0;rect.right=50;rect.bottom=50+frames0*50;
	lpDDSBack->BltFast(950-framesit*25,170,lpDDMum,&rect,DDBLTFAST_WAIT|DDBLTFAST_SRCCOLORKEY);
}

void ShowScore()//显示分数
{
	frames1=AdjustMum(score%10);
	ShowS(frames1,0);
	frames2=AdjustMum(((score-frames1)/10)%10);
	ShowS(frames2,1);
    frames3=AdjustMum(((score-frames1-frames2*10)/100)%10);
	ShowS(frames3,2);
	frames4=AdjustMum(((score-frames1-frames2*10-frames3*100)/1000)%10);
	ShowS(frames4,3);
    frames5=AdjustMum((score-frames1-frames2*10-frames3*100-frames4*1000)/10000);
	ShowS(frames5,4);
}

void Start()//“按SPACE开始游戏
{
	static RECT rect;
	::SetRect(&rect,0,0,340,31);
	static DWORD oldTime=timeGetTime();
	if(timeGetTime()-oldTime>1000)//必须用大于
	{
		lpDDSBack->BltFast(363,578,lpDDStart,&rect,DDBLTFAST_WAIT|DDBLTFAST_SRCCOLORKEY);
	}
	if(timeGetTime()-oldTime>2000)//必须用大于
	{
		oldTime=timeGetTime();
	}
}

void Select(int frameselect)//难度选择
{
	static RECT rect,rect1;
	::SetRect(&rect1,380,450,680,600);
	rect.top=0+frameselect*100;rect.left=0;rect.right=194;rect.bottom=100+frameselect*100;
	lpDDSBack->Blt(&rect1,lpDDSelect,&rect,DDBLTFAST_WAIT|DDBLT_KEYSRC,NULL);
}

⌨️ 快捷键说明

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