Posted: Mon Nov 09, 2009 7:57 pm Post subject: Yet another Pong game, Complete, With Beeps, points and tone sweeps!
Well...Here it is.
This is my first project...
code:
/*
PONG By ReCreate
(yet another)Remake of the old game PONG
Made in about 2-3 hours total.
Why I made it? No reason really, Kind of a competition with someone I know who had to make one for a project.
*/
View.Set ("graphics,nobuttonbar")
var boxx, boxy, xvelocity, yvelocity, xupordown, yupordown, points, p2points : int
var gameover, font, playerpaddlepos, otherplayerpaddlepos, debug : int
var gameovermessage : string
const midx := maxx div 2
const midy := maxy div 2
var chars : array char of boolean
points := 0
p2points := 0
boxx := midx
boxy := midy
xvelocity := Rand.Int (-8 - points, 8 + points)
yvelocity := Rand.Int (-8 - points, 8 + points)
gameover := 0 %0 means game not over, 1 means it is
playerpaddlepos := 10
otherplayerpaddlepos := 0
debug := 0 %0 means not in debug mode, 1 means is in debug mode
%prevents sloooow moving balls
if yvelocity < 4 or xvelocity < 4 or xvelocity = 0 then
xvelocity := Rand.Int (-8 - points, 8 + points)
yvelocity := Rand.Int (-8 - points, 8 + points)
end if
loop
Input.KeyDown (chars) %self explanatory
if chars ('r') then
%restarts the game
boxx := midx
boxy := midy
boxy := midy
xvelocity := Rand.Int (-8 - points, 8 + points)
yvelocity := Rand.Int (-8 - points, 8 + points)
gameover := 0
%prevents sloooow moving balls
if yvelocity < 4 or xvelocity < 4 or xvelocity = 0 then
xvelocity := Rand.Int (-8 - points, 8 + points)
yvelocity := Rand.Int (-8 - points, 8 + points)
end if
end if
if chars ('d') then %debug mode
if debug = 0 then
debug := 1
else
debug := 0
end if
delay (150)
end if
if debug = 1 then
put "Ball X velocity: " + intstr (xvelocity) + " Ball Y Velocity: " + intstr (yvelocity)
end if
if gameover = 0 then
%GAME HAS NOT ENDED!!!
if chars (KEY_UP_ARROW) then
if playerpaddlepos < maxy - 95 then
playerpaddlepos += 5
end if
end if
if chars (KEY_DOWN_ARROW) then
if playerpaddlepos > 0 then
playerpaddlepos -= 5
end if
end if
%finds is the box is out of the screen
if boxx < 0 then
gameovermessage := "You don't win. Still next level"
gameover := 1
p2points += 1
end if
if boxy < 0 then
%bounce!
yvelocity := -yvelocity
Music.Sound (440, 50)
end if
if boxx > maxx then
%you win
gameover := 1
gameovermessage := "You win! Next level"
points += 1
end if
if boxy > maxy - 20 then
%bounce!
Music.Sound (440, 50)
yvelocity := -yvelocity
end if
Time.DelaySinceLast (round (1000 / 30)) %delays to get 30 FPS
Draw.Cls () %clears the screen for this frame
put "Points: " + intstr (points) + " Points: " + intstr (p2points)
Draw.Line (midx, 0, midx, maxy, black)
%draws the ball
Draw.Box (boxx, boxy, boxx + 20, boxy + 20, black)
%moves the ball
boxx += xvelocity
boxy += yvelocity
%moves the other paddle
if boxy > otherplayerpaddlepos then
otherplayerpaddlepos += 3 + points
else
otherplayerpaddlepos -= 3 + points
end if
%collision checking
if 619 >= boxx and 599 <= boxx + 20 and otherplayerpaddlepos + 80 >= boxy and otherplayerpaddlepos <= boxy + 20 then
Music.Sound (440, 50)
%yvelocity := -yvelocity
xvelocity := -xvelocity
if xvelocity > 0 then
xvelocity += 1
else
xvelocity -= 1
end if
if yvelocity > 0 then
yvelocity += 1
else
yvelocity -= 1
end if
end if
if 40 >= boxx and 20 <= boxx + 20 and playerpaddlepos + 80 >= boxy and playerpaddlepos <= boxy + 20 then
Music.Sound (440, 50)
%yvelocity := -yvelocity
xvelocity := -xvelocity
if xvelocity > 0 then
xvelocity += 1
else
xvelocity -= 1
end if
if yvelocity > 0 then
yvelocity += 1
else
yvelocity -= 1
end if
end if
else
if gameovermessage = "You win! Next level" then
for i : 100 .. 3000 by 100
Music.Sound (i, 50) % Sound note
end for
%restarts the game
boxx := midx
boxy := midy
boxy := midy
xvelocity := Rand.Int (-8 - points, 8 + points)
yvelocity := Rand.Int (-8 - points, 8 + points)
gameover := 0
%prevents sloooow moving balls
if yvelocity < 4 or xvelocity < 4 or xvelocity = 0 then
xvelocity := Rand.Int (-8 - points, 8 + points)
yvelocity := Rand.Int (-8 - points, 8 + points)
end if
else
for decreasing i : 2900 .. 200 by 100
Music.Sound (i, 50)
end for
%restarts the game
boxx := midx
boxy := midy
boxy := midy
xvelocity := Rand.Int (-8 - points, 8 + points)
yvelocity := Rand.Int (-8 - points, 8 + points)
gameover := 0
%prevents sloooow moving balls
if yvelocity < 4 or xvelocity < 4 or xvelocity = 0 then
xvelocity := Rand.Int (-8 - points, 8 + points)
yvelocity := Rand.Int (-8 - points, 8 + points)
end if
end if
end if
end loop
Tell me what you think, Any suggestions, And any ideas to fix the (few) bugs there are.
Thanks
~ReCreate
Sponsor Sponsor
D_homes
Posted: Mon Nov 09, 2009 8:41 pm Post subject: RE:Yet another Pong game, Complete, With Beeps, points and tone sweeps!
Great game considering its your first project.
I ran into trouble a couple of times where after a point is scored, the xvelocity = 0 so the ball just bounces up and down in a straight line. to prevent this you could use :
code:
if xvelocity >= 0 then
xvelocity += 1
else
instead of:
code:
if xvelocity > 0 then
xvelocity += 1
else
by adding the = sign you are saying if xvelocity is greater than/less than or equal to 0 then make it + 1
therefor you would never run into that glitch
ReCreate
Posted: Mon Nov 09, 2009 9:50 pm Post subject: RE:Yet another Pong game, Complete, With Beeps, points and tone sweeps!
Thanks!
I updated the first post now.
Edit: Oh crap I can't edit a post that's been replied to...
Well anyways, Here is the Updated version.
code:
/*
PONG By ReCreate
(yet another)Remake of the old game PONG
Made in about 2-3 hours total.
Why I made it? No reason really, Kind of a competition with someone I know who had to make one for a project.
*/
View.Set ("graphics,nobuttonbar")
var boxx, boxy, xvelocity, yvelocity, xupordown, yupordown, points, p2points : int
var gameover, font, playerpaddlepos, otherplayerpaddlepos, debug : int
var gameovermessage : string
const midx := maxx div 2
const midy := maxy div 2
var chars : array char of boolean
points := 0
p2points := 0
boxx := midx
boxy := midy
xvelocity := Rand.Int (-8 - points, 8 + points)
yvelocity := Rand.Int (-8 - points, 8 + points)
gameover := 0 %0 means game not over, 1 means it is
playerpaddlepos := 10
otherplayerpaddlepos := 0
debug := 0 %0 means not in debug mode, 1 means is in debug mode
if yvelocity <= 4 or xvelocity <= 4 or xvelocity = 0 then
xvelocity := Rand.Int (-8 - points, 8 + points)
yvelocity := Rand.Int (-8 - points, 8 + points)
end if
loop
Input.KeyDown (chars) %self explanatory
if chars ('r') then
%restarts the game
boxx := midx
boxy := midy
boxy := midy
xvelocity := Rand.Int (-8 - points, 8 + points)
yvelocity := Rand.Int (-8 - points, 8 + points)
gameover := 0
%prevents sloooow moving balls
if yvelocity <= 4 or xvelocity <= 4 or xvelocity = 0 then
xvelocity := Rand.Int (-8 - points, 8 + points)
yvelocity := Rand.Int (-8 - points, 8 + points)
end if
end if
if chars ('d') then %debug mode
if debug = 0 then
debug := 1
else
debug := 0
end if
delay (150)
end if
if debug = 1 then
put "Ball X velocity: " + intstr (xvelocity) + " Ball Y Velocity: " + intstr (yvelocity)
end if
if gameover = 0 then
%GAME HAS NOT ENDED!!!
if chars (KEY_UP_ARROW) then
if playerpaddlepos < maxy - 95 then
playerpaddlepos += 5
end if
end if
if chars (KEY_DOWN_ARROW) then
if playerpaddlepos > 0 then
playerpaddlepos -= 5
end if
end if
%finds is the box is out of the screen
if boxx < 0 then
gameovermessage := "You don't win. Still next level"
gameover := 1
p2points += 1
end if
if boxy < 0 then
%bounce!
yvelocity := -yvelocity
Music.Sound (440, 50)
end if
if boxx > maxx then
%you win
gameover := 1
gameovermessage := "You win! Next level"
points += 1
end if
if boxy > maxy - 20 then
%bounce!
Music.Sound (440, 50)
yvelocity := -yvelocity
end if
Time.DelaySinceLast (round (1000 / 30)) %delays to get 30 FPS
Draw.Cls () %clears the screen for this frame
put "Points: " + intstr (points) + " Points: " + intstr (p2points)
Draw.Line (midx, 0, midx, maxy, black)
%draws the ball
Draw.Box (boxx, boxy, boxx + 20, boxy + 20, black)
%moves the ball
boxx += xvelocity
boxy += yvelocity
%moves the other paddle
if boxy > otherplayerpaddlepos then
otherplayerpaddlepos += 3 + points
else
otherplayerpaddlepos -= 3 + points
end if
%collision checking
if 619 >= boxx and 599 <= boxx + 20 and otherplayerpaddlepos + 80 >= boxy and otherplayerpaddlepos <= boxy + 20 then
Music.Sound (440, 50)
%yvelocity := -yvelocity
xvelocity := -xvelocity
if xvelocity >= 0 then
xvelocity += 1
else
xvelocity -= 1
end if
if yvelocity >= 0 then
yvelocity += 1
else
yvelocity -= 1
end if
end if
if 40 >= boxx and 20 <= boxx + 20 and playerpaddlepos + 80 >= boxy and playerpaddlepos <= boxy + 20 then
Music.Sound (440, 50)
%yvelocity := -yvelocity
xvelocity := -xvelocity
if xvelocity > 0 then
xvelocity += 1
else
xvelocity -= 1
end if
if yvelocity > 0 then
yvelocity += 1
else
yvelocity -= 1
end if
end if
else
if gameovermessage = "You win! Next level" then
for i : 100 .. 3000 by 100
Music.Sound (i, 50) % Sound note
end for
%restarts the game
boxx := midx
boxy := midy
boxy := midy
xvelocity := Rand.Int (-8 - points, 8 + points)
yvelocity := Rand.Int (-8 - points, 8 + points)
gameover := 0
%prevents sloooow moving balls
if yvelocity < 4 or xvelocity < 4 or xvelocity = 0 then
xvelocity := Rand.Int (-8 - points, 8 + points)
yvelocity := Rand.Int (-8 - points, 8 + points)
end if
else
for decreasing i : 2900 .. 200 by 100
Music.Sound (i, 50)
end for
%restarts the game
boxx := midx
boxy := midy
boxy := midy
xvelocity := Rand.Int (-8 - points, 8 + points)
yvelocity := Rand.Int (-8 - points, 8 + points)
gameover := 0
%prevents sloooow moving balls
if yvelocity < 4 or xvelocity < 4 or xvelocity = 0 then
xvelocity := Rand.Int (-8 - points, 8 + points)
yvelocity := Rand.Int (-8 - points, 8 + points)
end if
end if
end if
end loop
D_homes
Posted: Mon Nov 09, 2009 10:09 pm Post subject: RE:Yet another Pong game, Complete, With Beeps, points and tone sweeps!
Nope, still happened again, keep in mind you need to adjust this part aswell.
code:
if 40 >= boxx and 20 <= boxx + 20 and playerpaddlepos + 80 >= boxy and playerpaddlepos <= boxy + 20 then
Music.Sound (440, 50)
%yvelocity := -yvelocity
xvelocity := -xvelocity
if xvelocity > 0 then
xvelocity += 1
else
xvelocity -= 1
end if
if yvelocity > 0 then
yvelocity += 1
else
yvelocity -= 1
end if
end if
ReCreate
Posted: Mon Nov 09, 2009 10:56 pm Post subject: RE:Yet another Pong game, Complete, With Beeps, points and tone sweeps!
Yes I forgot that... The New one.
code:
/*
PONG By ReCreate
(yet another)Remake of the old game PONG
Made in about 2-3 hours total.
Why I made it? No reason really, Kind of a competition with someone I know who had to make one for a project.
*/
View.Set ("graphics,nobuttonbar")
var boxx, boxy, xvelocity, yvelocity, xupordown, yupordown, points, p2points : int
var gameover, font, playerpaddlepos, otherplayerpaddlepos, debug : int
var gameovermessage : string
const midx := maxx div 2
const midy := maxy div 2
var chars : array char of boolean
points := 0
p2points := 0
boxx := midx
boxy := midy
xvelocity := Rand.Int (-8 - points, 8 + points)
yvelocity := Rand.Int (-8 - points, 8 + points)
gameover := 0 %0 means game not over, 1 means it is
playerpaddlepos := 10
otherplayerpaddlepos := 0
debug := 0 %0 means not in debug mode, 1 means is in debug mode
if yvelocity <= 4 or xvelocity <= 4 or xvelocity = 0 then
xvelocity := Rand.Int (-8 - points, 8 + points)
yvelocity := Rand.Int (-8 - points, 8 + points)
end if
loop
Input.KeyDown (chars) %self explanatory
if chars ('r') then
%restarts the game
boxx := midx
boxy := midy
boxy := midy
xvelocity := Rand.Int (-8 - points, 8 + points)
yvelocity := Rand.Int (-8 - points, 8 + points)
gameover := 0
%prevents sloooow moving balls
if yvelocity <= 4 or xvelocity <= 4 or xvelocity = 0 then
xvelocity := Rand.Int (-8 - points, 8 + points)
yvelocity := Rand.Int (-8 - points, 8 + points)
end if
end if
if chars ('d') then %debug mode
if debug = 0 then
debug := 1
else
debug := 0
end if
delay (150)
end if
if debug = 1 then
put "Ball X velocity: " + intstr (xvelocity) + " Ball Y Velocity: " + intstr (yvelocity)
end if
if gameover = 0 then
%GAME HAS NOT ENDED!!!
if xvelocity = 0 then
xvelocity := 1
end if
if chars (KEY_UP_ARROW) then
if playerpaddlepos < maxy - 95 then
playerpaddlepos += 5
end if
end if
if chars (KEY_DOWN_ARROW) then
if playerpaddlepos > 0 then
playerpaddlepos -= 5
end if
end if
%finds is the box is out of the screen
if boxx < 0 then
gameovermessage := "You don't win. Still next level"
gameover := 1
p2points += 1
end if
if boxy < 0 then
%bounce!
yvelocity := -yvelocity
Music.Sound (440, 50)
end if
if boxx > maxx then
%you win
gameover := 1
gameovermessage := "You win! Next level"
points += 1
end if
if boxy > maxy - 20 then
%bounce!
Music.Sound (440, 50)
yvelocity := -yvelocity
end if
Time.DelaySinceLast (round (1000 / 30)) %delays to get 30 FPS
Draw.Cls () %clears the screen for this frame
put "Points: " + intstr (points) + " Points: " + intstr (p2points)
Draw.Line (midx, 0, midx, maxy, black)
%draws the ball
Draw.Box (boxx, boxy, boxx + 20, boxy + 20, black)
%moves the ball
boxx += xvelocity
boxy += yvelocity
%moves the other paddle
if boxy > otherplayerpaddlepos then
otherplayerpaddlepos += 3 + points
else
otherplayerpaddlepos -= 3 + points
end if
Posted: Wed Nov 18, 2009 3:29 pm Post subject: Re: Yet another Pong game, Complete, With Beeps, points and tone sweeps!
Ah the beeps is so annoying yet good.
Perfect for 8-bit playing...
ReCreate
Posted: Sun Nov 11, 2012 10:42 pm Post subject: RE:Yet another Pong game, Complete, With Beeps, points and tone sweeps!
Whoah. To think. I made this when I was only fourteen? Now that's not impressive by most standards, it's certainly impressive by my own.
I managed this at only fourteen with absolutely no help at all, and yet I'm this complete rubbish today.
(and I'm sorry if this goes against some sort of bumping, or reviving old threads rule, I just needed to write this for the sake of archival on these forums as my program is archived)
Edit: uhh... is my avatar supposed to be that big?
QuantumPhysics
Posted: Mon Nov 12, 2012 6:46 pm Post subject: RE:Yet another Pong game, Complete, With Beeps, points and tone sweeps!
Turing is meant to be understood by preschoolers.
Yea, reviving is not allowed on this forums, I don't know why, but you gotta play by the rules or go back to school
ReCreate
Posted: Mon Nov 12, 2012 7:03 pm Post subject: RE:Yet another Pong game, Complete, With Beeps, points and tone sweeps!
I don't understand why you seem to be insulting my education, though. I am the same person as the OP, just three years of untreated depression have passed.
Anyways, Please pardon this revival, I won't do it anymore.
Insectoid
Posted: Mon Nov 12, 2012 7:16 pm Post subject: RE:Yet another Pong game, Complete, With Beeps, points and tone sweeps!
QuantumPhysics, there's nothing wrong with reviving your own thread, and the logic behind the game is language independent. There's no need to be a dick.
Tony
Posted: Mon Nov 12, 2012 7:18 pm Post subject: RE:Yet another Pong game, Complete, With Beeps, points and tone sweeps!
Woah, hostilities. Necroposting is frowned upon, legitimate thread revivals are okay.
Posting in old topics is generally frowned upon, unless the post is important, relevant or adds new content. If your post is important (for example, say you made a big improvement to an algorithm the original author was using), you may post in an otherwise dead topic. However, bringing up an old game from [Turing Source Code] to say, "Good job!" is necro posting, and you will be issues a warning.
I feel that OP reflecting on their previous work and progress made over the last 3 years is a valid update to this thread.
Posting in old topics is generally frowned upon, unless the post is important, relevant or adds new content. If your post is important (for example, say you made a big improvement to an algorithm the original author was using), you may post in an otherwise dead topic. However, bringing up an old game from [Turing Source Code] to say, "Good job!" is necro posting, and you will be issues a warning.
I feel that OP reflecting on their previous work and progress made over the last 3 years is a valid update to this thread.
I did not realize you are allowed to revive threads on certain condtions. I thought it was no reviving at all
Insectoid @ Mon Nov 12, 2012 7:16 pm wrote:
QuantumPhysics, there's nothing wrong with reviving your own thread, and the logic behind the game is language independent. There's no need to be a dick.
I was only sharing my opinion, just like mirhagk has the right to share his opinion on me.