Have you ever thought about creating you’re own super classic mario game, or you’re own zelda series? Well, you’re dream has come true… with SFML you’re about to create you’re first game!! To make it easy I’ve chosen to recreate the well-known game Connect Four. Ready??… Go!!
Before starting the game development be sure to have :
- A ready-to-code IDE, configured for SFML.
- and : A well C++ understanding.
Let the coding start!!
There are two main ways of creating this type of games (board games).
- By drawing directly to the screen the components of the game (circles, lines, rectangles, etc).
- or, By using textures (images) and placing them on screen.
For the sake of this example, we’re using the first approach. We’ll be drawing a background color with circles. Three kinds of circles will make the whole : empty spaces, red tokens and yellow tokens. The outline of a winner combination (4 in a row) will be highlighted.
In the end, we’ll have a game like this:

Here you’ll find the Windows executable.
And here the complete sources, including a Code::Blocks Project.
The sourcecode is released under the zlib/png license.
To be continued…
Great tutorial, you should do another one!
Maybe you want to take a look at my game called Galactic Empire (http://freefile.kristopherw.us/uploads/alze/galactic_empire_1.11.7z) and give me some hints as how to seperate the code into separate classes and files. I’ve already done some work but I’m not sure if I’m doing it correctly, besides it’s a shitload of work
cheers
Thx!
And yeah, doing a game is never easy ^^ but in the end… satisfaction is your reward^^.
I’m certainly doing another one, but shh!! it’s top secret
I’ve already taken a look at your game and it looks really nice!
You can start by splitting your classes in different files. The class definition in a “ClassName.h” file and its methods in a “ClassName.cpp”. BTW you should forget about using global variables, they’re evil
Pingback: 2010 in review « Redkiing's Blog
Nice tutorial – I am currently working on some SFML tutorials on my own blog, and it’s always nice to come across a fellow SFML user