• Advertisement
Sign in to follow this  

1st game with SDL engine (new and improved)- please take a look and comment

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there. I've been working on my SDL game engine for a couple of weeks now and I've just done my 1st game with it. It's actually mostly nicked from Cone's GFX with SDL tutorials...well except for the engine bit. I'd be really grateful if you'd take a look, have a play, look at the code and give me some feedback as to general design, things that need adding. Etc. I've got some of ideas about what to add, but it'd be nice to hear from the forum on this as well. Anyway the project is built with dev-c++ and can be found here if you fancy a go. Thanks. EDIT: Binary now included...just trying to save webspace..:) [Edited by - garyfletcher on April 26, 2005 12:57:37 AM]

Share this post


Link to post
Share on other sites
Advertisement
not to appear entirely too lazy, but is there any way we could get binaries?

Share this post


Link to post
Share on other sites
Sorry... dont got the SDL installed. So you have to compile it for me. Yeah yeah call me lazy. :P

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Nice looking code. Never compiled it or played it but its nice looking code....

Share this post


Link to post
Share on other sites
Cone3D Clickomania...

I was a bit confused as to how to play as some of the tiles seem to randomly change..... Well, congrats on going through a tutorial at Cone3D. You seem to have left a bunch of images that you don't use inside the zip from some of the other Cone3D tutorials. Now maybe you can develop your own game?

... Sorry... Because I think I seemed a bit harsh there, I've decided to help your out with the bandwidth situation. I've made a mirror of only the binary with SDL.DLL:
Binary + SDL.DLL.

Share this post


Link to post
Share on other sites
Thanks Rob.

Not being harsh at all. Used Cone's clickomania coz it seemed simple and wanted to test out the engine...see if I could put the theory into practise..:)

You don't really seem too impressed with the Cone's tutorials? It has been difficult finding decent tutorials on SDL. Am sure there are plenty out there though..and I've learned a lot goign thru Cone's. Am still planning to do the last one as well..:)

Thanks again.

Share this post


Link to post
Share on other sites
OK. I think I've sorted out the problem with random balls being deleted and I've added continuation options when a) no move are available and b) the board is cleared.

please take a look and let me know what you think.

Share this post


Link to post
Share on other sites
Looks very good! One suggestion might be the speed of those remaining balls dropping down. Maybe you could slow the dropping a bit. But it works great.

Share this post


Link to post
Share on other sites
If you're interested in some comments on the code, too, here are some things I noticed when looking over it:

* Your include guard in globals.h starts with a double underscore, which is not legal because these names are reserved for the compiler
* GameEngine.h has a lot of using statements sitting in the global namespace, thus pollute the same. This wouldn't be half as bad if your game had its own namespace.
* Another thing about globals.h, constants are usually preferred to #defines in C++
* Minor: A better name for FRAME_RATE might be FRAME_INTERVAL_MS
* The GameEngine is quite a specialized class just for this single game (e.g. you can't use it for another game), so I wouldn't say it's a game engine, but the ClickomaniaEngine or something like that ;)
* I would have written a helper function for obtaining the resolution in main() and constructed the GameEngine instance on the stack (you're using new, thus allocate on the heap)
* Instead of the catch(...) you could catch(const std::exception &e) and then display e.what() to obtain an understandable error message. Global catching of all exceptions tends to make debugging quite hard.

But all in all, it is well commented, you've got a consistent coding style and I can't spot any obvious bugs. Clearly one of the better examples on how to use SDL!

-Markus-

Share this post


Link to post
Share on other sites
Thanks for all the advice Cygon, and thanks for takign the time to go thru the code in such details.

Will change the gaurd name on the global.h and change my #defines (C hangovers) to const type name = <value> instead.

Am still a little hazy about definign my own namespace..in fact I haven't really got a clue so I will have to investigate that.

The Engine is a little engineered toward the current game. I am planning to move some of the GameEngine code, or at least make calls from the Exit and some other member functions to functions in main, to make it more generic. But aren't all/most engines are influenced by the game they are supporting.

Why create the Engine on the stack and not the heap. I'm not saying you're wrong but I'd just like to know why it would be better on the stack?

I know about the exception handling. I am playing to create an exception class, at some point. And hopefully intergrate some kind of exception saftey into my constructors.

Share this post


Link to post
Share on other sites
One thing I've noticed is that the mouse pointer disapears when using SDL_FULLSCREEN...anyone got any ideas?

Share this post


Link to post
Share on other sites
I have to ask.. what's with the vikings?
Nnice first game. Smooth movement would be nice though.

~zix~

Share this post


Link to post
Share on other sites
oh...the vikings directory is just a left over from when I was doing some sprite stuff with the code. I thought I'd removed it...hmmmmm!

Share this post


Link to post
Share on other sites
Very nice! I'm glad it all works [wink]. Now you should move on to that Lesson 6 and make a better version of that [grin]. Keep at it! I'll look though the source a bit later after all my finals are done to see if there are any needed imporivments.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement