Sign in to follow this  
KaKaroTo

Game menu

Recommended Posts

i want to create a menu for my game... im programming in c++ using Opengl how can i open a BMP picture, to check if the buttons of the mouse were pressed, and what are the coordinates of the press? if anyone can add a program and/or explain to me how to do it I'll be greatful...

Share this post


Link to post
Share on other sites
Well there are probaly a good few ways of going about doing a game menu!

First way and probaly the easyist is just to draw some rectangles to the screen and texture them!

then get the mouse postion and make sure that its in the coords of the button
and then check to see if its pressed!

if your new to getting data from the mouse you can do this one of two ways first

you can just use win32 and GetMousepos()
then check to see if the mouse has been clicked with a

case WM_LBUTTONDOWN :

in your windows message loop!

something like this

switch(msg)
{
case WM_LEFTBUTTONDOWN:
//Get the mouse postion with GetMousepos()
//Then check to see if its in the area you want to use for a button
if(MousePosX < Button1PosX && MousePosY < Button1PosY && MousePosX +
Button1PosX > Button1PosX && MousePosY + Button1PosY > Button1PosY)
{
//Do what ever is need to change the look of the button and so on
}
break;
break;
}


A better way to do the mouse inputs would be to use DirectX.
There are some fine tutorials on GameDev here so i wont go into detail

The second method witch is also pritty easy is just to use Win32
you can graphicly change the buttons look althought it can some times be
abit of a challenge when your new to win32

These are not the only ways or might now even be the best but they should work.

Good luck if you need more help you may email me if you wish!



Share this post


Link to post
Share on other sites
I Don't exactly got you question.
But assuming win32 you can for example use the win32 api
say GetCursorPos and check if it is within the boundaries of each button.
Then you can use GetKeyState and check if the mouse buttons were pressed.

Hope this helps.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this