Skip to content

Commit 32dd54b

Browse files
committed
Use pygame_sdl2 if possible.
1 parent fac5449 commit 32dd54b

File tree

5 files changed

+26
-9
lines changed

5 files changed

+26
-9
lines changed

joystick.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import pygame
2-
1+
try:
2+
import pygame_sdl2 as pygame
3+
except ImportError:
4+
import pygame
35

46
class joystick(object):
57
def __init__(self):

popUp.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import pygame
1+
try:
2+
import pygame_sdl2 as pygame
3+
except ImportError:
4+
print "pygame_sdl2 not found; falling back to pygame."
5+
import pygame
26
import time
37

48

@@ -40,4 +44,4 @@ def drawPopUps(self):
4044
xPos = (self._screen.get_width() / 2)
4145
self._screen.blit(self.fnt.render(fullText, 1, self.color), (xPos - (self.fnt.size(fullText)[0] / 2), 5))
4246

43-
return True
47+
return True

snake.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
#from screen import screen
66
import sys
77
import random
8-
import pygame
8+
try:
9+
import pygame_sdl2 as pygame
10+
except ImportError:
11+
print "pygame_sdl2 not found; falling back to pygame."
12+
import pygame
913
import conf
1014
from ui import ui
1115
from joystick import joystick

touchScreen.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
import pygame
2-
1+
try:
2+
import pygame_sdl2 as pygame
3+
except ImportError:
4+
print "pygame_sdl2 not found; falling back to pygame."
5+
import pygame
36

47
class touchScreen(object):
58
def __init__(self, width, height):
@@ -20,4 +23,4 @@ def getEventBoxes(self):
2023
mPosX, mPosY = pygame.mouse.get_pos()
2124
if pygame.mouse.get_pressed()[0] and self.regions[i].collidepoint(mPosX, mPosY):
2225
#print("HIT AREA:" + str(i))
23-
return i + 1
26+
return i + 1

ui.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
# notes:
44
# The Ten Commandments Of Video Game Menus http://kotaku.com/5955855/the-ten-commandments-of-video-game-menus
55

6-
import pygame
6+
try:
7+
import pygame_sdl2 as pygame
8+
except ImportError:
9+
print "pygame_sdl2 not found; falling back to pygame."
10+
import pygame
711
import sys
812

913

0 commit comments

Comments
 (0)