Sign in to follow this  
GamerCon

Allegro show_mouse() problem

Recommended Posts

GamerCon    144
I wrote a small game loop that just has a little checkbox and shows a mouse cursor. Unfortunately im getting "mouse droppings" on the box when it is unckecked. Ive used scare_mouse/unscare_mouse and currently using show_mouse(NULL) which fixed the problem of "mouse droppings" when the box was checked but not unchecked. The first thing the loop does is acquire the screen then show_mouse(NULL). Just before the buffer gets drawn to the screen I put show_mouse(buffer). after the buffer is drawn it gets cleared and the screen is released. thanks -GamerCon P.S. the game loop's source
    while(!key[KEY_ESC])
    {
        acquire_screen();
        show_mouse(NULL);
        rect(buffer,10,10,20,20,makecol(255,255,255));
        if(mouse_b & 1 && clickable)
        {
            clickable = false;
            if(mouse_x > 10 && mouse_x < 20 && mouse_y > 10 && mouse_y < 20)
            {
                if(!state)
                    state = true;
                else
                    state = false;
            }
        }
        if(!(mouse_b & 1))
        {
            clickable = true;
        }
        if(state)
            rectfill(buffer,12,12,18,18,makecol(255,255,255));
        show_mouse(buffer);
        blit(buffer,screen,0,0,0,0,800,600);
        clear_bitmap(buffer);
        release_screen();
    }

Share this post


Link to post
Share on other sites
smart_idiot    1298
Firstly, you want to show the mouse on the screen. It doesn't do a whole lot of good on a bitmap. Secondly, you want to scare the mouse whenever it's in the same place you're drawing something.

Unfortunately for you, since you're using double buffering, that's every frame, everywhere.

If you really want to stick with double buffering, you might want to simply skip show_mouse(), and instead just draw the cursor every frame yourself onto the buffer before you blit it to the screen.

Share this post


Link to post
Share on other sites
GamerCon    144
sigh...I did go that way but, in windowed mode, I like how the cursor isnt displayed on screen if the mouse is off screen.

I did get it to work by using tripple buffering i.e. the cursor was shown on a second buffer cleared to bright pink and drawn to first buffer using draw sprite. Although I doubt this is efficient considering some computers cant handle tripple buffering.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this