📄 blockview.cpp
字号:
#include "blockview.h"
#include "blockdata.h"
#include "superball_res.h"
BlockView::BlockView(BlockApp *app) : AppView((AEEApplet *)app)
{
}
BlockView::~BlockView()
{
}
AppResult BlockView::Open()
{
GetData()->initialize();
GetData()->mgr->RenderScene();
return SUCCESS;
}
AppResult BlockView::Close()
{
if(GetData()->mgr)
delete GetData()->mgr;
GetData()->mgr = NULL;
return SUCCESS;
}
AppResult BlockView::Update()
{
if(!GetData()->upgrading)
{
GetData()->moveall();
GetData()->check();
GetData()->mgr->RenderScene();
}
else if(GetData()->newlevel)
GetData()->levelup();
else if(GetData()->newlife)
GetData()->lifeup();
else if(GetData()->newuser)
GetData()->username();
else
GetData()->gameover();
return SUCCESS;
}
AppResult BlockView::Enable()
{
return SUCCESS;
}
AppResult BlockView::Disable()
{
GetData()->namedir = 0;
GetData()->moveboard(false, true);
GetData()->moveboard(false, false);
return SUCCESS;
}
ETStatus BlockView::HandleUserEvent(AEEEvent evtCode, uint16 param16, uint32 param32)
{
switch(evtCode)
{
case EVT_USER_TIMER:
if(param16 == 0)
{
Update();
return ET_PROCESSED;
}
default:
break;
}
return AppView::HandleUserEvent(evtCode,param16,param32);
}
ETStatus BlockView::HandleKeyEvent(AEEEvent evtCode, uint16 param16, uint32 param32)
{
int i;
boolean empty = false;
switch(evtCode)
{
case EVT_KEY_PRESS:
switch(param16)
{
case AVK_LEFT:
if(!GetData()->upgrading)
GetData()->moveboard(true, false);
if(GetData()->highscore)
if(GetData()->bottomindex != 0)
{
if(GetData()->namelen == GetData()->bottomindex+1 && GetData()->letterindex[GetData()->bottomindex] == 68)
GetData()->namelen--;
GetData()->bottomindex--;
}
return ET_PROCESSED;
break;
case AVK_RIGHT:
if(!GetData()->upgrading)
GetData()->moveboard(true, true);
if(GetData()->highscore)
if(GetData()->bottomindex != 7)
{
if(GetData()->namelen == GetData()->bottomindex+1)
{
GetData()->namelen++;
GetData()->letterindex[GetData()->namelen-1] = 68;
}
GetData()->bottomindex++;
}
return ET_PROCESSED;
case AVK_UP:
if(!GetData()->upgrading)
GetData()->sendball();
if(GetData()->highscore)
{
if(--GetData()->letterindex[GetData()->bottomindex] == 5)
GetData()->letterindex[GetData()->bottomindex] = 68;
GetData()->lettersm[GetData()->bottomindex].ModifyStripIndex(GetData()->letterindex[GetData()->bottomindex]);
GetData()->namedir = -1;
}
return ET_PROCESSED;
case AVK_DOWN:
if(GetData()->highscore)
{
if(++GetData()->letterindex[GetData()->bottomindex] == 69)
GetData()->letterindex[GetData()->bottomindex] = 6;
GetData()->lettersm[GetData()->bottomindex].ModifyStripIndex(GetData()->letterindex[GetData()->bottomindex]);
GetData()->namedir = 1;
}
return ET_PROCESSED;
case AVK_SELECT:
if(GetData()->highscore)
{
for(i = 0; i < GetData()->namelen; i++)
if(GetData()->letterindex[i] != 68)
empty = true;
if(!empty)
return ET_PROCESSED;
GetData()->newhighscore();
}
return ET_PROCESSED;
default:
break;
}
break;
case EVT_KEY_RELEASE:
switch(param16)
{
case AVK_LEFT:
if(!GetData()->upgrading)
GetData()->moveboard(false, false);
return ET_PROCESSED;
case AVK_RIGHT:
if(!GetData()->upgrading)
GetData()->moveboard(false, true);
return ET_PROCESSED;
case AVK_UP:
if(GetData()->highscore)
GetData()->namedir = 0;
return ET_PROCESSED;
case AVK_DOWN:
if(GetData()->highscore)
GetData()->namedir = 0;
return ET_PROCESSED;
default:
break;
}
break;
default:
break;
}
return AppView::HandleKeyEvent(evtCode, param16, param32);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -