Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / 2D (Retro) Pong - Uses the internal beep sounds and everything dewd

Author
Message
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 13th Dec 2006 23:23 Edited at: 13th Dec 2006 23:29
Yeah so, got interested in the internal sounds I just found out about that DBP allows you to make with the use of some kernel dll, so I wipped up a pong game. Tried to keep it as classic as possible, meh.



I know, theres 100's of pong games out there, ohwell, this one is one of the few that isnt a product of Chris K's "My First Pong Game" tutorial obviously.

It could definitely be more efficient/"green", but whatever, got bored, thar she is.

Oh, also, I made sure to program it so that pretty much everything is customizable, down to the speed/size of the paddles, the acceleration of the ball, etc, so adding things like powerups to change the paddle size, or to slow the enemy down, shouldnt be too hard to plug em' right in.

wildbill
18
Years of Service
User Offline
Joined: 14th Apr 2006
Location:
Posted: 13th Dec 2006 23:32
I wander how long the original code was for pong. In a assembly type language it must have been a hell of a accomplishment.
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 13th Dec 2006 23:38
Kind of depends, strip away all of the type declarations and variables from the code above, hardcode any needed values into the system, and with DBP you could easily get it in 10 lines uncompressed, but yeah Id imagine an assembly language would require quite a bit more.

TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 14th Dec 2006 00:16
I know you aren't a noob, so I have to ask...

Why do you create float variables and only put integers into them?

There's always the 'it ain't broken so don't fix it' point of view I know, but as an 'old-time' purist sort of programmer I wonder why so many coders do it. It's slower, uses more memory and even needs an extra character to be typed!

TDK_Man

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 14th Dec 2006 00:26 Edited at: 14th Dec 2006 00:26
I agree, but it allows for the possibility of floats, like for the paddle height, you might want to make a power up that slowly stretches the height of the paddle by .1 pixels each loop (ok, you cant have .1 pixels, bad example).

I usually only define variables as integers if Im absolutely sure I wont need them as a float some time later, like for the player score, I doubt I or anyone else would ever want a decimal for a player's score.

Like I said, theres a lot of things that could be tweaked to lower the lag, but its pong , doesnt really come with that much overhead .

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 14th Dec 2006 04:12 Edited at: 14th Dec 2006 13:38
<EDIT>

nevermind.

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 16th Dec 2006 05:36
Heres a better version, it has AI, more action in the ball control (meaning it takes on different angles depending on how you hit it/what direction (with a bit of randomness added in )) and... yep, thats it.



Switching back to co-op play isnt hard, just rem out the AI section and give the second player keystate values for their controls. Play around with the curvevalue settings to increase/decrease difficulty. ATM, I made the AI move back to midfield when the ball isnt on it's side, I know the classic didnt do that but I think it makes it a bit harder.

- RUC'

Lucifer
18
Years of Service
User Offline
Joined: 26th Dec 2005
Location:
Posted: 16th Dec 2006 21:24
Quote: "'it ain't broken so don't fix it'"


hahaha, that is always how i do things


i like furry jesus and sódóma just more than anything else..

Login to post a reply

Server time is: 2024-11-22 23:16:48
Your offset time is: 2024-11-22 23:16:48