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

📄 bullhero.cpp

📁 Brew平台的手机游戏代码. 斗牛士.韩国开发的经典游戏.
💻 CPP
📖 第 1 页 / 共 5 页
字号:
//===========================================================================================
// (林)葛府家橇飘 
// 累己磊 : 辫肯荐
// 汲疙 : 牢屈惶扁 MainApp
// 颇老 : cpp 颇老 
//===========================================================================================
#include "MainApp.h"

#include "bullstr_res.h"
#include "bullimg_res.h"

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 檬扁 绢敲 积己  static 窃荐甸 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
extern "C" 
int AEEClsCreateInstance(AEECLSID clsID, IShell* pIShell, IModule* pIModule, void** ppApplet)
{
	AEEApplet* pMe = 0;
	*ppApplet = NULL;

	if(clsID == AEECLSID_COW)
	{	
		// 檬扁积己 窜拌  
		if(!AEEApplet_New(sizeof(MainApp), clsID, pIShell, pIModule, (IApplet**)ppApplet,(AEEHANDLER)MainApp::HandleEvent,
			(PFNFREEAPPDATA)MainApp::FreeAppData))
			return EFAILED;

		pMe = (AEEApplet*)(*ppApplet);

		if(!pMe)
			return EFAILED;

		// 皋葛府且寸 棺 函荐蔼 檬扁拳 汲沥 
		if(!MainApp::InitAppData((MainApp *)pMe))
			return EFAILED;

		return SUCCESS;
	}
	return EFAILED;
}


void MainApp::FreeAppData(MainApp *pMe)
{
	pMe->P_FreeEnd();
}

boolean MainApp::HandleEvent(MainApp *pMe, AEEEvent eCode, uint16 wParam , uint32 dwParam) 
{
	return pMe->P_Event(eCode, wParam, dwParam); 
}

boolean MainApp::InitAppData(MainApp *pMe)
{
	return pMe->P_Init();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 檬扁拳 窃荐
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
boolean MainApp::P_Init()
{
	int i;
	AEEDeviceInfo di;  // 勤靛迄 叼官捞胶 沥焊 

	ISHELL_GetDeviceInfo(m_pIShell, &di );
	Width = di.cxScreen;   // 胶农赴 承捞 
	Height = di.cyScreen;  // 胶农赴 臭捞 
	Height = 292;
	
	hWidth = Width>>1;
	hHeight = Height>>1;
	m_pRam = di.dwRAM;	

	//-----捞固瘤 概聪廉 努贰胶 积己----------------------
	CImg = NULL;
	CImg = new ImageManager();
	//檬扁拳
	CImg->Init_CImg(m_pIShell, m_pIDisplay);
	//----------------------------------------------------

	//-------弊贰侨 牢磐其捞胶 积己-----------------------
	if(ISHELL_CreateInstance(m_pIShell, AEECLSID_GRAPHICS, (void **)&m_pIgraphics) != SUCCESS)
		return FALSE;
	//----------------------------------------------------

	//-------赛 牢磐其捞胶 积己---------------------------
	if(ISHELL_CreateInstance(m_pIShell, AEECLSID_HEAP, (void **)&m_pHeap) != SUCCESS)
		return FALSE;
	//----------------------------------------------------

	//===========================File 积己==================================================
	if(ISHELL_CreateInstance(m_pIShell, AEECLSID_FILEMGR,(void **)&m_pIfilemgr) != SUCCESS)
	    return FALSE;
	
	GameState = ST_GAMETEMP;

	if( !CheckFile() )
	{
		GameState = ST_ERDIS;
		SubState = 0;
		aniCnt[0] = 0;
		
		return TRUE;
	}

/*	
	if( !CheckMem() )
	{
		GameState = ST_ERDIS;
		SubState = 1;
		aniCnt[0] = 0;
		
		return TRUE;
	}
*/	

	if((IFILEMGR_Test(m_pIfilemgr,"gamecfg.dat" ) )== EFAILED)
	{
		// 颇老阑 货肺 积己窃 
		if((m_pIfile = IFILEMGR_OpenFile(m_pIfilemgr, "gamecfg.dat", _OFM_CREATE)) == NULL)
		{
			IFILEMGR_Release(m_pIfilemgr);
			m_pIfilemgr = NULL;
			return FALSE;
		}	
		
		m_sound = 1;
		
		P_DataInit();

		IFILE_Write( m_pIfile, &m_horn, sizeof(int) );				//家 辉
		IFILE_Write( m_pIfile, &m_bullear, sizeof(int) );			//家 蓖
		for( i = 0 ; i < 8 ; ++i)
			IFILE_Write( m_pIfile, &EndingCnt[i], sizeof(int) );	//浚爹
		IFILE_Write( m_pIfile, &viewEnding, sizeof(int) );			//浚爹轰 蜡公
		for( i = 0 ; i < 10 ; ++i)
			IFILE_Write( m_pIfile, &mataskill[i], sizeof(int) );	// 胶懦
		for( i = 0 ; i < 3 ; ++i)
			IFILE_Write( m_pIfile, &Quest[i], sizeof(byte) );		// 涅胶飘
		for( i = 0 ; i < 3 ; ++i)
			IFILE_Write( m_pIfile, &QuestEnd[i], sizeof(byte) );	// 涅胶飘 浚靛
		for( i = 0 ; i < 4 ; ++i)
			IFILE_Write( m_pIfile, &w_Item[i], sizeof(int) );		// 馒侩 酒捞袍
		for( i = 0 ; i < 8 ; ++i)
			IFILE_Write( m_pIfile, &h_Item[i], sizeof(int) );		// 焊蜡 捞捞袍
		
		IFILE_Write( m_pIfile, &t_money, sizeof(long) );			// 惑陛 
		IFILE_Write( m_pIfile, &talkCnt, sizeof(byte) );			// 措拳 辆幅 魄窜 墨款飘 
		IFILE_Write( m_pIfile, &m_sound, sizeof(int8) );			// 荤款靛 汲沥
		IFILE_Write( m_pIfile, &m_speed, sizeof(int8) );			// 胶乔靛 汲沥 
		
		IFILE_Write( m_pIfile, &WarMoney, sizeof(long) );			// 公茄措傈 痢荐	
		IFILE_Write( m_pIfile, &proloview, sizeof(int) );			// 柳青茄 霸烙 冉荐
	}
	else
	{
		if( (m_pIfile = IFILEMGR_OpenFile(m_pIfilemgr, "gamecfg.dat", _OFM_READWRITE ) ) == NULL)
		{ // 凯扁 角菩矫 府畔 
			IFILEMGR_Release(m_pIfilemgr);
	    	m_pIfilemgr = NULL;
			return FALSE;
		}

		IFILE_Read( m_pIfile, &m_horn, sizeof(int) );			//家 辉
		IFILE_Read( m_pIfile, &m_bullear, sizeof(int) );			//家 蓖
		for( i = 0 ; i < 8 ; ++i)
			IFILE_Read( m_pIfile, &EndingCnt[i], sizeof(int) );	//浚爹
		IFILE_Read( m_pIfile, &viewEnding, sizeof(int) );		//浚爹轰 蜡公
		for( i = 0 ; i < 10 ; ++i)
			IFILE_Read( m_pIfile, &mataskill[i], sizeof(int) );	// 胶懦
		for( i = 0 ; i < 3 ; ++i)
			IFILE_Read( m_pIfile, &Quest[i], sizeof(byte) );		// 涅胶飘
		for( i = 0 ; i < 3 ; ++i)
			IFILE_Read( m_pIfile, &QuestEnd[i], sizeof(byte) );	// 涅胶飘 浚靛
		for( i = 0 ; i < 4 ; ++i)
			IFILE_Read( m_pIfile, &w_Item[i], sizeof(int) );		// 馒侩 酒捞袍
		for( i = 0 ; i < 8 ; ++i)
			IFILE_Read( m_pIfile, &h_Item[i], sizeof(int) );		// 焊蜡 捞捞袍
		
		IFILE_Read( m_pIfile, &t_money, sizeof(long) );			// 惑陛 
		IFILE_Read( m_pIfile, &talkCnt, sizeof(byte) );			// 措拳 辆幅 魄窜 墨款飘 
		IFILE_Read( m_pIfile, &m_sound, sizeof(int8) );			// 荤款靛 汲沥
		IFILE_Read( m_pIfile, &m_speed, sizeof(int8) );			// 胶乔靛 汲沥 
		
		IFILE_Read( m_pIfile, &WarMoney, sizeof(long) );			// 公茄措傈 痢荐*/
		IFILE_Read( m_pIfile, &proloview, sizeof(int) );			// 柳青茄 霸烙 冉荐
	}

	P_ReleaseFile();

	m_TimeInterval = 150 + 60*m_speed;

	//俺烙单捞磐 檬扁拳

	sounddie = 0;

	endgame = 0;

	talk_count = 0;

	InitRand();

	return TRUE;
}


void MainApp::P_SaveData()
{
	int i;

	if((m_pIfile = IFILEMGR_OpenFile(m_pIfilemgr, "gamecfg.dat", _OFM_READWRITE)) == NULL)
	{	
		IFILEMGR_Release(m_pIfilemgr);
	    m_pIfilemgr = NULL;
		return;
	}

	IFILE_Write( m_pIfile, &m_horn, sizeof(int) );				//家 辉
	IFILE_Write( m_pIfile, &m_bullear, sizeof(int) );			//家 蓖
	for( i = 0 ; i < 8 ; ++i)
		IFILE_Write( m_pIfile, &EndingCnt[i], sizeof(int) );	//浚爹
	IFILE_Write( m_pIfile, &viewEnding, sizeof(int) );			//浚爹轰 蜡公
	for( i = 0 ; i < 10 ; ++i)
		IFILE_Write( m_pIfile, &mataskill[i], sizeof(int) );	// 胶懦
	for( i = 0 ; i < 3 ; ++i)
		IFILE_Write( m_pIfile, &Quest[i], sizeof(byte) );		// 涅胶飘
	for( i = 0 ; i < 3 ; ++i)
		IFILE_Write( m_pIfile, &QuestEnd[i], sizeof(byte) );	// 涅胶飘 浚靛
	for( i = 0 ; i < 4 ; ++i)
		IFILE_Write( m_pIfile, &w_Item[i], sizeof(int) );		// 馒侩 酒捞袍
	for( i = 0 ; i < 8 ; ++i)
		IFILE_Write( m_pIfile, &h_Item[i], sizeof(int) );		// 焊蜡 捞捞袍
	
	IFILE_Write( m_pIfile, &t_money, sizeof(long) );			// 惑陛 
	IFILE_Write( m_pIfile, &talkCnt, sizeof(byte) );			// 措拳 辆幅 魄窜 墨款飘 
	IFILE_Write( m_pIfile, &m_sound, sizeof(int8) );			// 荤款靛 汲沥
	IFILE_Write( m_pIfile, &m_speed, sizeof(int8) );			// 胶乔靛 汲沥 
	
	IFILE_Write( m_pIfile, &WarMoney, sizeof(long) );			// 公茄措傈 痢荐
	IFILE_Write( m_pIfile, &proloview, sizeof(int) );			// 柳青茄 霸烙 冉荐

	P_ReleaseFile();
}

// 货肺 矫累矫 单捞磐 檬扁拳 何盒 - 胶懦, 酒捞袍, 浚爹 墨款飘 殿
void MainApp::P_DataInit()
{
	int i;
	// 胶懦 檬扁拳
	for( i = 0; i < 10 ; i++) 
		mataskill[i] = 0;

	mataskill[1] = 1;
	mataskill[2] = 1;
	mataskill[3] = 1;

	// 辉, 蓖, 霸烙 葛靛 檬扁拳
	m_horn = m_bullear = Warmode = 0;

	// 涅胶飘 檬扁拳
	for( i = 0; i < 3 ; i++)
	{
		Quest[i] = 0;
		QuestEnd[i] = 0;
	}

	// 馒侩酒捞袍 檬扁拳
	for( i = 0; i < 4 ; i++)
		w_Item[i] = 0;

	// 厚馒侩酒捞袍 , 浚爹 墨款飘 檬扁拳
	for( i = 0; i < 8 ; i++)
	{
		h_Item[i] = EndingCnt[i] = 0;
	}

	// 浚爹 蜡公 檬扁拳, 霸烙 墨款飘 檬扁拳
	viewEnding = 0;

	talkCnt = 0;
	
	// 霸烙赣聪 檬扁拳
	t_money = a_money = 0;

	t_money = 100000000;

	proloview = 0;
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void MainApp::P_ReleaseFile()
{
	if(m_pIfile)
	{
		IFILE_Release(m_pIfile);
		m_pIfile = NULL;
	}
}


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 辆丰 弥辆 秦力 窃荐
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void MainApp::P_FreeEnd()
{
	//-----荤款靛 努饭胶 秦力---------------------------- 
	if( m_pBrewMedia != NULL )
	{
		m_pBrewMedia->Stop();
		m_pBrewMedia->Release();
		delete m_pBrewMedia;
		m_pBrewMedia = NULL;
	}
	//---------------------------------------------------

	//-----捞固瘤 概聪廉 努贰胶 秦力---------------------
	CImg->FreeAllImg();
	delete CImg;
	CImg = NULL;
	//---------------------------------------------------

	//------弊贰侨 牢磐其捞胶 秦力-----------------------
	if(m_pIgraphics)
	{
		IGRAPHICS_Release( m_pIgraphics );
		m_pIgraphics = NULL;
	}
	//---------------------------------------------------

	//-----赛 牢磐其捞胶 @@------------------------------
	if(m_pHeap)
	{
		IHEAP_Release( m_pHeap );
		m_pHeap = NULL;
	}
	//---------------------------------------------------

	P_ReleaseFile();

	if(m_pIfilemgr)
	{
		IFILEMGR_Release(m_pIfilemgr);
		m_pIfilemgr = NULL;
	}
}

boolean MainApp::P_Event( AEEEvent eCode, uint16 wParam, uint32 dwParam )
{
	switch (eCode) 
	{	
		case EVT_APP_SUSPEND:    // 霸烙吝俊 傈拳啊 吭阑锭 
			ISHELL_CancelTimer( m_pIShell, NULL, this );
		   
			if(m_pBrewMedia)
			{
				if(m_pBrewMedia->m_bPlaying)
				{
					m_bSoundReplay = FALSE;			

//					if( m_SoundResId == RS_00 || m_SoundResId == RS_01 || m_SoundResId == RS_18 )
//						m_bSoundReplay = TRUE;
				}
				
				m_pBrewMedia->Stop();
				m_pBrewMedia->Release();			
				delete m_pBrewMedia;
				m_pBrewMedia = NULL;
		   }
		   m_bSoundSleep = TRUE;

		  return TRUE;

	   case EVT_APP_RESUME:	 
			if( GameState == ST_S2GAME && SubState == 0 )
			{
				m_sec = GET_TIMEMS()/1000;
				m_mtime[4] = m_sec - m_mtime[4];  
				m_mtime[3] += m_mtime[4];
			}

⌨️ 快捷键说明

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