SDL main menu

Started by
0 comments, last by Nekotan 9 years, 4 months ago

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!

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

This topic is closed to new replies.

Advertisement