Ferrous Moon
http://www.ferrousmoon.com:80/forums/

First attempt at an SDL game...
http://www.ferrousmoon.com:80/forums/viewtopic.php?f=45&t=1783
Page 1 of 1

Author:  eddieringle [ Fri May 15, 2009 9:45 pm ]
Post subject:  First attempt at an SDL game...

So I have finished my first real SDL game (it is my first real C/C++ app as well) and I am just going to post it here in hopes that I get some suggestions.

I am planning on switching from SDL to OpenGL for rendering, and I want to know why the sound effect plays a bit too late. Other than that, I'm looking to others for suggestions.

EDIT:
The attached file is the OpenGL version, plus it has a few bugfixes. I removed the link to the old version.
EDIT2:
And another new version, this cuts off most of the fat due to the inclusion of unnecessary libraries. I also fixed the app config error in the Windows builds.
EDIT3:
Okay, _now_ that application configuration error is fixed. I blame Microsoft for distributing different versions of files.

Attachments:
pong-1.3.zip [1.12 MiB]
Downloaded 328 times

Author:  Vaius [ Sat May 16, 2009 1:26 am ]
Post subject:  Re: First attempt at an SDL game...

The link isn't working.

Author:  eddieringle [ Sat May 16, 2009 7:27 am ]
Post subject:  Re: First attempt at an SDL game...

Whoops, thanks for pointing it out. Fixed now.

Author:  Tycho [ Sat May 16, 2009 11:00 am ]
Post subject:  Re: First attempt at an SDL game...

Quote:
The source is included, as well as Windows and Linux builds:
http://files.idlesoft.net/dl.php?f=pong.zip
Your download script is buggy. It's calling it the MIME type "text/html", so I end up getting "pong.zip.html", which is fine, because I can just rename it to .zip, but I shouldn't have to.

Also, what is this? No Makefile?

Author:  Tycho [ Sat May 16, 2009 11:49 am ]
Post subject:  Re: First attempt at an SDL game...

Got it to compile on Mac OS X by downloading SDL, SDL_mixer, SDL_image, SDL_ttf, and some weird SDL_gfxPrimitives library, and then doing a hackish compile like this:
Code:
Alcarin:pong steven$ g++ -O2 -std=c++98 -Wall -Wunused -Wundef -pedantic -fno-strict-aliasing -I ../SDL_gfxPrimitives-1.5/ -I /Library/Frameworks/SDL.framework/Headers -I /Library/Frameworks/SDL_mixer.framework/Headers -I /Library/Frameworks/SDL_image.framework/Headers -I /Library/Frameworks/SDL_ttf.framework/Headers -framework AppKit -framework SDL -framework SDL_mixer -framework SDL_image -framework SDL_ttf -o linux/pong.mac ../SDL_gfxPrimitives-1.5/SDL_gfxPrimitives.c *.cpp SDLMain.m Paddle.cpp: In member function ‘void Paddle::handle_input()’: Paddle.cpp:46: warning: enumeration value ‘SDLK_UNKNOWN’ not handled in switch Paddle.cpp:46: warning: enumeration value ‘SDLK_FIRST’ not handled in switch Paddle.cpp:46: warning: enumeration value ‘SDLK_BACKSPACE’ not handled in switch Paddle.cpp:46: warning: enumeration value ‘SDLK_TAB’ not handled in switch Paddle.cpp:46: warning: enumeration value ‘SDLK_CLEAR’ not handled in switch Paddle.cpp:46: warning: enumeration value ‘SDLK_RETURN’ not handled in switch Paddle.cpp:46: warning: enumeration value ‘SDLK_PAUSE’ not handled in switch Paddle.cpp:46: warning: enumeration value ‘SDLK_ESCAPE’ not handled in switch Paddle.cpp:46: warning: enumeration value ‘SDLK_SPACE’ not handled in switch Paddle.cpp:46: warning: enumeration value ‘SDLK_EXCLAIM’ not handled in switch Paddle.cpp:46: warning: enumeration value ‘SDLK_QUOTEDBL’ not handled in switch Paddle.cpp:46: warning: enumeration value ‘SDLK_HASH’ not handled in switch Paddle.cpp:46: warning: enumeration value ‘SDLK_DOLLAR’ not handled in switch Paddle.cpp:46: warning: enumeration value ‘SDLK_AMPERSAND’ not handled in switch Paddle.cpp:46: warning: enumeration value ‘SDLK_QUOTE’ not handled in switch [... snip ...] Paddle.cpp:51: warning: enumeration value ‘SDLK_UNKNOWN’ not handled in switch Paddle.cpp:51: warning: enumeration value ‘SDLK_FIRST’ not handled in switch Paddle.cpp:51: warning: enumeration value ‘SDLK_BACKSPACE’ not handled in switch Paddle.cpp:51: warning: enumeration value ‘SDLK_TAB’ not handled in switch Paddle.cpp:51: warning: enumeration value ‘SDLK_CLEAR’ not handled in switch Paddle.cpp:51: warning: enumeration value ‘SDLK_RETURN’ not handled in switch Paddle.cpp:51: warning: enumeration value ‘SDLK_PAUSE’ not handled in switch Paddle.cpp:51: warning: enumeration value ‘SDLK_ESCAPE’ not handled in switch Paddle.cpp:51: warning: enumeration value ‘SDLK_SPACE’ not handled in switch Paddle.cpp:51: warning: enumeration value ‘SDLK_EXCLAIM’ not handled in switch Paddle.cpp:51: warning: enumeration value ‘SDLK_QUOTEDBL’ not handled in switch Paddle.cpp:51: warning: enumeration value ‘SDLK_HASH’ not handled in switch Paddle.cpp:51: warning: enumeration value ‘SDLK_DOLLAR’ not handled in switch Paddle.cpp:51: warning: enumeration value ‘SDLK_AMPERSAND’ not handled in switch Paddle.cpp:51: warning: enumeration value ‘SDLK_QUOTE’ not handled in switch [... snip ...] Paddle.cpp:59: warning: enumeration value ‘SDLK_UNKNOWN’ not handled in switch Paddle.cpp:59: warning: enumeration value ‘SDLK_FIRST’ not handled in switch Paddle.cpp:59: warning: enumeration value ‘SDLK_BACKSPACE’ not handled in switch Paddle.cpp:59: warning: enumeration value ‘SDLK_TAB’ not handled in switch Paddle.cpp:59: warning: enumeration value ‘SDLK_CLEAR’ not handled in switch Paddle.cpp:59: warning: enumeration value ‘SDLK_RETURN’ not handled in switch Paddle.cpp:59: warning: enumeration value ‘SDLK_PAUSE’ not handled in switch Paddle.cpp:59: warning: enumeration value ‘SDLK_ESCAPE’ not handled in switch Paddle.cpp:59: warning: enumeration value ‘SDLK_SPACE’ not handled in switch Paddle.cpp:59: warning: enumeration value ‘SDLK_EXCLAIM’ not handled in switch Paddle.cpp:59: warning: enumeration value ‘SDLK_QUOTEDBL’ not handled in switch Paddle.cpp:59: warning: enumeration value ‘SDLK_HASH’ not handled in switch Paddle.cpp:59: warning: enumeration value ‘SDLK_DOLLAR’ not handled in switch Paddle.cpp:59: warning: enumeration value ‘SDLK_AMPERSAND’ not handled in switch Paddle.cpp:59: warning: enumeration value ‘SDLK_QUOTE’ not handled in switch [... snip ...] Paddle.cpp:64: warning: enumeration value ‘SDLK_UNKNOWN’ not handled in switch Paddle.cpp:64: warning: enumeration value ‘SDLK_FIRST’ not handled in switch Paddle.cpp:64: warning: enumeration value ‘SDLK_BACKSPACE’ not handled in switch Paddle.cpp:64: warning: enumeration value ‘SDLK_TAB’ not handled in switch Paddle.cpp:64: warning: enumeration value ‘SDLK_CLEAR’ not handled in switch Paddle.cpp:64: warning: enumeration value ‘SDLK_RETURN’ not handled in switch Paddle.cpp:64: warning: enumeration value ‘SDLK_PAUSE’ not handled in switch Paddle.cpp:64: warning: enumeration value ‘SDLK_ESCAPE’ not handled in switch Paddle.cpp:64: warning: enumeration value ‘SDLK_SPACE’ not handled in switch Paddle.cpp:64: warning: enumeration value ‘SDLK_EXCLAIM’ not handled in switch Paddle.cpp:64: warning: enumeration value ‘SDLK_QUOTEDBL’ not handled in switch Paddle.cpp:64: warning: enumeration value ‘SDLK_HASH’ not handled in switch Paddle.cpp:64: warning: enumeration value ‘SDLK_DOLLAR’ not handled in switch Paddle.cpp:64: warning: enumeration value ‘SDLK_AMPERSAND’ not handled in switch Paddle.cpp:64: warning: enumeration value ‘SDLK_QUOTE’ not handled in switch [... snip ...] cc1obj: warning: command line option "-std=c++98" is valid for C++/ObjC++ but not for ObjC SDLMain.m:8:2: warning: #import is a GCC extension SDLMain.m:9:2: warning: #import is a GCC extension In file included from SDLMain.m:9: SDLMain.h:8:2: warning: #import is a GCC extension In file included from SDLMain.m:9: SDLMain.h:11: warning: struct has no named members SDLMain.m:10:2: warning: #import is a GCC extension SDLMain.m:11:2: warning: #import is a GCC extension SDLMain.m:68: warning: struct has no named members Alcarin:pong steven$
The SDLMain.m warnings are no fault of your own.

So it looks like as far as warnings go, you're just missing a 'default' case on your switch statements in Paddle.cpp on lines 46, 51, 59, 64 (something like 'default: break;' would silence it). So nothing really bad there.

Is your game supposed to have some sort of A.I. controlling the 2nd paddle?

Author:  eddieringle [ Sat May 16, 2009 2:40 pm ]
Post subject:  Re: First attempt at an SDL game...

No, haven't really looked into AI yet. Any pointers on how I can learn to do that would be nice. Although, I got really hooked on beating myself at one point...

And SDL_gfx is an external library that allows me to draw geometric shapes.

Author:  Tycho [ Sat May 16, 2009 10:00 pm ]
Post subject:  Re: First attempt at an SDL game...

SDL_gfx and SDL_gfxPrimitives are two different libraries.

Author:  eddieringle [ Sun May 17, 2009 5:57 pm ]
Post subject:  Re: First attempt at an SDL game...

Okay, updated the main post with the latest version.

Rendering is now done using OpenGL, but there is one bug in Linux. The Windows build works fine, but when you run the Linux build it will be obvious what is wrong. The quad that the text is textured onto is completely white, instead of blended like in the Windows build.

Author:  eddieringle [ Mon May 18, 2009 1:30 pm ]
Post subject:  Re: First attempt at an SDL game...

Also, the windows build runs fine on my home computer, but as soon as I run it at school it crashes and gives an application configuration incorrect error. Any ideas?

EDIT: Fixed.

Page 1 of 1 All times are UTC-05:00
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/