Computer Science Canada Simple Pong |
Author: | Hallowedbethyname666 [ Thu Nov 18, 2004 1:04 pm ] |
Post subject: | Simple Pong |
Really simple, did it as a computer science project. I actually had Dimmu Borgir set playing in the backround, but seeing as you'd have to download the file, i thought it would be useless. colourback (black) colour (black) cls colour (12) locate (3, 22) put " Welcome to Pong " locate (25, 17) put " Written by Hallowedbethyname666, October 7th, 2004 " locate (10,3) put "Paddle 1 Controls - f Moves Paddle Up, v moves Paddle Down" locate (11,3) put "Paddle 2 Controls - j Moves Paddle Up, n moves Paddle Down" delay (6100) cls %Variables setscreen ("graphics : 600 ; 300") var x, y, xp, yp, xa, ya : int var xstep, ystep, radius : int var key : string (1) var score1, score2 : int score1 := 0 score2 := 0 xp := 20 yp := 190 xa := 620 ya := 190 x := round (maxx / 2) y := round (maxy / 2) radius := 5 xstep := 1 ystep := 1 %random moving ball drawfillbox (xp, yp, xp + 7, yp + 70, darkgrey) drawfillbox (xa, ya, xa - 7, ya + 70, darkgrey) drawline (0, 375, maxx, 375, grey) drawline (1, 375, maxx, 375, grey) drawline (2, 375, maxx, 375, grey) drawline (3, 375, maxx, 375, grey) drawline (4, 375, maxx, 375, grey) loop drawline (0, 375, maxx, 375, grey) drawline (1, 375, maxx, 375, grey) drawline (2, 375, maxx, 375, grey) drawline (3, 375, maxx, 375, grey) drawline (4, 375, maxx, 375, grey) drawfilloval (x, y, radius, radius, white) delay (3) drawfilloval (x, y, radius, radius, black) x := x + xstep y := y + ystep if y > maxy - radius or y < radius then ystep := -ystep end if if x > maxx - radius -1 then xstep := -xstep score1 := score1 + 1 x := round (maxx / 2) y := round (maxy / 2) elsif x < radius + 1 then xstep := -xstep score2 := score2 + 1 x := round (maxx / 2) y := round (maxy / 2) end if %Paddle 1 %Paddle 1 Collison if whatdotcolour (x - radius + 1, y) not= black then xstep := -xstep elsif whatdotcolour (x - radius - 1, y) not= black then xstep := -xstep elsif whatdotcolour (x, y - radius + 1) not= black then ystep := -ystep elsif whatdotcolour (x, y - radius - 1) not= black then ystep := -ystep elsif whatdotcolour (x + radius + 1, y) not= black then xstep := -xstep elsif whatdotcolour (x - radius - 1, y) not= black then xstep := -xstep elsif whatdotcolour (x, y + radius + 1) not= black then ystep := -ystep elsif whatdotcolour (x, y - radius - 1) not= black then ystep := -ystep end if %Paddle 1 Movement if hasch then getch (key) if key = "f" then drawfillbox (xp, yp, xp + 7, yp + 70, black) yp += 10 drawfillbox (xp, yp, xp + 7, yp + 70, darkgrey) elsif key = "v" then drawfillbox (xp, yp, xp + 7, yp + 70, black) yp -= 10 drawfillbox (xp, yp, xp + 7, yp + 70, darkgrey) elsif key = "j" then drawfillbox (xa, ya, xa - 7, ya + 70, black) ya += 10 drawfillbox (xa, ya, xa - 7, ya + 70, darkgrey) elsif key = "n" then drawfillbox (xa, ya, xa - 7, ya + 70, black) ya -= 10 drawfillbox (xa, ya, xa - 7, ya + 70, darkgrey) end if %Paddle 2 if whatdotcolour (x + radius + 1, y) not= black then xstep := -xstep elsif whatdotcolour (x + radius - 1, y) not= black then xstep := -xstep elsif whatdotcolour (x, y + radius + 1) not= black then ystep := -ystep elsif whatdotcolour (x, y + radius - 1) not= black then ystep := -ystep end if %Scoring locate (1, 1) put "Player 1 Score: ", score1 locate (1, 32) put "Pong" locate (1, 63) put "Player 2 Score: ", score2 end if end loop Enjoy. There's probably easier/harder ways to do this, but i found this one worked well. And oh yeah, the game doesn't end, only when you chose it to. |
Author: | zomg [ Thu Nov 18, 2004 1:13 pm ] |
Post subject: | |
its good execpt for the fact that the ball moves way too fast and the paddles are really slow good job tho |
Author: | Andy [ Thu Nov 18, 2004 3:40 pm ] |
Post subject: | |
pong has been posted at least 20 times.. plz do not post anything useless. |
Author: | Martin [ Thu Nov 18, 2004 3:55 pm ] |
Post subject: | |
Dodge, lay off man. Use code tags next time though guy |
Author: | Neo [ Thu Nov 18, 2004 5:21 pm ] |
Post subject: | |
The ball got stuck inside the scoring banner at the top when I tried it. The paddles should be fixed because you can move them off screen. |
Author: | computer_killer [ Wed Dec 15, 2004 12:12 pm ] |
Post subject: | hahahaha, kool |
that was really good only there is a glich in it, or rather a few. the ball gets stuck at the top and erases all the words. |
Author: | nathan [ Wed Dec 15, 2004 3:00 pm ] |
Post subject: | Re: Simple Pong |
my number is 1519 843 5310 |
Author: | Paul [ Wed Dec 15, 2004 4:05 pm ] |
Post subject: | |
Hey, quit spamming nathan, I know where you are, don't make me wring your little neck. |
Author: | m&m [ Thu Dec 16, 2004 11:46 am ] |
Post subject: | |
theres lotsa glitches in it and the fact that pong has been posted many times adds to the fact that this program is useless as dodge_tomahawk has stated |
Author: | zomg [ Thu Dec 16, 2004 12:14 pm ] |
Post subject: | |
i dont think its useless... he posted this game im shure not to be needlessly flamed by a noob that hasnt posted any programs of his own |
Author: | Amreen [ Sat Jan 22, 2005 12:55 pm ] |
Post subject: | |
i like it...nice job...its fun!!! gj |
Author: | b89 [ Sun Mar 20, 2005 12:55 pm ] |
Post subject: | |
yeh i made a pong game using a little C++ and Gamemaker. The ball moves too fast and some times it chops off the bar thingy. Anyways its still a good Beta version type game. |
Author: | [Gandalf] [ Mon Mar 21, 2005 7:29 pm ] |
Post subject: | |
grrr...people, people - do you have eyes? Amreen: "Posted: Thu Dec 16, 2004" means that this was posted more than a while ago, and the thread has died off. If you want to talk about pong then do it in Off Topic, or at least at a newer topic... b89: A month is also quite a bit for a new post - if you want to post your game then do so - in the C++ section... Since you're not brand new - you should already know of this rule, don't do it again. |
Author: | Delos [ Mon Mar 21, 2005 8:16 pm ] |
Post subject: | |
Don't people ever read the front page? Specifically the article on Necro posting...[sigh]. And yes I understand the irony in this post... |
Author: | dann_west [ Mon May 02, 2005 2:02 pm ] |
Post subject: | Re: Simple Pong |
Nice Work! Fun but the paddles were kinda slow. |