Game menu

Started by
4 comments, last by Ezbez 16 years, 11 months ago
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...
Advertisement
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!



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.
Thank you both...
how can i load a bitmap file?
Hi,

Since you're just starting OpenGL, i highly recommend you to visit
Nehe's site and check out his tutorials.

best regards,
- Christoph -
Google? Seriously, there's a ton of information out there.

This topic is closed to new replies.

Advertisement