Public Group

Pong

This topic is 4771 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I have earlier programmed in Allegro and it was very easy, now I want to move up to something more professional, still crossplatform. I choosed OpenGL and it seemed hard. So, can i have the sourcecode for a Pong game, it would be helpful to se how input, processing, output and gamestates work, I think I can use a sourcecode to learn. Thanks!

Share on other sites
Allegro = all the things you just asked for
OpenGL = Open Graphics Library. It does graphics.

Look up SDL, which will do everything else :)

Share on other sites
:D So.. I cant handle input only using OpenGL?

Share on other sites
no. you can only handle graphics using OpenGL; hence the name, Open Graphics Language.

Share on other sites
Ok sorry.

if (keys[VK_RIGHT]){//Do stuff}

?

Found it in an NeHe guide...

Share on other sites
Quote:
 Original post by NeoecsOk sorry.But what aboutif (keys[VK_RIGHT]){//Do stuff}?Found it in an NeHe guide...

That's some Win32 input handling, not something provided by OGL.

Share on other sites
Ok, can I use that? I guess it wont work on other OS'es that Windows if i do? Is it fast? Is it good?

Share on other sites
lol, VK_RIGHT VK_LEFT, are winapi virtual keys, constants defined in the windows headers. if you were wanting to make a cross platform game you would have to make a generic interface to the input.

If your a making a pong game I wouldn't be worrying about portability, unless it's a next gen version.

Share on other sites
you are going to learn win32 programming in addition to opengl? as a beginner, might i suggest you try glut, freeglut or glfw ... all of which provide means for simple input handling (keyboard and mouse). that way you can learn opengl without worrying about the details of win32 programming... which in and off itself can be a daunting task for the 'young jedi in training'. others might suggest SDL, but as 'simple' as it is ... the others i mentioned are even easier to get up and running (assuming you know how to link in external libs and add a new header reference).

Share on other sites
Quote:
 Original post by NeoecsOk, can I use that? I guess it wont work on other OS'es that Windows if i do?

Bingo, got it in one. Works perfectly fine, but only on Windows as you guessed. You might want to look at SDL; It's cross platform, and has input handling, sound, and rendering (and can be used for window handling along with OGL for 3d). Alternately, Screwtape's suggestions are an excellent way to get yourself some simple input handling along with OGL.

• 22
• 10
• 19
• 15
• 14