from apcs import Window
#COMMAND S TO SAVE THEN YOU CAN RUN!!!!
#if you deleted terminal, then just do cd Desktop and cd Kavinaya and finally python3 bouncingball.py
x = 100
y = 100
dx = 5
dy = 3


def drawBall():  #def= define, you are not calling the function btw
    global x, y, dx, dy  #you can change the value of x and y, only in a function
    Window.out.circle(x, y, 10)

    x = x + dx  #dx is the change in the x value
    y = y + dy  #dy is the change in the y value

    if x > 500 or x < 0:
        dx = -1 * dx
    if y > 500 or y < 0:
        dy = -1 * dy


Window.size(500, 500)
Window.frame(drawBall)
Window.start()  #makes window show up, in java it is already given
Exemple #2
0
def checkPaddle():
    global dx, dy
    if abs(x - 740) <= 10 and abs(y - paddle2y) <= 50:
        dx = -dx
        dy = dy + (y - paddle2y) / 10
    if abs(x - 60) <= 10 and abs(y - paddle1y) <= 50:
        dx = -dx
        dy = dy + (y - paddle1y) / 10
    pass


def checkScore():
    pass


#set size
Window.size(800, 600)

#functions for drawing the Frame
Window.frame(drawBackground)
Window.frame(drawBall)
Window.frame(moveBall)
Window.frame(drawPaddle)
Window.frame(movePaddle)
Window.frame(checkBounce)
Window.frame(checkPaddle)
Window.frame(checkScore)

#start animation
Window.start()
from apcs import Window

x = 400
y = 200


def tree():
    global x, y
    #trunk
    Window.out.color("brown")
    Window.out.rectangle(410, 350, 30, 250)
    #leaves
    Window.out.color("green")
    Window.out.circle(380, 180, 60)
    Window.out.circle(380, 120, 60)
    Window.out.circle(440, 120, 60)
    Window.out.circle(440, 180, 60)


Window.size(800, 800)
Window.frame(tree)

Window.start()
Exemple #4
0
    global x, y, dx, dy
    x = x + dx
    y + y + dy

def detectHit():
    global x, y, dx, dy

    if abs(Window.mouse.getx() - x) < 20 and abs(Window.mouse.getY() - y) < 20:
        dx = x - Window.mouse.getX()
        dy = y - Window.mouse.getY()

def detectBounce():
    global x, y, dx, dy
    if x > 795:
        x = 5
        dx = -dx
    if x < 5:


    #collabedit.com/25qxe





Window.size(800, 800)
Window.frame(drawBall)
Window.frame(moveBall)
Window.frame(detectHit)
Window.start()
Exemple #5
0
    balls.append(
        [randint(0, 500),
         randint(0, 500),
         randint(-5, 5),
         randint(-5, 5)])


def drawBalls():
    for ball in balls:
        Window.out.color(ball[4])
        Window.out.circle(ball[0], ball[1], 5)


def moveBalls():
    global balls  #wassupgAAAAys
    for ball in balls:
        ball[0] += ball[2]
        ball[1] += ball[3]

        if ball[0] < 5 or ball[0] > 495:
            ball[2] = -ball[2]
        if ball[1] < 5 or ball[0] > 495:
            ball[3] = -ball[3]
    pass


Window.size(500, 500)
Window.frame(drawBalls)
Window.frame(moveBalls)
Window.start()
Exemple #6
0
from apcs import Window

x = 50
dx = 5

def frame():
    global x, dx
    Window.out.circle(x, 200, 50)
    x = x + dx

    if x > 450:
        dx = -5
    if x < 50:
        dx = 5

    

Window.size(500, 500)
Window.frame(frame)
Window.start()
Exemple #7
0
from apcs import Window

Window.size(500, 500)


def drawRainbow():
    Window.out.color("red")
    Window.out.circle(250, 500, 250)
    Window.out.color("orange")
    Window.out.circle(250, 500, 225)


Window.frame(drawRainbow)
Window.start()