posx = 30
posy = 300
vx = 4
vy = 4
skin = 12

def setup():
    size(800, 600)
    textSize(200)
    ellipseMode(CENTER)


def stok_kleiz():
    y_up = mouseY - 40
    y_down = mouseY + 40
    x_left = posx
    x_right = posx + 16
    if posy + skin > y_up and \
        posy - skin < y_down and \
        posx + skin > x_left and \
        posx - skin < x_right:
        return True
    return False

def stok_dehou():
    return False


def draw():
    global posx, posy
    global vx, vy
    
    posx = posx + vx
    posy = posy + vy
    
    if posx > width - 12 or posx < 12:
        vx = -vx
    if posy > height - 12 or posy < 12:
        vy = -vy
    
    if stok_kleiz():
        background(255, 0, 0)
    else:
        background(255)
    
    fill(0)
    text("PONG", width/2 - 250, height/2 + 40)
    stroke(0)
    fill(255)
    circle(posx, posy, 2*skin)
    
    # Tresañ ar raketennoù
    fill(0)
    rect(10, mouseY-40, 16, 80)
    rect(width-26, mouseY-40, 16, 80)