Simple Puzzle game with SDL

Anything related in any way to game development as a whole is welcome here. Tell us about your game, grace us with your project, show us your new YouTube video, etc.

Moderator: PC Supremacists

Post Reply
User avatar
Sanshin77
Chaos Rift Regular
Chaos Rift Regular
Posts: 160
Joined: Tue Mar 10, 2009 9:36 am
Current Project: C++/SDL engine, zaActionWizardMagic game
Favorite Gaming Platforms: Xbox 360, Playstation 2, Nintendo DS, mac and PC
Programming Language of Choice: C++

Simple Puzzle game with SDL

Post by Sanshin77 »

I just completed a very simple puzzle game with SDL in C++, and I'm kinda proud of it and want to show it off here. Note, I'm proud of the technical part, not the game design or art(Coz that's simple and crappy). I worked on it for maybe 2-3 nights(yeah, I don't work in daylight), and surprisingly I didn't bump into any bugs or memory leaks.

I'm also releasing the source, so if anyone wanna try building it or look at it, you're welcome. I tried doing some documentation along with the source, but I'm not good at it, at all. Any comments? Suggestions or ideas?

So here it is:


And you can download the source, the build and the project file (for mac) here:
http://www.filefront.com/15662339/zaCoins.zip

Game Instructions:

Code: Select all

-Controls:
	- WASD - Move selection
	- Space - Choose current coins
	- 1 - Simple Mode ( Green )
	- 2 - Hardcore Mode ( Red )
	- Q - quit
	- Enter - Keep playing ( After winning )

-Basics
The objective of the game is to score as many points as possible. The points are represented as a green or red bar in the bottom of the window.
The SImple Mode is the relaxed, no-brainer mode. The Hardcore Mode is a requires a little more thinking. You can switch mode any time during the game by pressing 1 or 2.
Every coin has a value from 0-3.The total value of the selected coins determines your score.
You move the selection with the WASD keys and choose the currently selected coins with the space button.
When you push the space button, the game rewards you with points, the bar in the bottom of the window stretches out and the coins disappear.
New coins then appear from the top of the window. 

-Simple Mode (Green)
Your objective is to get as high total value as possible. You select a maximum of 5 coins at the same time, both the red and green lines mark your selection. The bar in the bottom of the window is green.

-Hardcore Mode (Red)
Your objective is to get a total value as close to 6 as possible. You select a maximum of 3 coins at the same time, the red lines mark your selection. The bar in the bottom of the window is green

-Winning the game
You win the game when your score bar reaches the right end of the window(600).
When you win, all the coins disappear and your score slowly depletes. Press enter to keep playing. I have not created a representation for scores over 600.
Edit: Want to try compiling on windows? This download should give you all the necessary source files and graphics.
Last edited by Sanshin77 on Sun Mar 14, 2010 6:22 pm, edited 1 time in total.
Check out videos of my C++ games as well as my "Amateur Game Dev" series over at
My YouTube Channel: http://www.youtube.com/user/Zanchill
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: Simple Puzzle game with SDL

Post by Falco Girgis »

5 starred and favorited. It's looking pretty damn good. If I didn't have a huge test in an hour for a class that I've done nothing in, I would be playing it now. :(
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Simple Puzzle game with SDL

Post by eatcomics »

Playing it now :D I'll tell you more after I play :D

Dam didn't notice it was for Mac... Oh well sorry, I guess I'm not gonna be able to play, but looks awesome :D
Image
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Simple Puzzle game with SDL

Post by dandymcgee »

Cool. I would suggest using different colors or shapes though, as matching the lines up is really difficult to do with a time limit.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
Sanshin77
Chaos Rift Regular
Chaos Rift Regular
Posts: 160
Joined: Tue Mar 10, 2009 9:36 am
Current Project: C++/SDL engine, zaActionWizardMagic game
Favorite Gaming Platforms: Xbox 360, Playstation 2, Nintendo DS, mac and PC
Programming Language of Choice: C++

Re: Simple Puzzle game with SDL

Post by Sanshin77 »

dandymcgee wrote:Cool. I would suggest using different colors or shapes though, as matching the lines up is really difficult to do with a time limit.
You did look at the rules? I don't think it's hard, and you're not really supposed to match them(check the rules). It might be an idea, but it's really a pretty different type of gameplay then. Might be a good idea for zaCoins 2 :P although I'm not going to work on that right now.
eatcomics wrote:Playing it now :D I'll tell you more after I play :D

Dam didn't notice it was for Mac... Oh well sorry, I guess I'm not gonna be able to play, but looks awesome :D
I'm sorry, I don't use windows, at all. You can download the source and it's all in SDL and C++ so it shouldn't be hard to compile it, you might have to change the #include's.

I'll try putting together a windows build soon. :roll: 8-)
Check out videos of my C++ games as well as my "Amateur Game Dev" series over at
My YouTube Channel: http://www.youtube.com/user/Zanchill
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Simple Puzzle game with SDL

Post by eatcomics »

Sanshin77 wrote:
dandymcgee wrote:Cool. I would suggest using different colors or shapes though, as matching the lines up is really difficult to do with a time limit.
You did look at the rules? I don't think it's hard, and you're not really supposed to match them(check the rules). It might be an idea, but it's really a pretty different type of gameplay then. Might be a good idea for zaCoins 2 :P although I'm not going to work on that right now.
eatcomics wrote:Playing it now :D I'll tell you more after I play :D

Dam didn't notice it was for Mac... Oh well sorry, I guess I'm not gonna be able to play, but looks awesome :D
I'm sorry, I don't use windows, at all. You can download the source and it's all in SDL and C++ so it shouldn't be hard to compile it, you might have to change the #include's.

I'll try putting together a windows build soon. :roll: 8-)
Cool
Image
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Simple Puzzle game with SDL

Post by dandymcgee »

Sanshin77 wrote:
dandymcgee wrote:Cool. I would suggest using different colors or shapes though, as matching the lines up is really difficult to do with a time limit.
You did look at the rules? I don't think it's hard, and you're not really supposed to match them(check the rules). It might be an idea, but it's really a pretty different type of gameplay then. Might be a good idea for zaCoins 2 :P although I'm not going to work on that right now.
Wow I'm really sorry, I misunderstood the game play due to the highlighting lines being so hard to see in the video. I didn't read the rules because I didn't plan on playing it (for the sole reason of not having time at the moment to compile it for windows). Using shapes or colors would actually make this game quite a bit more difficult. :P
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
Sanshin77
Chaos Rift Regular
Chaos Rift Regular
Posts: 160
Joined: Tue Mar 10, 2009 9:36 am
Current Project: C++/SDL engine, zaActionWizardMagic game
Favorite Gaming Platforms: Xbox 360, Playstation 2, Nintendo DS, mac and PC
Programming Language of Choice: C++

Re: Simple Puzzle game with SDL

Post by Sanshin77 »

So, I tried putting together a windows build some time ago, but It didn't work, I had some problems with linking SDL and SDL_image.

If this isn't too much to ask, could someone try to compile it on windows, shouldn't be too problematic, just change the includes in Lib.h to the windows equivalients. Of course I can't force anyone to do this but I'm interested in getting a windows build for this, I'm terrible in other IDE's than XCode and my windows partition is messy, slow and almost filled.
Check out videos of my C++ games as well as my "Amateur Game Dev" series over at
My YouTube Channel: http://www.youtube.com/user/Zanchill
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Simple Puzzle game with SDL

Post by eatcomics »

Sanshin77 wrote:So, I tried putting together a windows build some time ago, but It didn't work, I had some problems with linking SDL and SDL_image.

If this isn't too much to ask, could someone try to compile it on windows, shouldn't be too problematic, just change the includes in Lib.h to the windows equivalients. Of course I can't force anyone to do this but I'm interested in getting a windows build for this, I'm terrible in other IDE's than XCode and my windows partition is messy, slow and almost filled.
If you're using SDL then yes I can, just uh, IDK give me the code, then I get you the executable somehow...
Image
User avatar
Sanshin77
Chaos Rift Regular
Chaos Rift Regular
Posts: 160
Joined: Tue Mar 10, 2009 9:36 am
Current Project: C++/SDL engine, zaActionWizardMagic game
Favorite Gaming Platforms: Xbox 360, Playstation 2, Nintendo DS, mac and PC
Programming Language of Choice: C++

Re: Simple Puzzle game with SDL

Post by Sanshin77 »

eatcomics wrote: If you're using SDL then yes I can, just uh, IDK give me the code, then I get you the executable somehow...
The link has always been in the original post :P
Sanshin77 wrote: I'm also releasing the source, so if anyone wanna try building it or look at it, you're welcome. I tried doing some documentation along with the source, but I'm not good at it, at all. Any comments? Suggestions or ideas?

So here it is:


And you can download the source, the build and the project file (for mac) here:
http://www.filefront.com/15662339/zaCoins.zip
Check out videos of my C++ games as well as my "Amateur Game Dev" series over at
My YouTube Channel: http://www.youtube.com/user/Zanchill
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Simple Puzzle game with SDL

Post by eatcomics »

oops my bad. I'll do that, then I guess I'll upload it somewhere and post the link here

Edit: I can't read any of the source files... they are a format that MSVc++ can't use... I guess I'll try setting up dev cpp it opened them fine

Edit x 2: I can't open it in devc++ or notepad++ sorry... Could you post the source here, or PM it to me?
Image
User avatar
Sanshin77
Chaos Rift Regular
Chaos Rift Regular
Posts: 160
Joined: Tue Mar 10, 2009 9:36 am
Current Project: C++/SDL engine, zaActionWizardMagic game
Favorite Gaming Platforms: Xbox 360, Playstation 2, Nintendo DS, mac and PC
Programming Language of Choice: C++

Re: Simple Puzzle game with SDL

Post by Sanshin77 »

eatcomics wrote:oops my bad. I'll do that, then I guess I'll upload it somewhere and post the link here

Edit: I can't read any of the source files... they are a format that MSVc++ can't use... I guess I'll try setting up dev cpp it opened them fine

Edit x 2: I can't open it in devc++ or notepad++ sorry... Could you post the source here, or PM it to me?
Try this download:(Should only include the files necessary for windows-compile)
http://www.filefront.com/15831639/zaCoinsWinSrc.zip/

What is the problem, can you expand the archive? can you see the files? They should be .cpp and .h files, if you see one or two hidden mac files, with different extensions, ignore them...(thumbs.db for instance). My project file won't work on windows, so you'll have to create a new SDL project, link to the proper libraries(SDL and SDL_image) and import my files.

I'll PM/email you tomorrow if that doesn't work...
Check out videos of my C++ games as well as my "Amateur Game Dev" series over at
My YouTube Channel: http://www.youtube.com/user/Zanchill
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Simple Puzzle game with SDL

Post by dandymcgee »

Sanshin77 wrote: What is the problem, can you expand the archive? can you see the files? They should be .cpp and .h files, if you see one or two hidden mac files, with different extensions, ignore them...(thumbs.db for instance). My project file won't work on windows, so you'll have to create a new SDL project, link to the proper libraries(SDL and SDL_image) and import my files.

I'll PM/email you tomorrow if that doesn't work...
You should really consider adding error checking, especially in places like this:

Code: Select all

Dead(false){
	if(pSource == NULL)
		pSource = loadSurface("Coin.png");
	if(pOne == NULL)
		pOne = loadSurface("One.png");
	
	Y = 0-pSource->h;  //POTENTIAL CRASH HERE
	Value = zaRandom(0, 3);
	
}
The commented line of code is accessing the height attribute of a (potentially) NULL reference. You should check whether or not the images were successfully loaded.

There are also some other major errors that need to be fixed. See example test run (unaltered code) below:
Image
Attachments
Error.png
(128.07 KiB) Downloaded 88 times
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
Sanshin77
Chaos Rift Regular
Chaos Rift Regular
Posts: 160
Joined: Tue Mar 10, 2009 9:36 am
Current Project: C++/SDL engine, zaActionWizardMagic game
Favorite Gaming Platforms: Xbox 360, Playstation 2, Nintendo DS, mac and PC
Programming Language of Choice: C++

Re: Simple Puzzle game with SDL

Post by Sanshin77 »

Yea.. I'm not really good on the error checking stuff, that's usually what I start doing when it actually crashes.(Which is a bad idea, I know)

Seems like I'll have to try seting up SDL and Dev-C++ properly then, to do some Windows testing and compiling... From that Image, it seems that it's not drawing the background, don't know why though... I get the exact same effect If I comment out:

Code: Select all

drawSurface(pBackground, 0, 0, pScreen);
I don't expect you to do the bug testing and fixing of my source though, so nevermind. I'll ask on this forum If I can't manage to setup SDL on my own.
Check out videos of my C++ games as well as my "Amateur Game Dev" series over at
My YouTube Channel: http://www.youtube.com/user/Zanchill
Post Reply