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

Author Topic: main menu  (Read 2463 times)

0 Members and 1 Guest are viewing this topic.

GrislyGames

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
main menu
« on: April 07, 2013, 09:20:25 pm »
So I've been trying to figure out how to make a main menu in SFML 2.0 c++. I'm new at programming with it (only been using it for about a month now) and I'm now trying to make a game which is very important to have a main menu in. I'm not sure whether I should just use bool variables or whether I should be doing something else ( I've tried with the bool variables and wasn't able to get it to work). Thank you for your time! :D

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: main menu
« Reply #1 on: April 08, 2013, 10:05:15 am »
If you're new to programming with C++ in general, I really suggest to get a good book an read it through. C++ is not a language you learn within a month or two.

A main menu can be implemented and many, many different ways. One popular is to use different states/screens. There are numerous tutorials on the internet, about game states etc, just google a bit. There's also one on the SFML wiki and I've created a SmallGameEngine based on a tutorial for SDL, but I used SFML.

In theory, a main menu can just be an image with a few buttons; you capture the mouse and/or keyboard input and give some visual feedback when the mouse is over a button or a button is selected.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

bumblecorn

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: main menu
« Reply #2 on: April 09, 2013, 05:03:32 pm »
A couple of nested if-statements for each button should do the trick. Super-pseudo-mode activate:

if (button contains mouse)
{
     Switch to highlighted state of the button

     if (mouse button is pressed)
     {
           do things
     }
}

 

anything