Menu Screens
I am finished with my game, and I am interested in making a menu screen where you can choose "New Game," "About," "Controls," "Quit," etc. Would I need a switch to do that? I am not really sure how I would use the switch.
Thanks!
-Alex
I looooove programming! Even at my young age.
The way my game works is you have a main game loop which checks for windows messages, if there, it processes them, if not it continues, then it calls a procedure called Game_Main which occurs every loop iteration, does this make sense?
Well within my Game_Main procedure I have what in C you''d call a switch (I think) but I''m using assembler. Basically I have a variable called GameState which will change to a number of constant call GS_PLAY, GS_MENU, GS_EXIT, etc... so the procedure checks this variable and if it''s GS_PLAY it plays the game normally, if it''s GS_MENU it display''s the menu, if it''s GS_EXIT it clean''s up and quit''s. Obviously it''s a little more complex than that, but this should inspire you enough!
Hope this helped!
See ya,
Ben
Well within my Game_Main procedure I have what in C you''d call a switch (I think) but I''m using assembler. Basically I have a variable called GameState which will change to a number of constant call GS_PLAY, GS_MENU, GS_EXIT, etc... so the procedure checks this variable and if it''s GS_PLAY it plays the game normally, if it''s GS_MENU it display''s the menu, if it''s GS_EXIT it clean''s up and quit''s. Obviously it''s a little more complex than that, but this should inspire you enough!
Hope this helped!
See ya,
Ben
__________________________Mencken's Law:"For every human problem, there is a neat, simple solution; and it's always wrong."
"Computers in the future may weigh no more than 1.5 tons."- Popular Mechanics, forecasting the relentless march of science in 1949
"Computers in the future may weigh no more than 1.5 tons."- Popular Mechanics, forecasting the relentless march of science in 1949
Finally, someone with a game who wants to make a menu, as opposed to the other way around!
switch (someTypeOfInput) {
case 1: { //in case someTypeOfInput is equal to 1
quit();
} break;
case 2: {
options();
} break;
case 3: {
etc();
} break;
}
i hope that helps you somehow
If all these errors are so fatal, why am I still alive?
switch (someTypeOfInput) {
case 1: { //in case someTypeOfInput is equal to 1
quit();
} break;
case 2: {
options();
} break;
case 3: {
etc();
} break;
}
i hope that helps you somehow
If all these errors are so fatal, why am I still alive?
If all these errors are so fatal, why am I still alive?
Thanks! That helped a lot!
-Alex
-Alex
I looooove programming! Even at my young age.
Hey, a finished game! I''d like to see it. Do you have any screen shots or anything we can look at? Let us know, it''s exciting to see someone''s finished product!
Congrats on your accomplishment!
Torus
"Impressive!!!"
Congrats on your accomplishment!
Torus
"Impressive!!!"
"Impressive!!!"
Fresh Internet Business and Web Design
Fresh Internet Business and Web Design
Here''s my overkill method. I create a class called CScreen, which has virtual funcs like Tick() (called every frame), RestoreSurfaces(), etc., and there''s a global pointer to such a class that represents the current "screen". Every time the application does an action, the current screen does them too. There are several classes derived from it, like a CGameScreen or a CMenuScreen that override the virtual functions. So, you''d start out setting the pointer to a CTitleScreen, and then it would end and point the pointer to a CMenuScreen, and on and on. Very clean, but more code than it''s worth, maybe.
lntakitopi@aol.com | http://geocities.com/guanajam/
lntakitopi@aol.com | http://geocities.com/guanajam/
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement