Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--physics.py2
-rw-r--r--tools.py70
2 files changed, 1 insertions, 71 deletions
diff --git a/physics.py b/physics.py
index 4b2bbdc..4615117 100644
--- a/physics.py
+++ b/physics.py
@@ -32,8 +32,6 @@ class PhysicsGame:
self.clock = pygame.time.Clock()
self.font = pygame.font.Font(None, 24) # font object
self.canvas = olpcgames.ACTIVITY.canvas
- self.joystickobject = None
- self.debug = True
# create the name --> instance map for components
self.toolList = {}
for c in tools.allTools:
diff --git a/tools.py b/tools.py
index 0ce23d9..41bc52f 100644
--- a/tools.py
+++ b/tools.py
@@ -43,39 +43,7 @@ class Tool(object):
self.game.setTool("magicpen")
#elif event.key == K_g:
# self.game.setTool("gear")
- # Game/joystick-related keys
- elif event.key == K_KP4: # Left gamepad, left arrow
- if self.game.joystickobject:
- self.game.joystickobject[0].ApplyTorque(9000)
- elif self.game.debug: print "Left gamepad left arrow error: no joystick object selected"
- elif event.key == K_KP6: # Left gamepad, right arrow
- if self.game.joystickobject:
- self.game.joystickobject[0].ApplyTorque(9000)
- elif self.game.debug: print "Left gamepad right arrow error: no joystick object selected"
- elif event.key == K_KP8: # Left gamepad, up arrow
- if self.game.joystickobject:
- self.game.joystickobject[0].ApplyTorque(9000)
- elif self.game.debug: print "Left gamepad up arrow error: no joystick object selected"
- elif event.key == K_KP2: # Left gamepad, down arrow
- if self.game.joystickobject:
- self.game.joystickobject[0].ApplyTorque(9000)
- elif self.game.debug: print "Left gamepad down arrow error: no joystick object selected"
- elif event.key == K_KP7: # Right gamepad, square
- if self.game.joystickobject:
- self.game.joystickobject[0].ApplyTorque(-9000)
- elif self.game.debug: print "Right gamepad square button error: no joystick object selected"
- elif event.key == K_KP1: # Right gamepad, check
- if self.game.joystickobject:
- self.game.joystickobject[0].ApplyTorque(-9000)
- elif self.game.debug: print "Right gamepad check button error: no joystick object selected"
- elif event.key == K_KP9: # Right gamepad, circle
- if self.game.joystickobject:
- self.game.joystickobject[0].ApplyTorque(-9000)
- elif self.game.debug: print "Right gamepad circle button error: no joystick object selected"
- elif event.key == K_KP3: # Right gamepad, X
- if self.game.joystickobject:
- self.game.joystickobject[0].ApplyTorque(-9000)
- elif self.game.debug: print "Right gamepad X button error: no joystick object selected"
+
elif event.type == USEREVENT:
if hasattr(event,"action"):
if self.game.toolList.has_key(event.action): self.game.setTool(event.action)
@@ -394,42 +362,6 @@ class DestroyTool(Tool):
def cancel(self):
self.vertices = None
- # The joystick tool
-class JoystickTool(Tool):
- name = "joystick"
- icon = "magicpen" # for now
- toolTip = "Joystick"
-
- def __init__(self,gameInstance):
- self.game = gameInstance
- self.name = "Joystick"
- self.vertices = None
- #self.joystickobject
- def handleEvents(self,event):
- #look for default events, and if none are handled then try the custom events
- super(JoystickTool,self).handleEvents(event)
- if pygame.mouse.get_pressed()[0]:
- if not self.vertices:
- self.vertices = []
- self.vertices.append(pygame.mouse.get_pos())
- if len(self.vertices) > 10:
- self.vertices.pop(0)
- self.game.joystickobject = self.game.world.get_bodies_at_pos(pygame.mouse.get_pos())
- if self.game.joystickobject:
- print "hi1"
- #self.game.world.world.DestroyBody(self.joystickobject[0])
- elif event.type == MOUSEBUTTONUP and event.button == 1:
- self.cancel()
- def draw(self):
- # draw the trail
- if self.vertices:
- if len(self.vertices) > 1:
- pygame.draw.lines(self.game.screen,(255,0,0),False,self.vertices,3)
-
- def cancel(self):
- self.vertices = None
-
-
def getAllTools():
this_mod = __import__(__name__)
all = [val for val in this_mod.__dict__.values() if isinstance(val, type)]