Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/data/graphics/xolympics
diff options
context:
space:
mode:
Diffstat (limited to 'data/graphics/xolympics')
-rw-r--r--data/graphics/xolympics39
1 files changed, 21 insertions, 18 deletions
diff --git a/data/graphics/xolympics b/data/graphics/xolympics
index 525e480..b6ed90b 100644
--- a/data/graphics/xolympics
+++ b/data/graphics/xolympics
@@ -5,7 +5,10 @@ Use w,a,s,d and up,down,left,right to play.
Score by making the newest ball hit your opponent's wall.
"""
-import pippy, pygame, sys, math
+import pippy
+import pygame
+import sys
+import math
from pygame.locals import *
from pippy import physics
from pygame.color import *
@@ -42,15 +45,15 @@ class XOlympicsGame:
# add the left border and player (red)
self.world.set_color((255, 0, 0))
self.world.add.rect((0, -20), 25, self.height,
- dynamic=False, density=1.0,
- restitution=0.16, friction=0.5)
- self.leftplayer = self.world.add.poly(( self.width * 0.25, 81.0 ), [(-109.9405166666667, -64.244016666666653), (110.60718333333335, -63.089316666666605), (-0.66666666666668561, 127.33333333333337)] , dynamic=True, density=1.0, restitution=0.16, friction=0.5, screenCoord=False)
+ dynamic=False, density=1.0,
+ restitution=0.16, friction=0.5)
+ self.leftplayer = self.world.add.poly(( self.width * 0.25, 81.0 ), [(-109.9405166666667, -64.244016666666653), (110.60718333333335, -63.089316666666605), (-0.66666666666668561, 127.33333333333337)], dynamic=True, density=1.0, restitution=0.16, friction=0.5, screenCoord=False)
# add the right border and player (blue)
self.world.set_color((0, 0, 255))
self.world.add.rect((self.width, -20), 25, self.height,
- dynamic=False, density=1.0,
- restitution=0.16, friction=0.5)
- self.rightplayer = self.world.add.poly(( self.width * 0.75, 81.0 ), [(108.94051666666667, -65.976066666666611), (2.6666666666666288, 127.33333333333337), (-111.60718333333341, -61.357266666666646)] , dynamic=True, density=1.0, restitution=0.16, friction=0.5, screenCoord=False)
+ dynamic=False, density=1.0,
+ restitution=0.16, friction=0.5)
+ self.rightplayer = self.world.add.poly(( self.width * 0.75, 81.0 ), [(108.94051666666667, -65.976066666666611), (2.6666666666666288, 127.33333333333337), (-111.60718333333341, -61.357266666666646)] , dynamic=True, density=1.0, restitution=0.16, friction=0.5, screenCoord=False)
# we're getting 2 grounds - grey and green. why?
def run(self):
@@ -94,39 +97,39 @@ class XOlympicsGame:
self.rightDPress = False
if self.leftLPress:
- self.leftplayer.ApplyForce(box2d.b2Vec2(-self.forcespeed,0), self.leftplayer.GetWorldCenter())
+ self.leftplayer.ApplyForce(box2d.b2Vec2(-self.forcespeed, 0), self.leftplayer.GetWorldCenter())
if self.leftRPress:
- self.leftplayer.ApplyForce(box2d.b2Vec2(self.forcespeed,0), self.leftplayer.GetWorldCenter())
+ self.leftplayer.ApplyForce(box2d.b2Vec2(self.forcespeed, 0), self.leftplayer.GetWorldCenter())
if self.leftJump:
if self.leftplayer.GetWorldCenter().y < 0.75:
- self.leftplayer.ApplyImpulse(box2d.b2Vec2(0,self.jumpforce), self.leftplayer.GetWorldCenter())
+ self.leftplayer.ApplyImpulse(box2d.b2Vec2(0, self.jumpforce), self.leftplayer.GetWorldCenter())
if self.rightLPress:
- self.rightplayer.ApplyForce(box2d.b2Vec2(-self.forcespeed,0), self.rightplayer.GetWorldCenter())
+ self.rightplayer.ApplyForce(box2d.b2Vec2(-self.forcespeed, 0), self.rightplayer.GetWorldCenter())
if self.rightRPress:
- self.rightplayer.ApplyForce(box2d.b2Vec2(self.forcespeed,0), self.rightplayer.GetWorldCenter())
+ self.rightplayer.ApplyForce(box2d.b2Vec2(self.forcespeed, 0), self.rightplayer.GetWorldCenter())
if self.rightDPress:
- self.rightplayer.ApplyImpulse(box2d.b2Vec2(0,-self.jumpforce), self.rightplayer.GetWorldCenter())
+ self.rightplayer.ApplyImpulse(box2d.b2Vec2(0 ,-self.jumpforce), self.rightplayer.GetWorldCenter())
if self.rightJump:
if self.rightplayer.GetWorldCenter().y < 0.75:
- self.rightplayer.ApplyImpulse(box2d.b2Vec2(0,self.jumpforce), self.rightplayer.GetWorldCenter())
+ self.rightplayer.ApplyImpulse(box2d.b2Vec2(0, self.jumpforce), self.rightplayer.GetWorldCenter())
if self.leftDPress:
- self.leftplayer.ApplyImpulse(box2d.b2Vec2(0,-self.jumpforce), self.leftplayer.GetWorldCenter())
+ self.leftplayer.ApplyImpulse(box2d.b2Vec2(0, -self.jumpforce), self.leftplayer.GetWorldCenter())
# Clear Display
if self.ball.GetWorldCenter().x < 1:
self.leftscore += 1
print "Goal Blue!", self.leftscore
self.world.set_color((0, 0, 255))
- self.ball = self.world.add.ball((self.width/2, 0), 50)
+ self.ball = self.world.add.ball((self.width / 2, 0), 50)
elif self.ball.GetWorldCenter().x > 11:
# FIXME: the 11 above works only when display width is
# 1200 pixels
self.rightscore += 1
print "Goal Red!", self.rightscore
self.world.set_color((255, 0, 0))
- self.ball = self.world.add.ball((self.width/2, 0), 50)
+ self.ball = self.world.add.ball((self.width / 2, 0), 50)
- self.screen.fill((255,255,255))
+ self.screen.fill((255, 255, 255))
# Update & Draw World
self.world.update()
self.world.draw()