
-----------------------------------
landfarm
Mon Apr 19, 2010 7:20 pm

Pong Help
-----------------------------------
What is it you are trying to achieve?
I am currently trying to make Pong more lively. 


What is the problem you are having?
I believe that I am almost done the project, but I have no clue how to add trigonometry or an alternative to add "physics" into the game of Pong. I know it sounds easy, but I have absolutely no idea how to do it. For example, when you hit the ball with the paddle to hit it further to the left, I have no clue how to do this. I'm hoping for a tutorial to help teach me the concept, rather than having someone doing it for me. Btw, I searched on the forums, but I couldn't find what I was looking for. 


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Here is my code so far. 



import GUI

var x1, x2, y1, y2, xc, yc : int %Declares the coordinate variables for the game
var c, t : int %Declares the counter variables for the game
var p1, p2 : int %Declares the points counter for the game
var velx, vely, facy, facx : int %Declares the velocity variables for the game
var timeprevious, timecurrent, timedifference : int %Declares variables for holding time
var font1 : int %Declares variable for font
var keys : array char of boolean

c := 1 %Counter to see if the game just started
t := 1 %Counter to see who's starting the game
p1 := 0
p2 := 0
velx := 0
vely := 0
facy := 1
facx := 1
font1 := Font.New ("serif:40")
assert font1 > 0

procedure controls1 %Controls for player1
    Input.KeyDown (keys)
    if keys ('a') and x1 >= 0 then
        x1 -= 4
    elsif keys ('d') and x1 + 60 = 0 then
        x2 -= 4
    elsif keys (KEY_RIGHT_ARROW) and x2 = 0 and yc + 20 = 0 and xc + 20 = maxy then %Sets up the points system
        p1 += 1
        c := 1
    elsif yc - 20 = x1 and yc - 20 >= y1) and (xc = y2 - 20) and (xc = maxx) or (xc - 20 