Well, the code of this page could have be better (as always in fact). There are two things that pop up to me. The first one, as you said, is about header/source file (i.e., .hpp/.cpp files). For example I would have split «screen_0.hpp» up this way :
Header (put in these kind of file the «definition»)
#ifndef __SCREEN_0__ // NEW
#define __SCREEN_0__ // NEW
#include <iostream>
#include "screen.hpp"
class screen_0 : public Screen
{
private:
int alpha_max;
int alpha_div;
bool playing;
public:
screen_0 (void);
virtual int Run (sf::RenderWindow &App);
};
#endif // NEW
Source (put here the «implementation»)
#include "screen_0.hpp" // NEW
screen_0::screen_0 (void)
{
alpha_max = 3*255;
alpha_div = 3;
<snip>
:
</snip>
//Never reaching this point normally, but just in case, exit the application
return (-1);
}
The second thing is about
readability and C-style VS C++-style. For example the author creates all his variables at the beginning of functions which is «bad». With C++ we create variables as late as possible. (The rule is : I need a variable NOW (not before) to store some data so I create it NOW (and not before)).
Another quesiton is, why I'm getting some errors, when trying to compile this program: http://www.sfml-dev.org/wiki/en/tutoriels/multiecransjeu_en?
I've made all the header files and .cpp file, copied (to test it, before applying to my own project) and tried to compile. I'm receifving these errors (guessing, that something is old in that code):
The code was designed to use an earlier version of SFML. Now SetBackgroundColor is Clear for example. There may be non-SFML related errors too. Nothing is perfect.