
-----------------------------------
Salman
Thu Jan 17, 2013 1:41 pm

Turing Pong Project
-----------------------------------
What is it you are trying to achieve?
I'm trying to make the ball hit the paddles

Describe what you have tried to solve this problem
I'm confused with how to make it hit the paddles

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)




import GUI
var x2 := maxx div 2
var y2 := maxy div 2
const radius := 10
var speedx : int := -1
var speedy : int := 1
var font : int
var font2 : int
var movement1 : int := 0
var movement2 : int := 0
var keys : array char of boolean
var x := 175
var y := 0
colorback (black)
for i : 1 .. 25 %Counted loop makes the background stay black
    for j : 1 .. 80
        put " " ..
    end for
end for
setscreen ("nocursor,offscreenonly")
font := Font.New ("Arial Black:18")
font2 := Font.New ("Arial Black:12")
Font.Draw ("Pong", 280, 320, font, red)

procedure startGame
    cls
 
    Draw.FillBox (0, 600, maxx, 360, brightred)
    Draw.FillBox (0, 00, maxx, 45, brightred)
    Draw.FillBox (0, 175 + movement1, 10, 225 + movement1, brightred)
    Draw.FillBox (630, x + movement2, maxx, 225 + movement2, brightred)
    Font.Draw ("Player 1 Score", 5, 385, font2, blue)
    Font.Draw ("Player 2 Score", 500, 385, font2, blue)
    Input.KeyDown (keys)
    if keys ('w') then
        Draw.FillBox (0, 175 + movement1, 10, 225 + movement1, brightred)
        if movement1 = 45 - 175 then
            movement1 := movement1 - 2
        end if
    end if

    if keys (KEY_UP_ARROW) then
        Draw.FillBox (630, 175 + movement2, maxx, 225 + movement2, brightred)
        if movement2 = 45 - 175 then
            movement2 := movement2 - 2
        end if
    end if

    Draw.FillOval (x2, y2, radius, radius, brightblue)
    x2 := x2 + speedx
    y2:=y2+speedy
    if y2 + speedy + radius > 360 or y2 + speedy - radius < 45 then
        speedy := speedy * -1
    end if
    if x2 + speedx + radius