1. NodeBox 1
    1. Homepage
    2. NodeBox 3Node-based app for generative design and data visualization
    3. NodeBox OpenGLHardware-accelerated cross-platform graphics library
    4. NodeBox 1Generate 2D visuals using Python code (Mac OS X only)
  2. Gallery
  3. Documentation
  4. Forum
  5. Blog

Disappearing Bullets...

Posted by Cedric on Nov 10, 2008

I am not sure it is a bug, but here is my problem: I wanto to simulate some bunching with bullets. And the problem is that the exported movie is different (and wrong) from the running animation at runtime. Below is the code. If you try it, you can see bullets moving from left to right. But when exporting (100 frames, 10 fps), bullets disappear before reaching the image limit!

Am I wrong somewhere?

Cedric

P.S. Image size is just to fit with a customized Quantum Of Solace background...

coreimage = ximport("coreimage")
global frame, bullets, w, h
w, h = 1280, 950
bullets = coreimage.canvas(w, 30)
size(w, h)
speed(24)
background(None)
 
def setup():
    global frame, bullets, w, h
    frame = 0
 
def bullet_factory(deltax=0):
    fill(0.5)
    bullets.append(oval(0, 0, 15, 15, draw=False))
    bullets[-1].x = 0
    bullets[-1].y = 15
    return bullets
 
def draw():
    global frame, bullets, w, h
    frame += 1
 
    if random() > 0.5 and len(bullets) < 25:
        bullet_factory()
 
    for bullet in bullets:    
        if bullet.x > w:
            del bullet
        else:
            bullet.x = bullet.x + 23
 
    bullets.draw(670, 705)
    print ' Current bullet content: %i'%(len(bullets))