Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [Video Tutorial] Arkanoid in 160 lines - C++11 + SFML2  (Read 41614 times)

0 Members and 1 Guest are viewing this topic.

SuperV1234

  • SFML Team
  • Full Member
  • *****
  • Posts: 188
    • View Profile
Re: [Video Tutorial] Arkanoid in 160 lines - C++11 + SFML2
« Reply #30 on: May 14, 2015, 10:48:42 pm »
Thanks everyone for the feedback!

1) In Episode 2 (about Frametime and FPS) is there a benefit using std::chrono instead of sf::Time? I am researching about Game Loop and Game Time and I am still trying to find the best approach. BTW I really liked the Fixed time slice approach.

I don't think there is a particular benefit - I was trying to be as standard-compliant as possible and use modern STL features.



2) Based on Episode 5 (Game entity management basics) I wanted to make a space invaders clone.
I expanded the p9.cpp and created my game. The problem is that I haven't figured out how to create Entities in real time. For example when player presses the space bar, a bullets gets fired from player ship. (Maybe I need to brush up my C++ skills  :-[)

Create a function similar to `createBrick` and call it during your game loop - you can do it after spacebar is pressed, for example.



  • Base classes that aren't instantiated should be abstract, corresponding virtual member functions pure.
Classes that derive from abstract classes explicitly require to define the base class's abstract methods.
In my design, components can often have an empty `draw` or `update` implementation - forcing the derived type to implement an empty version of those methods is not something I want to do.



  • You could show std::make_unique() (C++14). emplace_back() with raw new
    is not exception-safe, leading to possible memory leaks. In general, I would avoid new where possible -- especially if you wrap the pointer in a smart pointer anyway.
This is correct - the `new` keyword should never be used (unless we're using "placement new").
Unfortunately the video is targeting the C++11 standard, so I can't use `std::make_unique` in it.



  • Calling a parameter mArgs is rather unusual; the "m" prefix is commonly used for members.
I've received the same feedback on my naming conventions before, and you're probably right - "m" could seem an abbreviation for "member".
The truth is that I'm really really used to this naming convention so it would take a lot of time and "find-replace regexes" to change it - I'll think about it.


  • You use both abs() and std::abs(), the latter is correct.
Correct, will fix this as well in the GitHub code.
« Last Edit: May 14, 2015, 10:55:16 pm by SuperV1234 »

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: [Video Tutorial] Arkanoid in 160 lines - C++11 + SFML2
« Reply #31 on: May 14, 2015, 10:50:50 pm »
The link doesn't seem to work. It comes up with a 404 this is not the page you are looking for.

SuperV1234

  • SFML Team
  • Full Member
  • *****
  • Posts: 188
    • View Profile
Re: [Video Tutorial] Arkanoid in 160 lines - C++11 + SFML2
« Reply #32 on: May 14, 2015, 10:56:11 pm »
The link doesn't seem to work. It comes up with a 404 this is not the page you are looking for.

What link?

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: [Video Tutorial] Arkanoid in 160 lines - C++11 + SFML2
« Reply #33 on: May 14, 2015, 10:57:19 pm »
Hi Vittorio,
thanks for the videos. Really enjoying folloing them  ;)

Thank you!



Update: I've finished writing the source code for part 4 of the tutorial.
Since I'll be busy this week it will take a while before I start recording.

The source code is available here. If anyone is not currently busy, I'd really like to hear some feedback on the code before I start recording, so that the quality of the final video could improve. Thanks!
This one. Sorry, I must have clicked on the wrong page.

SuperV1234

  • SFML Team
  • Full Member
  • *****
  • Posts: 188
    • View Profile
Re: [Video Tutorial] Arkanoid in 160 lines - C++11 + SFML2
« Reply #34 on: May 14, 2015, 11:02:45 pm »
Hi Vittorio,
thanks for the videos. Really enjoying folloing them  ;)

Thank you!



Update: I've finished writing the source code for part 4 of the tutorial.
Since I'll be busy this week it will take a while before I start recording.

The source code is available here. If anyone is not currently busy, I'd really like to hear some feedback on the code before I start recording, so that the quality of the final video could improve. Thanks!
This one. Sorry, I must have clicked on the wrong page.

Whoops - you're right. I've moved stuff around in the repository.
You can find "4_SmartPtrs" here:
https://github.com/SuperV1234/Tutorials/tree/master/DiveIntoC%2B%2B11

SuperV1234

  • SFML Team
  • Full Member
  • *****
  • Posts: 188
    • View Profile
Re: [Video Tutorial] Arkanoid in 160 lines - C++11 + SFML2
« Reply #35 on: June 02, 2015, 10:46:55 am »
I've published two new video tutorials on my YouTube channel.
The videos introduce a new series: "Dive into C++14".

Like the previous series, dedicated to the C++11 standard, "Dive into C++14" will show the convenience and power of the latest standard (C++14) through videos regarding various topics.

The format of the videos is what makes "Dive into C++11" and "Dive into C++14" different from other tutorials: well-commented and well-formatted independently compilable chronologically sequential code segments will show the audience the thought process behind writing modern C++14 code.

The first two videos are not really related to game development, but I find myself using the features/patterns described in them a lot for my game projects, so I hope they're not out-of-scope for the SFML forum.



* Dive into C++14 - [1] - Introduction to C++14 core language features



The first video is a brief introduction to some of my favorite new C++14 core language features.
It covers the following topics, using code examples:
    * Function return type deduction.
    * `decltype(auto)`.
    * Relaxed constexpr restrictions.
    * Variable templates.
    * Generic lambdas.

   The target audience is newcomers to the C++14 standard who already have some experience with C++11.



* Dive into C++14 - [2] - `for_each_argument` explained and expanded



The second video covers a very interesting code snippet originally posted on Twitter by Sean Parent: `for_each_argument`.
It shows and explains the usage of C++14 compile-time integer sequences, and analyzes a very interesting iterative implementation of an alternative version of Sean's function that takes the desired arity as a template parameter.

This tutorial video is a reviewed and improved version of my C++Now 2015 lightning talk ("`for_each_arg` explained and expanded").

Some possible use cases for the implemented functions are also shown and analyzed:
    * `make_vector(...)`
    * `forTuple` - iteration over tuple elements
    * `make_unordered_map(...)`

The target audience is people with knowledge of C++11 features and some C++14 experience.



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

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

You can find previous episodes here:
https://www.youtube.com/playlist?list=PLTEcWGdSiQenl4YRPvSqW7UPC6SiGNN7e