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

Author Topic: Switching 'scenes'  (Read 7583 times)

0 Members and 1 Guest are viewing this topic.

teunissenstefan

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: Switching 'scenes'
« Reply #15 on: August 19, 2014, 02:44:59 pm »
It was also useful for me and I also thanked you. Yet you're not glad it was useful for me  >:(

And there are many more ways to learn programming than reading books.
And I renamed everything correctly, 100% sure.

teunissenstefan

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: Switching 'scenes'
« Reply #16 on: August 20, 2014, 07:34:46 pm »
Okay fine, thanks for not even helping me anymore. Jesus, what a community...

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Switching 'scenes'
« Reply #17 on: August 20, 2014, 07:43:15 pm »
Okay fine, thanks for not even helping me anymore. Jesus, what a community...
Well. Your "I don't read books" and "I know how programming languages work." comments display a rather arrogant attitude which is not really conductive towards getting help.

C++ is a very large and very complex language. It takes years to get to even an intermediate level and to master it you can easily spend many more years. I personally treat anyone who claim 5 years or less experience with C++ as still being a relative newbie (maybe intermediate).

In any case. You could try to post the exact compiler output you get (along with compiler version and other relevant details).
You could also post a complete and minimal version of your code so we could take a look, run on our own machines, and help spot the problem.
You don't do any of those things.

Also remember that this is a web forum, not a telephone call. People are not sitting ready refreshing their browsers constantly, waiting to answer your questions. It may be days between when people check-in, so have some patience.
« Last Edit: August 20, 2014, 08:05:50 pm by Jesper Juhl »

MadMartin

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
Re: Switching 'scenes'
« Reply #18 on: August 20, 2014, 07:46:08 pm »
Okay fine, thanks for not even helping me anymore. Jesus, what a community...
What goes around comes around. You come here and demand help without giving necessary information. That is very bold, to say the least.

teunissenstefan

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: Switching 'scenes'
« Reply #19 on: August 20, 2014, 07:49:53 pm »
How about asking for information?
And at least now I got you people's attention again.

-
Displaying arrogant? That's an opinion because I don't think it displays arrogant at all, I'm just saying what my brain wants me to.
And what parts of the code should I upload? Because I have no idea what you want to look at then.

And the reason that I didn't give any info was because I'm fairly new to C++, and I thought that I might give you guys the wrong information. For example if I give you A, you need to see B
« Last Edit: August 20, 2014, 07:56:03 pm by teunissenstefan »

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Switching 'scenes'
« Reply #20 on: August 20, 2014, 07:57:26 pm »
Read these (don't worry, they are not books):

http://sscce.org/

https://github.com/SFML/SFML/wiki/FAQ#tr-grl-minimal

http://www.catb.org/esr/faqs/smart-questions.html

http://en.sfml-dev.org/forums/index.php?topic=5559.0

Regarding asking for information: you are the one who wants help. It's your responsibility to provide all details needed to help you and ask a good question. We are all volunteers and none of us have any obligation to help you. If you want help you need to help us help you.

teunissenstefan

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: Switching 'scenes'
« Reply #21 on: August 20, 2014, 08:03:49 pm »
I know what SSCCE is, I just can't do it.
And uhm they are going to be a bit more than 40 lines, so I put them on pastebin. (I hope it is allowed here)
OptionsMenuState.hpp http://pastebin.com/Lxt7BHdG
OptionsMenuState.cpp http://pastebin.com/JdN7iwCM
I removed everything that I thought was unnecessary.
« Last Edit: August 20, 2014, 08:09:47 pm by teunissenstefan »

teunissenstefan

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: Switching 'scenes'
« Reply #22 on: August 20, 2014, 08:12:24 pm »
Uhm I really have NO IDEA what i did, but it works now :|
Thanks for your help though.

firet

  • Newbie
  • *
  • Posts: 7
  • Gamedev, web dev and C++ programmer.
    • View Profile
    • Future Games official site
    • Email
Re: Switching 'scenes'
« Reply #23 on: September 03, 2021, 06:31:59 pm »
How do you switch 'scenes' in SFML? Example: From the menu to the game.
This is something that I have not seen anywhere :/
This is pretty simple, as long as the game/app isn't too insanely complex. Essentially the state of a program is stored in variables. So use a few to keep track of the scene:
int scene = 1; //Scene 1 is menu, 2 is game, etc. Only render certain things or run certain code/inputs if the scene is a certain integer. Example: only check for clicks on menu buttons if scene = 1.
bool running = false; //Only run the code for the primary game functions when running = true. This allows you to freeze the program.
bool reset = false; //You will see this later
 
In your main loop, on the game end, set running to false.
When the game starts, set running to true and scene to 2.
When you want to reset the game, set reset to true. Then you'll need an if statement, IN THE MAIN LOOP, like this:
if(reset == true)
{
    //Reset the game variables to their original values
    reset = false; //Make sure it doesn't reset every frame
}
 
Sorry if it's hard to understand, if you need help, just DM me and I can set up a tutorial.
Online I am: firet; flesheatindragon; Future Games.

 

anything