Bug with python mode

The tutorial written is correct and not obselete.

It says:



You need to include the keyword 'global ’ only when you want to reassign that variable inside a function.

Here, you are reassigning the value of the global variable inside the draw() function.

If you do not want to include that keyword, another alternative is first overriding the value of the global variables inside the draw() function and then assigning them.

ys = 0
g = 0.1
x = 300
y = 50

def setup():
    size(600,600)
    delay(1000)
def draw():
    ys = 0
    g = 0.1
    x = 300
    y = 50
    background(0)
    ys += g
    y += ys
    ellipse(x,y,15,15)

Hope this helps! :smile:

3 Likes