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

Adding a counter

Posted by Samuel Clemente Aceituno on Jan 25, 2011

Hi,
I'm doing a "Pong" as a homework and I have a problem.
I want to put a "counter", and I don't know how to do that the counter increases the numbers.
When I run the script, it increases a moment, but then the number dissappears...

I add the script.

Sorry for my english.
Thanks!!!


 
Posted by Trumpetto on Jan 26, 2011

size(400, 300)
speed(30)
 
def setup():
    global counter
    counter = 0
    text(str(counter), 160, 20)
    text(str(0), 220, 20)
 
def draw():
    global counter
 
    font("Andale Mono", 30)
    background(0)
    fill(1)
    counter = FRAME / 30
    text(str(counter), 160, 30)
    text(str(counter+2), 220, 30)
Right wins!



Posted by Samuel Clemente Aceituno on Jan 30, 2011

Thanks, I'll try it!!!