Skip to content

Commit 9d0c281

Browse files
committed
python 3 compatibility
1 parent 32dd54b commit 9d0c281

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

popUp.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
from __future__ import print_function
12
try:
23
import pygame_sdl2 as pygame
34
except ImportError:
4-
print "pygame_sdl2 not found; falling back to pygame."
5+
print("pygame_sdl2 not found; falling back to pygame.")
56
import pygame
67
import time
78

snake.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#!/usr/bin/env python
22

3-
3+
from __future__ import print_function
44
import os
55
#from screen import screen
66
import sys
77
import random
8+
89
try:
910
import pygame_sdl2 as pygame
1011
except ImportError:
11-
print "pygame_sdl2 not found; falling back to pygame."
12+
print("pygame_sdl2 not found; falling back to pygame.")
1213
import pygame
1314
import conf
1415
from ui import ui
@@ -292,7 +293,7 @@ def run_game(self):
292293
elif event.key == pygame.K_q:
293294
self.exit_game()
294295
else:
295-
print "event.key:", event.key
296+
print("event.key:", event.key)
296297
#if event.key == pygame.K_UP:
297298
# self.move(1)
298299
else:
@@ -301,7 +302,7 @@ def run_game(self):
301302

302303
if conf.TOUCH_SCREEN:
303304
mouseAction = self.touchScreen.getEventBoxes()
304-
if mouseAction > 0:
305+
if mouseAction and mouseAction > 0:
305306
if gameOver:
306307
self.resetGame()
307308
gameOver = False

touchScreen.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
from __future__ import print_function
2+
13
try:
24
import pygame_sdl2 as pygame
35
except ImportError:
4-
print "pygame_sdl2 not found; falling back to pygame."
6+
print("pygame_sdl2 not found; falling back to pygame.")
57
import pygame
68

79
class touchScreen(object):

ui.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
# notes:
44
# The Ten Commandments Of Video Game Menus http://kotaku.com/5955855/the-ten-commandments-of-video-game-menus
5-
5+
from __future__ import print_function
66
try:
77
import pygame_sdl2 as pygame
88
except ImportError:
9-
print "pygame_sdl2 not found; falling back to pygame."
9+
print("pygame_sdl2 not found; falling back to pygame.")
1010
import pygame
1111
import sys
1212

@@ -183,11 +183,11 @@ def draw(self, menuKey=''):
183183

184184
elif event.type == pygame.KEYDOWN:
185185
if iUi.interaction(event.key):
186-
print "UI catched this key:", event.key
186+
print("UI catched this key:", event.key)
187187
else:
188-
print "no UI catch, key pressed:", event.key
188+
print("no UI catch, key pressed:", event.key)
189189
if pygame.K_RETURN == event.key:
190-
print "selected item:", iUi.getSelectedItem()
190+
print("selected item:", iUi.getSelectedItem())
191191

192192
if event.key == pygame.K_q:
193193
sys.exit(0)

0 commit comments

Comments
 (0)