You can do that in five events. The first does the motion, and the other four are for bouncing off each wall.
global number radius=16
global number gravity=1000
global number elasticity=0.5
every tick
--- add gravity*dt to vy
--- set x to self.x+vx*dt
--- set y to self.y+vy*dt
y>640-radius
--- set y to 640-radius
--- set vy to -elasticity*abs(vy)
y<radius
--- set y to radius
--- set vy to elasticity*abs(vy)
x>480-radius
--- set x to 480-radius
--- set vx to -elasticity*abs(vx)
x<radius
--- set x to radius
--- set vx to elasticity*abs(vx)