?? s60testengine.cpp
字號:
#include <aknnotewrappers.h>
#include <e32def.h>
#include "s60testdocument.h"
#include "s60testengine.h"
#include "s60test.pan"
#include "step6.rsg"
CS60TestEngine *CS60TestEngine::NewLC(CS60TestDocument *aDoc)
{
CS60TestEngine *self=new(ELeave) CS60TestEngine(aDoc);
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
CS60TestEngine *CS60TestEngine::NewL(CS60TestDocument *aDoc)
{
CS60TestEngine *self=CS60TestEngine::NewLC(aDoc);
CleanupStack::Pop(self);
return self;
}
void CS60TestEngine::ConstructL()
{
CTimer::ConstructL();
CActiveScheduler::Add(this);
After(iInterval);
iState=ERunning;
}
void CS60TestEngine::KeyLeft()
{
iDoc->MoveBlock(iDoc->iBlockPos-TPoint(1, 0));
}
void CS60TestEngine::KeyRight()
{
iDoc->MoveBlock(iDoc->iBlockPos+TPoint(1, 0));
}
void CS60TestEngine::KeyDrop()
{
while (iDoc->MoveBlock(iDoc->iBlockPos+TPoint(0, 1)))
;
}
void CS60TestEngine::KeyRotate(int dir)
{
iDoc->RotateBlock(dir);
}
void CS60TestEngine::Reset()
{
if (iState==ERunning)
Cancel();
iPauseRef=0;
if (iTechPauseRef==0)
{
After(iInterval);
iState=ERunning;
} else
{
iPauseTime.HomeTime();
iBeginTime.HomeTime();
iState=EPaused;
}
}
void CS60TestEngine::DoPause()
{
__ASSERT_ALWAYS(iPauseRef>=0 && iTechPauseRef>=0, Panic(ES60TestAssert));
if (iPauseRef==0 && iTechPauseRef==0)
{
if (iState==EPaused)
{
int ms=iPauseTime.MicroSecondsFrom(iBeginTime).Int64().GetTInt();
if (ms<0 || ms>iInterval)
ms=0;
iState=ERunning;
After(iInterval-ms);
}
} else
{
if (iState==ERunning)
{
iState=EPaused;
iPauseTime.HomeTime();
Cancel();
}
}
}
void CS60TestEngine::RunL()
{
if (!iDoc->MoveBlock(iDoc->iBlockPos+TPoint(0, 1)))
{
if (!iDoc->FixBlock())
{
// Game over
TBuf<64> message;
CEikonEnv::Static()->ReadResource(message, R_NOTE_GAME_OVER);
CAknInformationNote *informationNote=new(ELeave) CAknInformationNote;
informationNote->ExecuteLD(message);
iState=EGameOver;
return;
}
iDoc->CheckRows();
if (iDoc->iLevel<=(iDoc->iLines/10))
{
iInterval*=3;
iInterval/=4;
iDoc->iLevel++;
}
iDoc->NewBlock();
}
iBeginTime.HomeTime();
After(iInterval);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -