import sas_pygame as sas
SPEED = 6

view = sas.createView(600, 400, "green","billard")
bandeRechts = sas.Rectangle(580,0,20,400, "blue")
bandeOben = sas.Rectangle(0,0,580,20, "blue")
bandeLinks = sas.Rectangle(0,20,20,380, "blue")
bandeUnten = sas.Rectangle(0, 380, 580, 20,"blue")
kugel = sas.Circle(285, 185, 15, "red")
kugel.setDirection(sas.Tools.randomNumber(0, 45))

def update():
    kugel.move(SPEED)
    if kugel.intersects(bandeOben) or kugel.intersects(bandeUnten):
        richtung = kugel.getDirection()
        kugel.setDirection(180 - richtung)
    if kugel.intersects(bandeLinks) or kugel.intersects(bandeRechts):
        richtung = kugel.getDirection()
        kugel.setDirection(360 - richtung)

while view.running:
    view.step()
    update()
view.quit()



