Listing 3: Handling timer messages
void TrisField::Notify(void) {
BeginDrawing();
if (trisApp.GameState() == GAME_PAUSED) {
return;
}
Stop();
if (trisApp.GameState() == NO_GAME) {
return;
}
currentPiece->TryMove(0,-1);
if (PieceFits()) {
ErasePiece(currentPiece, trisBLACK);
currentPiece->ConfirmMove();
DrawPiece(currentPiece);
if (!ignoreTickTime){
logo->Draw();
}
}
else {
LockPiece();
StripRows();
EnterPiece(intPair(5, 18));
ignoreTickTime = FALSE;
}
if (ignoreTickTime) {
Start(0, FALSE);
}
else {
// Start(tickTime, TRUE); Doesn't work
// properly with Watcom build (?)
Start(tickTime, FALSE);
}
// Other windows within the same app
// including menu panes and panels
// occasionally steal keyboard focus when
// the user clicks on them. This (greedily)
//keeps the focus on the playing field.
SetFocus();
EndDrawing();
}
//End of File