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

Author Topic: [Problem]Manage different screens in a game  (Read 8686 times)

0 Members and 1 Guest are viewing this topic.

beginner88

  • Newbie
  • *
  • Posts: 7
    • View Profile
[Problem]Manage different screens in a game
« on: June 21, 2009, 10:12:58 pm »
Hi,

I just did the very usefull tutorial to manage different screens in games (or sfml applications).
But something couldn´t be right in this tutorial, because I got a lot of errors, although I had copy&paste the whole code.

Ok, my project includes 4 header files and one main(cpp) file.
The header files are called screen.h, screens.h, screen_0.h and screen_1.h.
In the header file screens.h I included the basic class (in the header file screen.h) and the two other classes.
I think till now everything should be ok, but than there comes some strange things. For example, in the tutorial the basic class (in screen.h) is declared as
Code: [Select]
class cScreen
{
//...
};

and the main function says
Code: [Select]

std::vector<cScreen*> Screens;

Allright, but in screen_0.h "class screen_0" inherit from cScreen, but the author wrotes
Code: [Select]

class screen_0 : public Screen
{
private:
//...
};

As you can see is this a mistake.

But I fixed such mistakes, compiled the code and get errors like
Quote
error C2011: 'Screen': 'class' Typeredefinition

for the basicclass.
And for the code, where one class inherit from the basicclass
Quote
Basicclass undefined
.

Does anybody else this tutorial and got the same or similar problems?
I really got no idea what could be wrong with this code.
Would be really really nice if somebody could compile the code on his system and help me!
Thanks in advance!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
[Problem]Manage different screens in a game
« Reply #1 on: June 22, 2009, 12:15:44 am »
The error messages mostly state what you have done wrong - as here.

Type redefinition probably means you included the header twice. Header guards are able to prevent that. The other error refers to an undefined base class (how could it be else). Make sure the concerning class definition is made available before it is used.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

beginner88

  • Newbie
  • *
  • Posts: 7
    • View Profile
[Problem]Manage different screens in a game
« Reply #2 on: June 23, 2009, 04:05:04 pm »
Ok thx, I added include guards and can now run the program.
The bigger problem is, that the program doesn´t work like it should do.
That means that the menu isn´t working exactly (it doesn´t disappear when the game is starting) or I could finish the program about the menu.

I don´t now who else than me did this tutorial, because it would be really nice if another guy would send me an .exe file and the source from him, when it´s working on his system :)

 

anything