|
mouse problems |
Money
Member #6,730
December 2005
|
why won't the mouse move?? #include <allegro.h> int main(){ allegro_init(); acquire_screen(); show_mouse(screen); } release_screen(); return 0; } |
miran
Member #2,407
June 2002
|
Throw out acquire_screen() and it will work. -- |
Money
Member #6,730
December 2005
|
thanks, i thought i need aquare screen so i can draw to the screen also, the mouse goes under the text, i need it to overlap the text |
ReyBrujo
Moderator
January 2001
|
Use a double buffer.
-- |
miran
Member #2,407
June 2002
|
Try this code:
EDIT: Göddämnít Rey, you type too fast. -- |
ReyBrujo
Moderator
January 2001
|
And Money, begin adding checks. Your program may crash and you will never find out why. -- |
Money
Member #6,730
December 2005
|
new game doesn't get highlightsed #include <allegro.h> int main(){ bmp = create_bitmap(640, 480); textout_ex( bmp, font, "New Game", 0, 0, makecol( 0, 155, 0), makecol( 0, 0, 0) ); show_mouse(bmp); if ( mouse_x >= 0 && mouse_x <= 50 && mouse_y >= 0 and mouse_y <= 20 ) textout_ex( bmp, font, "New Game", 0, 0, makecol( 0, 255, 0), makecol( 0, 0, 0) ); } } show_mouse(NULL); |
miran
Member #2,407
June 2002
|
Think a little bit about what your code does. -- |
ReyBrujo
Moderator
January 2001
|
Hehehe miran is right, you need to understand what you are writing. Note that you blit the bitmap on the screen and then highlight it. You should highlight it before blitting the bitmap on the screen. Go one line at a time, understanding what each does. -- |
Money
Member #6,730
December 2005
|
ok, got it thanks what does blitting a bitmap mean? |
ReyBrujo
Moderator
January 2001
|
Blit is basically copying. You copy every pixel of a memory bitmap onto the screen so that you can see it. Until you blit the bitmap, you won't see anything you have drawn on that determined bitmap. -- |
Money
Member #6,730
December 2005
|
oh, ok, thNks |
miran
Member #2,407
June 2002
|
Blit stands for Block Image Transfer. In simple terms it means copying a bitmap somewhere. The blit() function copies (blits) one bitmap on top of another. In your code you should draw all your graphics to the canvas buffer and then copy (blit) it to the visible screen. What you actually did was draw some of the gfx to the canvas, copy it to the screen, then draw some more. Which is wrong. EDIT: Yes, I type slower. Or maybe I just type more? -- |
Andrei Ellman
Member #3,434
April 2003
|
Also, don't forget to call install_timer() before you call install_mouse(). Allegro needs this if you want to display the pointer. AE. -- |
Don Freeman
Member #5,110
October 2004
|
You don't need to call install_timer() first because the manual states that the install_mouse() function calls it if not installed. I do suggest the following order though: allegro_init(); I install timer before keyboard even, because the keyboard was an interrupt driven device...I don't beleive it matters with allegro, but I've stuck with this all the same. -- |
Tobias Dammers
Member #2,604
August 2002
|
Don: I believe that this can get you into trouble on some windows platforms, since the w32 port needs a window (created by set_gfx_mode()) to process the keyboard and mouse messages. I could be wrong though. --- |
miran
Member #2,407
June 2002
|
The proper order should be something like this: allegro_init(); set_color_depth(BPP); set_gfx_mode(CARD,Width,Height,XWidth,XHeight); set_color_conversion(COLORCONV_TOTAL); install_keyboard(); install_mouse();
-- |
Evert
Member #794
November 2000
|
Quote: I believe that this can get you into trouble on some windows platforms, since the w32 port needs a window (created by set_gfx_mode()) to process the keyboard and mouse messages. I could be wrong though. Allegro already creates a window before you call set_gfx_mode(). It's somewhere outside the desktop area of the viewport though, so you never get to see it. That said, I think the Windows port delays the `real' initialisation of the keyboard and mouse code until after set_gfx_mode() is called. But calling the initialisation routines before then should be fine (I do it all the time and have never seen a problem myself). |
Matthew Leverton
Supreme Loser
January 1999
|
It is fine to initialize them before the graphics mode is set, but you cannot use them until after. The docs are quite clear on this, especially the example. |
|