gengine.cpp

来自「仿游戏 Diablo 的源代码」· C++ 代码 · 共 74 行

CPP
74
字号
#include "..\common.h"
#include "gl.h"
#include "gengine.h"

//#define _OFFDDRAW	//关闭DirectDraw
Hero *warrior;

int InitGraphicEngine( DWORD w, DWORD h, DWORD colordepth )
{
	CheckCPU();
#ifdef _DEBUG
//	if( cpu.mmx )
//		OutDebugString( "mmx" );
#endif

	screenInfo.width = w;
	screenInfo.height = h;
	screenInfo.colorDepth = colordepth;
#ifndef	_OFFDDRAW
	// 初始化DirectDraw
	if( InitDDraw() != 0 )
		return -1;
#else
	backScreen = CreateBitmapEx( w, h, colordepth );
#endif
#ifndef _OFFDDRAW
	if( InitDInput( hInst ) != 0 ){
		return -1;
	}
	// 初始化文字显示例程
	if( InitHanzi( Hanzi::SmallFont ) != 0 ){
		MsgBox( "InitHanzi failed." );
		return -1;
	}
	// 初始化光影效果, call InitDDraw() first !!!
	if( InitBrighter() != 0 ){
		MsgBox( "InitBrighter failed" );
		return -1;
	}
	// 初始化简单精灵显示例程
	if( InitSprite() != 0 ){
		MsgBox( "InitSprite failed" );
		return -1;
	}

	if( scene.InitScene( 0, 24, 24 ) != 0 ){
		MsgBox( "InitScene failed" );
		return -1;
	}
#endif

//	initRleBitmap( );
//	InitAni();
	MouseOn();
	warrior = new Hero( 24, 24 );
	warrior->LoadPicture();
	if( warrior->LoginMaze() != 0 )
		return -1;
	OutDebugString( "init engine end" );

	return 0;
}

int ExitGraphicEngine( void )
{
#ifndef _OFFDDRAW
	DestroyDDraw();
#endif
	DestroyDInput();

	return 0;
}

⌨️ 快捷键说明

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