
-----------------------------------
ashvinthecha
Sat May 30, 2009 5:30 pm

please help: pong game for school
-----------------------------------
ok i have no idea how to make a ball for the game and i could use some help here is my code so far 

% variable declaration 
var x : int 
var y : int 
var p1 : string 
var p2 : string 
var ashvin := 100 
var ashvin2 := 180 
var ashvin3 := 100 
var ashvin4 := 180 
var bouce1 := 1 
var bounce2 := 1 
var background := white 
var getKey : array char of boolean 

% procedure declaration 
procedure Screen 
drawfillbox (0, 0, maxx, maxy, background) 
drawfillbox (20, ashvin, 30, ashvin2, black) 
drawfillbox (maxx - 20, ashvin3, maxx - 30, ashvin4, black) 
end Screen 

procedure MoveP1Up 
drawfillbox (20, ashvin2, 30, ashvin, background) 
ashvin += 1 
ashvin2 += 1 
drawfillbox (20, ashvin2, 30, ashvin, black) 
delay (3) 
end MoveP1Up 

procedure MoveP1Down 
drawfillbox (20, ashvin2, 30, ashvin, background) 
ashvin -= 1 
ashvin2 -= 1 
drawfillbox (20, ashvin2, 30, ashvin, black) 
delay (3) 
end MoveP1Down 

procedure MoveP2Up 
drawfillbox (maxx - 20, ashvin3, maxx - 30, ashvin4, background) 
ashvin3 += 1 
ashvin4 += 1 
drawfillbox (maxx - 20, ashvin3, maxx - 30, ashvin4, black) 
delay (3) 
end MoveP2Up 

procedure MoveP2Down 
drawfillbox (maxx - 20, ashvin3, maxx - 30, ashvin4, background) 
ashvin3 -= 1 
ashvin4 -= 1 
drawfillbox (maxx - 20, ashvin3, maxx - 30, ashvin4, black) 
delay (3) 
end MoveP2Down 


% beginning of program 
loop 
drawfillbox (20, ashvin, 30, ashvin2, black) 
Input.KeyDown (getKey) 
if getKey ('q') then 
MoveP1Up 
end if 
if getKey ('a') then 
MoveP1Down 
end if 

if (ashvin = maxy - 80) then 
ashvin2 := maxy 
ashvin := maxy - 80 
end if 
drawfillbox (maxx - 20, ashvin3, maxx - 30, ashvin4, black) 
Input.KeyDown (getKey) 
if getKey (KEY_UP_ARROW) then 
MoveP2Up 
end if 
if getKey (KEY_DOWN_ARROW) then 
MoveP2Down 
end if 
if (ashvin3 = maxy - 80) then 
ashvin4 := maxy 
ashvin3 := maxy - 80 
end if 
View.Update 
end loop

-----------------------------------
tjmoore1993
Sat May 30, 2009 5:40 pm

RE:please help: pong game for school
-----------------------------------
You really didn't need to ask for help. Why? Simple explanation. Simply go to the submission section a look for submissions on Ping-Pong. Most of them demonstrate accurate movement of the ball and will help you a lot.

If that doesn't help then ask again. :)

-----------------------------------
saltpro15
Sat May 30, 2009 5:44 pm

RE:please help: pong game for school
-----------------------------------
I think mine's pretty descriptive

http://compsci.ca/v3/viewtopic.php?t=20169&highlight=pong

cheers
