Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 26 Jun 2011
Offline Last Active Aug 30 2015 05:55 AM

#5117159 [Video Tutorial] Arkanoid in 160 lines - C++11 + SFML2

Posted by on 15 December 2013 - 02:13 PM

I've uploaded the third episode of "Dive into C++11" on my YouTube channel.

Video || Playlist

In this episode we'll take a break from game development to delve into C and C++'s memory and lifetime management. We'll talk about automatic variable lifetime, pointers in general and dynamic memory allocation.

The intended audience for this tutorial/screencast are people who have some experience with C++ in general, and who watched the previous episodes. This episode may be very interesting for those with experience with C++ who want to learn more about variable lifetime and memory management.

I greatly appreciate comments and criticism, and ideas for future videos/tutorials.

Feel free to fork/analyze the source code at: https://github.com/SuperV1234/Tutorials

#5113452 [Video Tutorial] Arkanoid in 160 lines - C++11 + SFML2

Posted by on 01 December 2013 - 05:02 AM

Thank you Goran for the interesting feedback. I'll reply to every single point.

"testCollision" is a very poor name for a function that does much more: You're not just testing if a collision occurred; You're modifying game state, and this should be reflected in the function name.

You're right - `testCollision` is a misleading name. I'll address this in a future video.

The erase + remove_if + lambda combo used to remove destroyed bricks is a good showcase of new C++ 11 features, but I think you overstate the performance aspect: At most, you can remove 3 bricks at the same time (and that would be an extremely rare event), so the "block remove" optimization features offered by erase are basically irrelevant here.

True, the performance aspect may be irrelevant in a game like this one, but it's still the way to go, in my opinion. It's a scalable approach that works with any type of game: what if an user tries to make a shoot'em'up game after watching the tutorial? Erase-remove_if will work great.

The whole "frame time" segment should have been left out, in my opinion, because, as you yourself explained, it leads to a pretty absurd situation, where a slower machine has to do more work, so ... Is that really a solution?

If you are referring to the part before the "time slices": I included that part to show the train of thought that brought me to using slices.
If you are referring to "time slices" themselves: it's not "a solution", but it's the "best solution", in my opinion. It has been used a lot in the past, and even if there are some drawbacks it's a lot better than scaling movements/actions with frametime.
Take a look at these links for more information:

I don't see the point of replacing the content of main with Game::run. That seems like needless indirection.
It's good to have a Game structure that encapsulates your gamestate, but there's no reason why your high-level flow can't stay in main.

As I said in the video, it's not a global solution, but it's what works for me. I like my code to be as structured and abstracted as possible.
While having a `Game::run` may be totally unnecessary for an Arkanoid clone, I was going for a more scalable approach: the `Game` class design works well in larger games (especially when dividing the `Game` class itself in `GameWindow` and `GameState`).

Thanks again for the criticism. I really enjoy reading other people's opinions and improving my videos/knowledge.
Also, your YouTube videos are really interesting! smile.png

#5113076 [Video Tutorial] Arkanoid in 160 lines - C++11 + SFML2

Posted by on 29 November 2013 - 03:54 PM

I've uploaded the second episode of "Dive into C++11" on my YouTube channel.

Playlist: http://www.youtube.com/playlist?list=PLTEcWGdSiQenl4YRPvSqW7UPC6SiGNN7e
The video is quite long - if you want to skip to the parts you may find most interesting, here's a schedule:


0:00 - constexpr addendum
3:20 - uniform intialization syntax addendum
10:10 - 1st segment (const-correctness, noexcept, event polling)
19:40 - 2nd segment (FPS and Frametime management)
34:15 - 4th segment ("time-slicing" for consistent logic with any FPS)
45:10 - 5th segment (refactoring)

In this episode we will learn more about two previously mentioned new awesome C++11 features: "constexpr" and "uniform initialization syntax".
Most importantly, we will also deal with a very big issue that every game developer must face: FPS/frametime, and how to avoid the game from behaving differently on slower/faster machines. 
In addition, we'll also briefly learn about "const-correctness" and using the "noexcept" keyword.
We will analyze the "time-slice" method to allow the game to run smoothly and consistently on every machine.
In the last code segment, we will also "refactor" our code by creating a `Game` class, making our source much easier to read and maintain.
I greatly appreciate comments and criticism, and ideas for future videos/tutorials.
Feel free to fork the game's source code at: https://github.com/SuperV1234/Tutorials

#5111660 [Video Tutorial] Arkanoid in 160 lines - C++11 + SFML2

Posted by on 24 November 2013 - 02:26 PM

Hello gamedev.net! 

I've created a 40 minutes tutorial/screencast on the creation of a complete game using C++11 and SFML2.
The end result is a playable Arkanoid/Breakout clone with a paddle, a ball and destroyable bricks.

This is my first attempt at a complete C++11 game development tutorial.
I divided the code in 9 segments, that I analyze and execute individually. 

The video is aimed at people with at least a basic knowledge of C++. 
Having some knowledge about common game development concepts will also greatly help.

The point of the video is showing how easy it is to create something playable thanks to the new standard and to SFML2, and to show a possible train of thought that can be taken during game development.

Watch it here:

I greatly appreciate comments and criticism, and ideas for future videos/tutorials.

Also, feel free to fork the game's source code at:
and expand upon it: if people like the idea I will feature the best forks in a future video  

For other tutorials: http://vittorioromeo.info/tutorials.html - or just browse my YT channel.

Thanks for your attention!

#5030084 [Video Tutorial] Solving the "crack" collision problem (getting stuck...

Posted by on 08 February 2013 - 08:39 AM

Hello gamedev, I made a video tutorial on how to solve a common problem encountered in 2D collision detection and resolution.
The issue often happens when your physical bodies live in tile-based environments. Sometimes the order in which the collisions are resolved is incorrect, and the physical body gets stuck between two tiles.
I've discovered two interesting ways to prevent (and fix) the issue, and I've created a tutorial video:


Video description:

Foreword: this is my first time doing a video tutorial. Please excuse me for any mistake, or if the explanation wasn't clear. I've also had some technical difficulties - my microphone is broken, and my webcam has a very poor quality. I recorded the tutorial (both audio and video) using my iPhone 4S. Unfortunately the quality of the markers I'm using is also poor - they're old and I couldn't find anything better, but I will buy some better markers tomorrow.
You can see an EXPERIMENTAL implementation of the merging method here:https://github.com/SuperV1234/SSVSCollision[3]
Additional information: I've already written an article about collisions. It's outdated, but some concepts can be easier to understand in the article. I talk about spatial hashing and "overlap area" sorting, albeit in a different (and less elegant) way. If you need more info on what I'm talking about in the video, the article would be a good place to start.
When I have time, I'll update the article and put it in my website. (http://http://vittorioromeo.info/[6] )
Please let me know if you need anything explained in the comments - and if you have suggestion on how I could record audio/video in a better way.
Thanks for watching.

#4990762 New to C++ from C#, is my pointer usage correct?

Posted by on 16 October 2012 - 09:33 AM


I've started learning C++ and wanted to make sure I'm not doing anything wrong. I've designed a very simple component-based entity system intended for game development.

An EntityManager manages pointers to Entity objects, and an Entity manages pointers to Component objects.

Game behavior is written by having classes that inherit from Component and override its methods.
The compiler was complaining about not having a virtual destructor in Component and I added one.

The Factory class is supposed to be an easy way to create Entity objects with preset component combinations.

This system is obviously not ready for game creation and missing many features, but the main point here is my memory management and pointer usage.

Is this the correct way to do it? What would you change?
Sorry if this is an unusual/uninteresting post, but I want to make sure I learn good practices from the beginning. Thanks for the help

#4969454 Articles on 2d collision detection and resolution

Posted by on 14 August 2012 - 07:43 AM

Hello gamedev!

I just started a new blog where I can share my experiences as a novice game developer.

My first article is about the creation of a physics engine, how my initial project failed, how the engine worked, and how I managed to salvage it and create something useful.

I wrote this article for every starting game developer out there - it deals with technical problems in collision detection, and design problems such as "reinventing the wheel".

It is divided in two parts: the first one deals more with my experience and with the problems a game developer faces in designing a physics engine, the second one (the most useful) explains how my collision detection and resolution works, along with videos, diagrams, .gifs from my project and source code analysis.


Hope you find it interesting and useful, considering many questions nowadays are about collision detection.
Check it out!: D