2007-09-05 17:01

PyWeek progress: the 4 hour mark

Suddenly I was having a calm day at work, and Rosario is taking care of the baby, so I spent a few hours on the PyWeek project.

I have integrated Chipmunk with QGraphicsScene.

What does it mean? That I can now...

  • Create a scene
  • Create a view onto that scene
  • Create balls, walls and polygons as scene items
  • Watch said balls/walls/polygons bounce around happily under Chipmunk direction.

For example, here's enough code to create a few balls a box and a staircase:

self.scene=ChipScene()
self.ui.view.setScene(self.scene)

for x in range (0, 10):
    self.scene.addBall(x*50.0+10, 50.0, 10.)
    self.scene.addBall(x*50.0+20, 20.0, 10.)
self.scene.addWall(0., 0., 0., 500.)
self.scene.addWall(0., 500., 500., 500.)
self.scene.addWall(500., 500., 500., 0.)
self.scene.addWall(500., 0., 0., 0.)
for i in range (0, 20):
    self.scene.addWall(i*20, 200+i*20, i*20+20, 200+i*20)
    self.scene.addWall(i*20+20, 200+i*20, i*20+20, 200+i*20+20)

self.scene.addPoly([[0, 50], [0, 100], [100, 100], [100, 50], [0, 50]])

I declare that nifty.

Comments

Comments powered by Disqus

Contents © 2000-2018 Roberto Alsina