splash screen

Started by
12 comments, last by phil67rpg 11 years, 1 month ago

I want to add a splash screen to my game but this is new to me, I need a little help. I am making a breakout game using opengl and c++.

Advertisement

You need game states.

If this post or signature was helpful and/or constructive please give rep.

// C++ Video tutorials

http://www.youtube.com/watch?v=Wo60USYV9Ik

// Easy to learn 2D Game Library c++

SFML2.2 Download http://www.sfml-dev.org/download.php

SFML2.2 Tutorials http://www.sfml-dev.org/tutorials/2.2/

// Excellent 2d physics library Box2D

http://box2d.org/about/

// SFML 2 book

http://www.amazon.com/gp/product/1849696845/ref=as_li_ss_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=1849696845&linkCode=as2&tag=gamer2creator-20

is this code good for game states

class CGameState
{
public:
  void Init();
  void Cleanup(); void Pause();
  void Resume();

  void HandleEvents();
  void Update();
  void Draw();
};

It should be OK but, if I'm not wrong you need virtual keyword before void's :-)

how do I actually implement this code, I have 14 pages of code, where should I start

.

It should be OK but, if I'm not wrong you need virtual keyword before void's :-)

You only need virtual if you plan on overwriting the function in child classes. "void" works if you are not returning anything from a function.

how do I actually implement this code, I have 14 pages of code, where should I start

.

I am assuming you already have some game code? Perhaps a running game? Since you want to run the splash before opening any real window (assuming you are using a windowed design), you could just create a splash screen window that does not have any windowed effects (ie title bar, minimize button, close button) to show your splash screen, and while that is displayed, load your resources. When your resources are loaded, call the rest of your already established code, for instance your game window that does have a title bar and a close button.

With the structure you posted*, just put the splash screen code in your init() function, at the start, show a splash image, then start loading resources and data. When it finishes, start the game code.

* - edited

It should be OK but, if I'm not wrong you need virtual keyword before void's :-)

You only need virtual if you plan on overwriting the function in child classes. "void" works if you are not returning anything from a function.

This is not an accurate way of thinking about it. First you can overwrite a method in a child class without virtual, however to call it you must have a variable or pointer to the child class. Virtual is for polymorphism. If you wish to call a method on a parent class but have the method called for child class of the runtime type. To get this to work you must use the heap, and there for pointers, and inheritance.

If this post or signature was helpful and/or constructive please give rep.

// C++ Video tutorials

http://www.youtube.com/watch?v=Wo60USYV9Ik

// Easy to learn 2D Game Library c++

SFML2.2 Download http://www.sfml-dev.org/download.php

SFML2.2 Tutorials http://www.sfml-dev.org/tutorials/2.2/

// Excellent 2d physics library Box2D

http://box2d.org/about/

// SFML 2 book

http://www.amazon.com/gp/product/1849696845/ref=as_li_ss_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=1849696845&linkCode=as2&tag=gamer2creator-20

It should be OK but, if I'm not wrong you need virtual keyword before void's :-)

You only need virtual if you plan on overwriting the function in child classes. "void" works if you are not returning anything from a function.

This is not an accurate way of thinking about it. First you can overwrite a method in a child class without virtual, however to call it you must have a variable or pointer to the child class. Virtual is for polymorphism. If you wish to call a method on a parent class but have the method called for child class of the runtime type. To get this to work you must use the heap, and there for pointers, and inheritance.

I was thinking more along the lines of interfaces when Damian. mentioned virtual. You are right.

assuming you are using a windowed design

Forgot to mention:

If you are doing just a full screen game you don't need to create a new window/change styles, just draw the splash screen, handle loading, then clear the screen and start running/drawing your game.

thanks for all the help, I have a running game, let me work on this problem.

This topic is closed to new replies.

Advertisement