Ir al contenido principal

Ralsina.Me — El sitio web de Roberto Alsina

PyWeek progress: the 4 hour mark

Sud­den­ly I was hav­ing a calm day at work, and Rosario is tak­ing care of the baby, so I spent a few hours on the Py­Week projec­t.

I have in­te­grat­ed Chip­munk with QGraph­ic­sS­cene.

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

  • Cre­ate a scene

  • Cre­ate a view on­­to that scene

  • Cre­ate bal­l­s, walls and poly­­gons as scene items

  • Watch said bal­l­s/wal­l­s/poly­­gons bounce around hap­pi­­ly un­der Chip­­munk di­rec­­tion.

For ex­am­ple, here's enough code to cre­ate a few balls a box and a stair­case:

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 de­clare that nifty.

Juanjo / 2007-09-06 06:08:

So.. which is your entry name?

Roberto Alsina / 2007-09-06 12:04:

OldPumpkin


Contents © 2000-2020 Roberto Alsina