![]() |
|
help with main menu |
Money
Member #6,730
December 2005
![]() |
hey, why doesn't the mouse show up?
this is the code for main.h
|
BrknPhoenix
Member #7,304
June 2006
|
You put the mouse on the buffer but as far as I can see, at no time after that did you draw the buffer back onto the screen. |
Kitty Cat
Member #2,815
October 2002
![]() |
For one, you're calling acquire_screen then doing non-screen-related things (and not calling release_screen). Second, you're showing the mouse on an off-screen buffer. Third, you have a non-inlined function in your header. Unrelated, but important. The actual problem is that you draw the buffer to the screen once, before showing the mouse on it, then never again. readkey() is blocking, so you can't draw the buffer afterward. You should make a loop that always cycles (eg. while(1) { /* code here */ } after initializing everything. When you draw, clear the buffer, draw to the buffer instead of the screen, then use blit()] to copy the buffer to the screen. To show the mouse, use draw_sprite() to draw mouse_sprite onto the buffer right before blitting to the screen. -- |
emprog m
Member #5,886
May 2005
|
[EDIT] I don't see why it should. Why don't you update everything to the buffer and display that? For example.. int main( ) { //initialization stuff BITMAP *buffer = create_bitmap( 640, 480 ); while(!key[KEY_ESC]) { //update buffer with menu stuff here show_mouse(buffer); //show buffer to screen here? } destroy_bitmap(buffer); return 0; }END_OF_MAIN() Also, don't forget to deallocate your buffer. Hope this helps. Erick |
Money
Member #6,730
December 2005
![]() |
i got flickering and it still didn't show, the mouse i mean |
emprog m
Member #5,886
May 2005
|
try this..
|
Kitty Cat
Member #2,815
October 2002
![]() |
Don't use show_mouse on an off-screen buffer. Especially a memory bitmap. And you don't need to use acquire_release_screen when you're only doing one thing to the screen. -- |
Money
Member #6,730
December 2005
![]() |
how can i do a quick small menu like that one, but use the keyboard instead of te mouse, just, i want for the user to press down and an action occurs for a game menu with the keyboard, couldn't i do something like switch(menu) |
CursedTyrant
Member #7,080
April 2006
![]() |
Yes, you could. You would have to make an int/short Menu() function that returns the user's choice. --------- |
Money
Member #6,730
December 2005
![]() |
well how would i make the menu items correspond to a menu umber, like "new game" would be enter to one or something, i dont really know how to implement this |
CursedTyrant
Member #7,080
April 2006
![]() |
Simple example:
--------- |
Money
Member #6,730
December 2005
![]() |
o, i tried something on my own, but its not working right, i tried drawing to the screen, but still the highlighter wouldn't move, but when i try to use the buffer, either the program crashes or the start game and exdit doens't show
|
Jonatan Hedborg
Member #4,886
July 2004
![]() |
You create the bitmap before you initialize that graphics mode. that will not work. You also never actually draw the buffer to the screen any where in your loop. And there will be now way to select option 0 once you pressed down once. To draw something to the screen, you typically do (once per "round" of your loop): 1. Clear the buffer Right now, all you are doing is step 2.
|
Money
Member #6,730
December 2005
![]() |
i did that globally cause it says buffer undeclared, so i declared buffer globally, but you said i coudn't do it |
CursedTyrant
Member #7,080
April 2006
![]() |
You can declare the buffer globally, but not create a BITMAP. BITMAP *buffer; int main() { allegro_init(); set_color_depth(desktop_color_depth()); set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 640, 480, 0, 0); buffer = create_bitmap(SCREEN_W, SCREEN_H); clear(buffer); allegro_exit(); return 0; }
--------- |
Money
Member #6,730
December 2005
![]() |
oh man, i've been sitting here for like an hour tring to figure this out, i got the buttons to work fine, but now i can't get the input part, right, i've tried different things and don't see how to fix it, i think i know what the prob is, i was thinking so hard to fix it, but didn't have a clue, i think it'd be easier to use a switch case in this..."case" but i don't know how to implement that in my code
|
CursedTyrant
Member #7,080
April 2006
![]() |
Easier? No. Different.
--------- |
Money
Member #6,730
December 2005
![]() |
if you compiled my previous code, you'd see that once ypou press down, it highights exit, but when you let go of down, it goes back to start game, how do i make it so that when you press down it stays there, and i wanted to edit my code, not add in new, cause i kinda don't understand it that way, just tell me what to do and why its doing it like that |
CursedTyrant
Member #7,080
April 2006
![]() |
Because: while ( !key[KEY_ESC] ) { menu(); //display main game menu draw_sprite(screen,buffer,0,0); } void menu(void) { int menu_choice = 0; } Make the menu_choice global, initialize it once outside of the loop, and change the values inside the loop. --------- |
Money
Member #6,730
December 2005
![]() |
i ...do not understand sigh you said change the valuies to what, i just don't understand, stuff like this jsut makes me want to quit progrmaming forever |
CursedTyrant
Member #7,080
April 2006
![]() |
Sorry, I was focusing on the menu() function and I forgot you're looping it.
It doesn't get much simple than that. --------- |
Money
Member #6,730
December 2005
![]() |
umm, did you even try to compile that? nothing happens, i don't even see anything hightlighted that code doens't work sobs |
CursedTyrant
Member #7,080
April 2006
![]() |
Because you have to write it yourself. I've written what has to be written, and you can insert the code for starting/exiting/highlighting yourself... but in case you're too lazy:
This time it's tested. --------- |
Money
Member #6,730
December 2005
![]() |
thank you so much for your help, im such a noob, i jsut need a little guidance |
CursedTyrant
Member #7,080
April 2006
![]() |
"A little" is not a good way to put it. You have a lot to learn. But then again, we all started like that, so no need to discourage yourself... I spent 3 hours today trying to figure out what was wrong in my game, only to find out that it was just a misplaced line of code. --------- |
|