Пример #1
0
void Button::handle_events(int flag)
{
    //The mouse offsets
    int x = 0, y = 0;
    bool quit= false;

    //If the mouse moved

    //If a mouse button was pressed
    if( event.type == SDL_MOUSEBUTTONDOWN )
    {
        //If the left mouse button was pressed
        if( event.button.button == SDL_BUTTON_LEFT )
        {
            //Get the mouse offsets
            x = event.button.x;
            y = event.button.y;


            //If the mouse is over the button
            if( ( x > box.x ) && ( x < box.x + box.w ) && ( y > box.y ) && ( y < box.y + box.h ) )
            {
                if (flag==0||flag==2)
                {
                    Mix_PlayChannel( -1, button, 0 );
                    SDL_Delay(500);
                    SDL_Quit() ;
                }

                else if(flag==1)
                {
                    Mix_PlayChannel( -1, button, 0 );
                    SDL_Delay(500);
                    dino_main();
                }

            }
        }
    }


    //If a mouse button was released
    /*if( event.type == SDL_MOUSEBUTTONUP )
    {
        //If the left mouse button was released
        if( event.button.button == SDL_BUTTON_LEFT )
        {
            //Get the mouse offsets
            x = event.button.x;
            y = event.button.y;

            //If the mouse is over the button
            if( ( x > box.x ) && ( x < box.x + box.w ) && ( y > box.y ) && ( y < box.y + box.h ) )
            {
                //Set the button sprite

            }
        }
    }*/
}
Пример #2
0
int
main (int argc, char *argv[], char *envp[])
{
  exit (dino_main (argc, argv, envp));
}