Example #1
0
bool PlayArea::MsgChar(int c) {
	if (!curPiece || !playing) return false;

	switch (c>>8) {
		case ALLEGRO_KEY_LEFT:
			curPiece->MoveLeft();
			break;

		case ALLEGRO_KEY_RIGHT:
			curPiece->MoveRight();
			break;

		case ALLEGRO_KEY_DOWN:
			if (curPiece->MoveDown()) {
				parent->HandleEvent(*this, MyDialog::MSG_UPDATESCORE, lines, score += ((600 - frameInterval)/100));
			}
			break;

		case ALLEGRO_KEY_UP:
			curPiece->RotateRight();
			break;

		case ALLEGRO_KEY_SPACE:
			while (curPiece->MoveDown()) {
				parent->HandleEvent(*this, MyDialog::MSG_UPDATESCORE, lines, score += ((600 - frameInterval)/100));
			}
			break;

		case ALLEGRO_KEY_ESCAPE:
			GameOver();
			break;

		default:
			return false;
	};

	return true;
}