Pong game I made - source code inside

mrchimp

Newbie
Joined
Jul 19, 2003
Messages
1,928
Reaction score
0
As a bit of practice I decided to make a pong game in a graphics API called allegro I found in dev-c++'s packages. It's the first program I'v done that isn't command line based, although it's by no means the most complex.

It's not finnished yet, I plan on adding some sound and an AI that predicts where the ball is going to hit instead of just following it. I might even make it follow a couple of proggraming standards :upstare:

Tell you me what you think... or atleast have some kind of discusion, this forum is half dead compared to the other editing one's.

BTW allegro is great for noobs: http://www.talula.demon.co.uk/allegro/index.html
You don't have to deal with windows atall unless you want to, it does it all for you. If there's anyone who wants to make a small game but doesn't have the skill to use OGL or DX then this is a good alternative. Although the examples and some of the documentation is out of date.

The source code is inside the zip along with the exe.
http://homepage.ntlworld.com/j.palethorpe/pong.zip

I did try posting the code directly onto the page but it was too long. It would be helpfull if a mod posted it :thumbs:
 
not bad :)
That allegro thing looks a bit crap though, i recommend clanlib as a much better substitute. Check out www.clanlib.org :)
Is the movement time based? Nothing to suggest it is, unless allegro takes care of that for you. If not, you really need to make it time based, so I learned when my little test game ran at 2000fps on someone elses machine :D
 
The paddles need to move faster. I'd boost them myself but I don't have a compiler. :(
 
Sorry I renamed it so I could put it on the colledge computers.

Yes the paddle movement is time based, it uses interupt handlers and yes allegro is a bit crappy. I'v looked at clanlib before but it seemed a bit too complicated, I'v learnt much since then so i geuss I'll give it another go. I need to use alpha blending in my new game and allegro's being an arse wipe about it.

Varsity: everyone thinks there too slow except me, I'v probably being playing it too much myself ;)
 
clanlib isnt that complicated, once you get used to it it's great. of course you have to do a lot of things yourself, but still a nice framework to make a game on
 
OK, I read around and downloaded Dev-C++, and now I'm trying to get allegro up and running. I have the full source (all403.zip) and the binaries (all403_bin.zip), but I still need a C++ compiler. Dev-C++ doesn't feature in the readme and Borland Delphi 7 isn't going to be compiling C++ any time soon...what do I do from here?
 
OK, progress. I've downloaded allegro though the update interface. Now it recognises the allegro being called on the first line, but can't see the commands for it. There's a linker error for every one (install_allegro, set_color_depth and so on). What next?
 
Regarding this thread - Its under the HL2 Development section :p

However, if there is enough demand for a general coding, be it PHP, C++, Java, ASP.net, VB.net etc etc etc then we'll start a new forum for you lovely people.
 
Varsity said:
OK, progress. I've downloaded allegro though the update interface. Now it recognises the allegro being called on the first line, but can't see the commands for it. There's a linker error for every one (install_allegro, set_color_depth and so on). What next?

Are you trying to compile my source code? because if you are it would probably be best to make a new allegro project then add my source files too it.
 
I don't think there is any need for a general coding forum. I may however change the rules of this one to allow people to post general coding stuff, as I see no reason why we shouldn't. Carry on :)
 
mrchimp said:
Are you trying to compile my source code? because if you are it would probably be best to make a new allegro project then add my source files too it.
No use, same problem. I just don't think I installed allegro right.
 
OK, sorted. I had to add -lalleg to the linker paramaters.

Code:
void Input() //players input
{
    if (key[KEY_UP])
    {
        pPaddleSpeed = -2;
    }
    else if (key[KEY_DOWN])
    {
        pPaddleSpeed = 2;
    }
    else
    {
        pPaddleSpeed = 0;
    }
    
    if(twoP)
    {
        if (key[KEY_A])
        {
            cPaddleSpeed = -2;
        }
        else if (key[KEY_Z])
        {
            cPaddleSpeed = 2;
        }
        else
        {
            cPaddleSpeed = 0;
        }
    }
}

END_OF_FUNCTION(Input);

Much better! :) You could extend it into a rudimentary difficult level, with easier modes giving you more speed and the computer less.
 
I could do alot of things but I'm lazy :p

I'v been looking at some of the clanlib tut's and the API refference and I'm still not sure if it's really worth learning instead of just jumping in at the deep end and learning OpenGL.

I'v heard of SDL before but never looked into it.
 
well yes, you would need to know some opengl, but it's a great way to start. It handles a lot of things for you, well worth the effort in my opinion :)
 
I'v taken a look at SDL and it seems simpler to me and more like allegro, also it has dev-cpp support so I think I'll give it a go then move onto OGL.
 
In some ways it's too simple, after reading the API reference it seems very low level. I'm not sure what to go with now... does anyone know any alternatives?
 
Yes, what I miss most on SDL are functions to write text on the screen.
 
Back
Top