Computer Science Canada need help with pong |
Author: | cop_mike [ Thu Nov 04, 2004 9:02 pm ] |
Post subject: | need help with pong |
hey i found out how to add the score and stuff but the score keeps adding up when it hits the walls and even when the ball hits the paddles its gives the other person a couple points can u fix this and send it back to me? View.Set ("graphics:640;480") var x, y, xr, yr, c, x1, y1, x2, y2 : int var xstep, ystep : int := 5 var key : string (1) var count1, count2 := 0 var font, font1 : int font := Font.New ("arial :20:bold") font1 := Font.New ("arial :30:bold") ystep := 6 x := 480 y := 240 xr := 8 yr := 8 x1 := 10 y1 := 240 x2 := 620 y2 := 240 count1 := 0 count2 := 0 drawfillbox (640, 0, 0, 480, 2) Font.Draw ("Welcome to MIke's game of...", 72, 320, font, 0) delay (3000) cls delay (10) drawfillbox (640, 0, 0, 480, 2) Font.Draw ("!~!~!~!~PONG~!~!~!~!", 190, 320, font, 0) delay (3000) cls delay (10) loop randint (c, 10, 69) %line in middle drawline (320, 480, 320, 0, 7) %circle in middle drawoval (320, 210, 80, 80, 7) %score border drawfillbox (640, 420, 0, 480, 4) %score Font.Draw (intstr (count1), 175, maxy - 25, font, 0) Font.Draw (intstr (count2), maxx - 175, maxy - 25, font, 0) %ball drawfilloval (x, y, xr, yr, c) % right paddle drawfillbox (x1, y1, x1 + 10, y1 + 60, c) %left paddle drawfillbox (x2, y2, x2 + 10, y2 + 60, c) delay (30) % clear ball drawfilloval (x, y, xr, yr, 0) %clear right paddle drawfillbox (x1, y1, x1 + 10, y1 + 60, 0) %clear left paddle drawfillbox (x2, y2, x2 + 10, y2 + 60, 0) x := x + xstep y := y + ystep %keys if hasch then getch (key) if key = "W" or key = "w" and y1 < 350 then y1 := y1 + 20 elsif key = "S" or key = "s" and y1 > 0 then y1 := y1 - 20 elsif key = chr (200) and y2 < 350 then y2 := y2 + 20 elsif key = chr (208) and y2 > 0 then y2 := y2 - 20 end if end if %makes it bounce if x > 630 or x < 10 then xstep := -xstep end if if y > 410 or y < 10 then ystep := -ystep end if if x - 8 <= x1 + 10 then if y >= y1 and y <= y1 + 50 then xstep := -xstep end if end if %bounces off paddles if x + 8 >= x2 then if y >= y2 and y <= y2 + 50 then xstep := -xstep end if end if %marks score if x >= 640 - 35 then count1 := count1 + 1 elsif x <= 35 then count2 := count2 + 1 end if end loop |
Author: | Tony [ Thu Nov 04, 2004 9:06 pm ] |
Post subject: | |
oh yes! I'm on it One pong assignment comming right up, would you like a sideorder of a loading bar with that? |
Author: | AsianSensation [ Thu Nov 04, 2004 9:10 pm ] | ||
Post subject: | |||
here, Pong:
|
Author: | cop_mike [ Thu Nov 04, 2004 9:10 pm ] |
Post subject: | |
so ur going to help me? |
Author: | SuperGenius [ Thu Nov 04, 2004 9:40 pm ] |
Post subject: | |
most people will be glad to help you, however most people around here are not a fan of doing your work for you. |
Author: | Tony [ Thu Nov 04, 2004 9:47 pm ] | ||
Post subject: | |||
oh, I am! I enjoy doing work for others! here's your pong
|
Author: | Neo [ Thu Nov 04, 2004 10:56 pm ] | ||
Post subject: | |||
Here you GO!!!!
|
Author: | Tony [ Thu Nov 04, 2004 11:11 pm ] |
Post subject: | |
Neo : its flash, slow and too long. how about pong in 20 lines? |
Author: | Neo [ Thu Nov 04, 2004 11:26 pm ] |
Post subject: | |
That pong is not mine, its cop_mike's, I just fixed his scoring problem. |
Author: | cop_mike [ Fri Nov 05, 2004 7:15 pm ] |
Post subject: | |
no its ok i didnt want someone to do it for me i just needed help but its ok now i got it working by myself at school today. thanx nyways |