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

Author Topic: SFML Book/How to develop a NewPlaneState on Top of GameState  (Read 2795 times)

0 Members and 1 Guest are viewing this topic.

madcat

  • Newbie
  • *
  • Posts: 21
  • Creator of TacWars
    • View Profile
    • TacWars
SFML Book/How to develop a NewPlaneState on Top of GameState
« on: August 22, 2014, 11:34:38 am »
I was playing with the idea of implementing multiple lives in the game example developed in the book.
My idea was to add a new state NewPlaneState that will shortcut the controls of the GameState but animate the main plane into position.

The trouble I encounter is that this new state will have to access mPlane of World

Any idea about how to get about that in a clean fashion?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: SFML Book/How to develop a NewPlaneState on Top of GameState
« Reply #1 on: August 22, 2014, 01:35:40 pm »
The states described in the book aren't really made for lots of interaction between states/in-game states/cutscenes. It's more of an "absolute" state, e.g. a menu or the game with all its content and logic.

If you want to more use of cutscenes you might want to develop a different system or modify the current state system.
If you don't want to change anything, there's also the Context class with which you can pass data between states.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

madcat

  • Newbie
  • *
  • Posts: 21
  • Creator of TacWars
    • View Profile
    • TacWars
Re: SFML Book/How to develop a NewPlaneState on Top of GameState
« Reply #2 on: August 22, 2014, 06:21:35 pm »
Thanks for the quick answer  :D.

I was thinking about passing the World through Context to my stacked up NewPlaneState... but it smells a little bit of sulphur...

At the same time, I love the way the code keeps everything "light and tight" and doesn't overload a specific class. I don't want to suffocate the World class, yet again, a CutScene stack might be a way to handle the problem.

Well Thx again. Any architectural design tip is always welcome.


SeriousITGuy

  • Full Member
  • ***
  • Posts: 123
  • Still learning...
    • View Profile
Re: SFML Book/How to develop a NewPlaneState on Top of GameState
« Reply #3 on: August 25, 2014, 10:46:58 am »
Thanks for the quick answer  :D.

I was thinking about passing the World through Context to my stacked up NewPlaneState... but it smells a little bit of sulphur...

You're about right, this screams "sulphur" :D. This would couple the World class with all other States, not a wise thing to do in the presented architecture. World is only used inside the GameState and it should stay only there.

If you just want to "animate in" a new plane after the first is crashed, why not make use of the powerful command system to do so? The tools are all there, I leave the rest to yourself ;)