?? engine.cpp
字號:
// Engine.cpp: implementation of the Engine class.
//
//////////////////////////////////////////////////////////////////////
#include "Engine.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Engine::Engine()
{
m_lpDirectDraw=NULL;
m_lpMap=NULL;
}
Engine::~Engine()
{
}
bool Engine::Initialize(HWND hWnd)
{
m_lpDirectDraw=new DirectDraw;
if (!m_lpDirectDraw->Create(hWnd)) return false;
m_lpMap=new Map;
m_lpMap->LoadMapFile("default.map");
m_lpMap->LoadMapCGL("default.cgl",m_lpDirectDraw->m_bColorMode);
m_lpMap->CreateCharactar(m_lpDirectDraw->m_bColorMode);
m_lpImageCursor=new ImageList;
m_lpImageCursor->Create("system.cgl",m_lpDirectDraw->m_bColorMode,0);
return true;
}
void Engine::UpdateFrame()
{
POINT cpt;
GetCursorPos(&cpt);
m_lpMap->m_Cursor=cpt;
WORD *lpBitmap=NULL;
long lPitch;
//bool debug=true;
bool debug=false;
m_lpDirectDraw->CleanDDSBackbuffer(0);
if (debug)
{
lpBitmap = new WORD [DisplayMode_Width*DisplayMode_Height];
lPitch=DisplayMode_Width;
}
else m_lpDirectDraw->Lock(lpBitmap,lPitch);
//Draw Code here
m_lpMap->DrawMapLayer(m_lpMap->m_lpCharactar->m_ix-64*6-32,-32*2+m_lpMap->m_lpCharactar->m_iy,lpBitmap,lPitch);
POINT pt;
GetCursorPos(&pt);
m_lpImageCursor->Draw(0,pt.x,pt.y,lpBitmap,lPitch);
if (debug) delete lpBitmap;
else m_lpDirectDraw->UnLock();
//m_lpDirectDraw->Flip();
HDC dc;char temp[256];
m_lpDirectDraw->m_lpDDSBackbuffer->GetDC(&dc);
//SetBkMode(dc,TRANSPARENT);
m_lpDirectDraw->Dump(temp);
TextOut(dc,0,0,temp,strlen(temp));
sprintf(temp,"%d",m_lpMap->m_lpCharactar->m_iLookAroundTimeCount);
TextOut(dc,100, 0, temp, strlen(temp));
sprintf(temp,"%d %d",m_lpMap->m_Cursor.x,m_lpMap->m_Cursor.y);
TextOut(dc,200, 0, temp, strlen(temp));
int x,y;
x=m_lpMap->m_Cursor.x;
y=m_lpMap->m_Cursor.y;
m_lpMap->ConvertPosition(x,y);
sprintf(temp,"%d %d",x,y);
TextOut(dc,0, 60, temp, strlen(temp));
m_lpMap->m_lpCharactar->Dump(temp);
RECT rc;
rc.left=0;rc.right=400;
rc.top=20;rc.bottom=200+40;
DrawText(dc,temp,strlen(temp),&rc,0);
//TextOut(dc,0, 20, temp, strlen(temp));
m_lpDirectDraw->m_lpDDSBackbuffer->ReleaseDC(dc);
//for(int i=0;i<10000000;i++);
//-------------------------//
m_lpDirectDraw->Flip();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -