How do you make a simple animation with a rectangle. I know that there’s a example in Codea I tried it out for my project and it won’t work. Can someone show me how to do it?
What kind of animation is the rectangle supposed to do.
displayMode(FULLSCREEN)
function setup()
rectMode(CENTER)
x=WIDTH/2
y=100
dy=1
end
function draw()
background(0)
fill(255,0,0)
rect(x,y,50,25)
y=y+dy
if y>HEIGHT-100 then
dy=0
end
end
Or this:
function setup()
y = 1
end
function draw()
background(0)
fill(255)
if y < 100 then
y = y + 1
end
rect(200, 200, 500, y)
end
AveryD wrote: @TokOut @dave1707 thanks
Answer
Np - this is basic:
The
draw()
function is displayed 60 times a second
If you put there any printing it will print it 60 times a second. If you put there
z = z + 0.5
then it will give every 60 times a second the z value 1 more