|
10 | 10 | from ui import ui |
11 | 11 | from joystick import joystick |
12 | 12 | from popUp import popUp |
| 13 | +from touchScreen import touchScreen |
13 | 14 | #from pygame.sprite import Sprite |
14 | 15 |
|
15 | 16 | #sys.stdout = os.devnull |
@@ -62,6 +63,7 @@ def __init__(self): |
62 | 63 | self.playerBox = None |
63 | 64 | self.ui = None |
64 | 65 | self.popUp = None |
| 66 | + self.touchScreen = None |
65 | 67 |
|
66 | 68 | def move(self, direction): |
67 | 69 | #print 'direction:', direction |
@@ -232,6 +234,7 @@ def run_game(self): |
232 | 234 | self.iUi = ui(self.screen) |
233 | 235 | self.popUp = popUp(self.screen) |
234 | 236 | self.popUp.color = conf.FONT_COLOR |
| 237 | + self.touchScreen = touchScreen(self.SCREEN_WIDTH, self.SCREEN_HEIGHT) |
235 | 238 |
|
236 | 239 | pygame.joystick.init() |
237 | 240 | self.joystickInteract = joystick() |
@@ -291,7 +294,16 @@ def run_game(self): |
291 | 294 | else: |
292 | 295 | pass |
293 | 296 | #print event |
294 | | - |
| 297 | + |
| 298 | + if conf.TOUCH_SCREEN: |
| 299 | + mouseAction = self.touchScreen.getEventBoxes() |
| 300 | + if mouseAction > 0: |
| 301 | + if gameOver: |
| 302 | + self.resetGame() |
| 303 | + gameOver = False |
| 304 | + else: |
| 305 | + doMove = mouseAction |
| 306 | + |
295 | 307 | if gameOver is False and redrawCount >= (self.gameSpeed - self.gameSpeedFactors[self.gameSpeedFactor]): |
296 | 308 | # ONLY move, when the timer elapses! |
297 | 309 | # otherwise you could change the direction multiple times before the scenery changes and upates |
@@ -329,6 +341,9 @@ def run_game(self): |
329 | 341 | for elem in reversed(self.elements): |
330 | 342 | elem.blit() |
331 | 343 |
|
| 344 | + # draw touchscreen |
| 345 | + # TODO: draw touch areas |
| 346 | + |
332 | 347 | # draw pop ups |
333 | 348 | self.popUp.drawPopUps() |
334 | 349 |
|
|
0 commit comments