-
Notifications
You must be signed in to change notification settings - Fork 0
/
KeyDownHandler.cpp
50 lines (47 loc) · 926 Bytes
/
KeyDownHandler.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "KeyDownHandler.h"
#include "GameFram.h"
#include "GameMap.h"
#include "CommonFunc.h"
//处理旋转
bool KeyDownHandler::proc_key_rotate()
{
GameFram * game = GameFram::getInstance();
TetrisBase* tetris = game->cur_tetris;
AggregateBase* gameMap = game->m_gameMap;
if (tetris != NULL)
{
tetris->rotate(90);
if (!illTest())
tetris->rotate(270);
}
return true;
}
bool KeyDownHandler::proc_key_down()
{
return true;
}
bool KeyDownHandler::proc_key_left()
{
GameFram * game = GameFram::getInstance();
TetrisBase* tetris = game->cur_tetris;
if (tetris != NULL)
{
tetris->moveLeft();
if (!illTest())
tetris->moveRight();
}
return true;
}
bool KeyDownHandler::proc_key_right()
{
GameFram * game = GameFram::getInstance();
TetrisBase* tetris = game->cur_tetris;
if (tetris != NULL)
{
tetris->moveRight();
if (!illTest())
tetris->moveLeft();
}
return true;
return true;
}