bouncing.py

Created by julien-bernon

Created on October 13, 2021

328 Bytes


from kandinsky import *
from time import *
x=10
y=10
vx=2
vy=2
while True:
  fill_rect(0,0,320,240,(255,255,255))
  x+=vx
  y+=vy
  if x<0:
    x=0
    vx=-vx
  if x>320-10:
    x=320-10
    vx=-vx
  if y<0:
    y=0
    vy=-vy
  if y>224-10:
    y=224-10
    vy=-vy
  fill_rect(x,y,10,10,(255,0,0))
  sleep(0.03)