Help making a game menu.
How do I get started making a game menu.
I have the Image I want to use.
I am using directdraw for the gfx and using genaric windows input for the mouse.
can some one list the things that are needed to get started?
What I have came up with is.
1)load the image
2) find were the mouse pointer is at -> Not sure how to do this.
3) if you click or not.
4) check to see if you are in button area -> Not sure how to do this.
5) if mouse is in the button arrea then do something
Let me know what else that needs to be done.
I looked at the article about making a gui. But I am not using classes yet.
Quote:Original post by kingpinzs
1)load the image
Yep. You'll want to do that [smile]
Quote:
2) find were the mouse pointer is at -> Not sure how to do this.
You need to handle the WM_MOUSEMOVE message in your windows message handler.
Quote:
3) if you click or not.
Again you will want to handle a windows message, e.g. WM_LBUTTONDOWN.
Quote:
4) check to see if you are in button area -> Not sure how to do this.
Have a RECT that holds the screen boundaries of your menu entries and use
PtInRect to query which entry the cursor is hovering.
Quote:
5) if mouse is in the button arrea then do something
Exactly. [smile]
Quote:
Let me know what else that needs to be done.
I looked at the article about making a gui. But I am not using classes yet.
Your list pretty much sums up everything you'll need to get a menu working. You cn add things like changing the image/text colour of hovered entries, but that's just eye candy (though pretty standard).
You also don't need to use classes at all.
Good luck!
Pat.
My games typically have a single rendering function for the game.
However, when I add menus to a game, I put in what I call a "Screen" system.
Example:
RenderScreen()
{
if(!playing)
{ //draw menu stuff
}
else
{
//render game screen
}
}
No need for classes there. Instead of a "playing" variable, I use a global GAMESTATE variable (ex. pause = 15, playing = 10, initialization = 0, menu = 5, player dead = 99) and adapt my functions from there.
-Greven
-Greven
However, when I add menus to a game, I put in what I call a "Screen" system.
Example:
RenderScreen()
{
if(!playing)
{ //draw menu stuff
}
else
{
//render game screen
}
}
No need for classes there. Instead of a "playing" variable, I use a global GAMESTATE variable (ex. pause = 15, playing = 10, initialization = 0, menu = 5, player dead = 99) and adapt my functions from there.
-Greven
-Greven
can some one show me sample code about WM_MOUSEMOVE and how to use it to detirmin were the pointer is
int posX, posY LRESULT CALLBACK winProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam){ switch (uMsg) { case WM_MOUSEMOVE: posX = LOWORD(lParam); posY = HIWORD(lParam); return 0; case WM_DESTROY: case WM_CLOSE: case WM_QUIT: PostQuitMessage(0); return 0; } return DefWindowProc(hWnd, uMsg, wParam, lParam);}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement