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

📄 accident.cpp

📁 一个简单的rpg游戏
💻 CPP
字号:
#include "Headers.h"
#include "resource.h"
#include "DriverDialog.h"
#include "MAIN.h"



/*
	0:	place.bmp
	1:	city.bmp
	2:	room.bmp
*/



void MAIN::ChangeMap(OBJECT *obj,long from,long to,long get)
{
	ChangeAccRes(obj,from,to,game.accmem,game.acclength);

	obj->ReGet();
	if(get)
		obj->GetAppend(hit,MAX_HIT,acc,MAX_ACC);
	else
		obj->InitDlg(game.dlgmem,game.dlglength);


}



void MAIN::Accident(long id)
{
	static long f,t,n;

	switch(map[0]->res.number)
	{
	case 10000:
		switch(id)
		{
		case 1:
			//from 0 to 1
			FadeOut(primsurf,backsurf,&game.screen,lpdd);

			f=10000;t=10001;
			ChangeMap(map[0],f,t,1);

			f=20000;t=20001;
			ChangeMap(sub[0],f,t);

			f=30000;t=30001;
			for(n=0;n<MAX_NPC;n++)
			{
				ChangeMap(npc[n],f+n*1000000,t+n*1000000);
				npc[n]->running=0;
			}

			Draw();
			FadeIn(primsurf,backsurf,&game.screen,lpdd);
			break;
		}
		break;

	case 10001:
		switch(id)
		{
		case 1:
			//from 1 to 0
			FadeOut(primsurf,backsurf,&game.screen,lpdd);

			f=10001;t=10000;
			ChangeMap(map[0],f,t,1);

			f=20001;t=20000;
			ChangeMap(sub[0],f,t);
			
			f=30001;t=30000;
			for(n=0;n<MAX_NPC;n++)
			{
				ChangeMap(npc[n],f+n*1000000,t+n*1000000);
				npc[n]->running=0;
			}

			Draw();
			FadeIn(primsurf,backsurf,&game.screen,lpdd);
			break;

		case 2:
			//from 1 to 2
			FadeOut(primsurf,backsurf,&game.screen,lpdd);

			f=10001;t=10002;
			ChangeMap(map[0],f,t,1);

			f=20001;t=20002;
			ChangeMap(sub[0],f,t);

			f=30001;t=30002;
			for(n=0;n<MAX_NPC;n++)
			{
				ChangeMap(npc[n],f+n*1000000,t+n*1000000);
				npc[n]->running=0;
			}

			Draw();
			FadeIn(primsurf,backsurf,&game.screen,lpdd);

			if(game.process[2]==1)
			{
				game.process[2]==2;

				boss[0]->Get();
				boss[0]->InitDlg(game.dlgmem,game.dlglength);

				npc[0]->direction=4;
				boss[0]->direction=6;
				boss[0]->res2.x=npc[0]->res2.x-32;
				boss[0]->res2.y=npc[0]->res2.y;

				Dialog(boss[0]);

				sub[0]->direction=6;
				while(sub[0]->res2.x<=boss[0]->res2.x)
				{
					Draw();

					primsurf->Flip( 0,DDFLIP_WAIT );

					sub[0]->step=!sub[0]->step;
					sub[0]->res2.x+=game.step;
				}

				sub[0]->res2.x=boss[0]->res2.x;

				sub[0]->direction=8;
				while(sub[0]->res2.y>=boss[0]->res2.y)
				{
					Draw();

					primsurf->Flip( 0,DDFLIP_WAIT );

					sub[0]->step=!sub[0]->step;
					sub[0]->res2.y-=game.step;
				}

				FadeOut(primsurf,backsurf,&game.screen,lpdd);

				Fight(sub[0],boss[0]);

				//over
				boss[0]->sfc->Release();
				boss[0]->sfc=0;

				sub[0]->direction=6;
				npc[0]->direction=4;

				sub[0]->res2.x=npc[0]->res2.x-32;
				sub[0]->res2.y=npc[0]->res2.y;

				Dialog(sub[0]);

				FadeOut(primsurf,backsurf,&game.screen,lpdd);

				lpdd->FlipToGDISurface();
				MessageBox("请看 README.TXT 。");
				PostMessage( WM_CLOSE );
			}
			break;

		case 3:
			if(game.process[1]==1)
			{
				game.process[1]=2;
				game.process[2]=1;

				boss[0]->Get();

				boss[0]->direction=6;
				boss[0]->res2.y=352;
				boss[0]->res2.x=-32;
				while(boss[0]->res2.x<=448)
				{
					Draw();

					primsurf->Flip( 0,DDFLIP_WAIT );

					boss[0]->step=!boss[0]->step;
					boss[0]->res2.x+=game.step;
				}

				boss[0]->direction=8;
				boss[0]->res2.x=448;
				while(boss[0]->res2.y>=320)
				{
					Draw();

					primsurf->Flip( 0,DDFLIP_WAIT );

					boss[0]->step=!boss[0]->step;
					boss[0]->res2.y-=game.step;
				}

				boss[0]->res2.x=-32;
				boss[0]->res2.y=-32;

				Dialog(sub[0]);

				boss[0]->sfc->Release();
				boss[0]->sfc=0;
			}
			break;
		}
		break;

	case 10002:
		switch(id)
		{
		case 1:
			//from 2 to 1
			FadeOut(primsurf,backsurf,&game.screen,lpdd);

			f=10002;t=10001;
			ChangeMap(map[0],f,t,1);

			f=20002;t=20001;
			ChangeMap(sub[0],f,t);
			
			f=30002;t=30001;
			for(n=0;n<MAX_NPC;n++)
			{
				ChangeMap(npc[n],f+n*1000000,t+n*1000000);
				npc[n]->running=0;
			}

			Draw();
			FadeIn(primsurf,backsurf,&game.screen,lpdd);
			break;
		}
		break;
	}

}



void MAIN::Fight(OBJECT *left,OBJECT *right)
{
}

⌨️ 快捷键说明

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