Jump to content
  • Advertisement
Sign in to follow this  
Elit3d

SDL main menu

This topic is 1414 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Are there any tutorials to show me how to go about making a main menu with buttons? For example, how to recognize where the mouse is so when the button is pressed, it will take me to my game.

 

Many thanks!

Share this post


Link to post
Share on other sites
Advertisement

I would just get the position values of the MouseEvent, if it is a DownEvent. ( http://wiki.libsdl.org/SDL_MouseButtonEvent?highlight=%28\bCategoryStruct\b%29|%28SDLStructTemplate%29 )

Then you could check it against the position of your buttons and if it is inside, activate it.

 

There is a more extensive tutorial at Lazy Foo:

http://lazyfoo.net/tutorials/SDL/17_mouse_events/index.php

 

I wouldn't do it that way, because you check for the current mouse position, when you handle the event and if are running slow, because you already had to handle many events, there can be some lag and the mouse position is off. That could lead to the user clicking the wrong button, altough it is hard to actually move the mouse that fast. I just don't think, that solution is "clean".

 

Good Luck,

Neko

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!