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

Author Topic: Game menu  (Read 14925 times)

0 Members and 2 Guests are viewing this topic.

northLynx

  • Newbie
  • *
  • Posts: 9
    • View Profile
Game menu
« on: July 07, 2016, 05:35:27 am »
I want to make a game menu where it shows the intro then the screen starts going black and shows the main menu and the main menu shows play, settings, about and quit. Also, if the user enters settings or about they can go back to the main menu. Do I create a class with an enum that shows all the states and a stack instance in the private section followed by some functions that get current state and set any of state equal to one of them?

nicox11

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: Game menu
« Reply #1 on: July 07, 2016, 09:50:01 am »
Are you aware that there are multiple ways to develop functionality ? One will say your point of vue is right, another will say there is a better way to do it. Your question has thus no right answer.

What I can say, is that one of the most popular way to implement you game menu is the game state pattern :
http://gameprogrammingpatterns.com/state.html
« Last Edit: July 07, 2016, 10:01:17 am by nicox11 »

northLynx

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Game menu
« Reply #2 on: July 09, 2016, 01:15:02 am »
Ok thanks for the link it is useful. Is there any example online that can get me started and I mean a good example to look at that can give me a good idea of how the class should look like because the link is just explaining how it works with only partial code example.

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: Game menu
« Reply #3 on: July 09, 2016, 11:54:49 am »
The SFML Game Development Book covers both state stacks and UI elements. The source is here (and the book is well worth a read. There's 50% off the digital version).

koolboy_174

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Re: Game menu
« Reply #4 on: April 12, 2019, 06:53:52 am »
I also had a problem like this. I made a mini game but found difficult in creating a game menu. Did you completed it? Could you show me, please. your source code or a link, etc ... Thank everyone

Grenthal

  • Newbie
  • *
  • Posts: 20
    • View Profile
    • Email
Re: Game menu
« Reply #5 on: April 12, 2019, 09:22:14 am »
I also had a problem like this. I made a mini game but found difficult in creating a game menu. Did you completed it? Could you show me, please. your source code or a link, etc ... Thank everyone

Like it was mentioned previously, there could be lots of ways to implement this (nicox11 posted a very good article describing how it could be handled by using finite state machine).

If you would like see live code for further inspiration, feel free to browse through my long forgotten project (which is waiting for update and refactoring for a long time… ;) ) where I’ve handled menu by using FSM.

Link to repository: https://github.com/PawelWorwa/SFMLnake/tree/master/sources/states/menu