Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/data/graphics/physics
diff options
context:
space:
mode:
authorJames Cameron <quozl@laptop.org>2010-05-21 09:30:18 (GMT)
committer James Cameron <quozl@laptop.org>2010-05-21 09:30:18 (GMT)
commit4a50004aa8f2109e6cff4a082a10581dfee0d540 (patch)
tree90daf190816ac4a24515b1df907d953a576d2809 /data/graphics/physics
parent0ce089fc9bb7a9f18f953a32c7195e70a62cf2b1 (diff)
adapt pippy examples to screen dimensions, dev.laptop.org #9260
Adjust all the examples to work for different screen dimensions, and briefly fix formatting or style in some of the other code examples. Yet to be done: 1. slideshow, it finds no objects in journal with MIME type image/jpeg, and as a result does not show any slides, 2. xolympics, it tests an object location against physics world coordinates to determine winning condition.
Diffstat (limited to 'data/graphics/physics')
-rw-r--r--data/graphics/physics17
1 files changed, 8 insertions, 9 deletions
diff --git a/data/graphics/physics b/data/graphics/physics
index 556442a..0611351 100644
--- a/data/graphics/physics
+++ b/data/graphics/physics
@@ -6,12 +6,12 @@ from pippy import physics
# initialize pygame first thing
pygame.init()
-screen = pygame.display.set_mode((1200,900))
-
+screen = pygame.display.set_mode()
+
# set up the physics world (instance of Elements)
world = physics.Elements(screen.get_size())
world.renderer.set_surface(screen)
-
+
# set up initial physics objects
world.add.ground()
world.add.ball((600,0), 50)
@@ -19,9 +19,9 @@ world.add.rect((500,0), 25, 300, dynamic=True, density=1.0, restitution=0.16, fr
# add 20 more balls
balls = 0
-while(balls<20):
- world.add.ball((balls*5+200,balls*5), 50)
- balls+=1
+while(balls < 20):
+ world.add.ball((balls*5+200, balls*5), 50)
+ balls += 1
# begin physics simulation
world.run_physics = True
@@ -46,8 +46,8 @@ while pippy.pygame.next_frame() and world.run_physics:
world.mouse_move(event.pos)
# clear display with a color
- # (r,g,b), where 0<=value<256
- screen.fill((80,160,240))
+ # (red, green, blue), where 0 <= value < 256
+ screen.fill((80, 160, 240))
# update & draw physics world
world.update()
@@ -55,4 +55,3 @@ while pippy.pygame.next_frame() and world.run_physics:
# update the display
pygame.display.flip()
-