Mouse::~Mouse()
{
    if (m_Cursor != nullptr)
    {
        SDL_SetCursor(SDL_GetDefaultCursor());
        SDL_FreeCursor(m_Cursor);
    }
}
Exemple #2
0
void Game::OnLoop()
{
    //Gets the start ticks
    OnStartup();

    //Set default cursor every frame
    SDL_SetCursor(SDL_GetDefaultCursor());


    if(LeftButtonPressed == true)
    {
        Map1.building = true;
    }

    //Caps the frame rate depending on the ticks that have past
    FrameRate(FPS);
}
Exemple #3
0
void Game::OnLoop()
{
    //Gets the start ticks
    //OnStartup();

    //Set default cursor every frame
    SDL_SetCursor(SDL_GetDefaultCursor());

    int mX, mY;

    SDL_GetMouseState(&mX, &mY);


    if(LeftButtonPressed)
    {
        Character.MoveTo_Mouse(mX, mY, &Camera1);
    }



    //Caps the frame rate depending on the ticks that have past
    //FrameRate(FPS);
}
Exemple #4
0
void Game::OnLoop()
{
    CapFrameRate(60);

    //Gravity

    //Character.Gravity(WindowHeight);

    //Collisions

    //if(Character.CheckEntityColl(Block) ==  true)
    //{
    //    cout<<"Character is in collision with the Block"<<endl;
    //    Character.CanMove = false;
   // }
    //else
    //    Character.CanMove = true;

    //Cursor

    SDL_SetCursor(SDL_GetDefaultCursor());

    //Drag Entities with mouse
    //MouseDrag(&Block);
    //MouseDrag(&Character);

    if(MouseDragReset(&Cloud) == true)
    {
        water += Raining;

        if(chorbi > 5)
        {
            CreateKapka();
            chorbi = 0;
        }
    }

    chorbi ++;

    if(MouseDragReset(&Fertilizer) == true)
    {
        if(Fertilizer.XPos + 30 < lineX1)
            beenDrop = true;
    }
    else if(beenDrop == true)
    {
        fertilize += BeRiching;
        beenDrop = false;
    }

    fertilize -= Disolving;

    // Water Function
    water -= Drying;

    for(int i = 0; i < maxKapki; i ++)
    {
        Kapka[i].YPos += 6;

        if(Kapka[i].YPos > 430)
        {
            Kapka[i].falling = false;
        }
    }

    if(water < desert) water = desert;
    if(water > ocean) water = ocean;

    if(fertilize < 1) fertilize = 1;
    if(fertilize > 10) fertilize = 10;

    waterPointer.x = waterX * water;
    fertilizePointer.x = fertilizeX * fertilize;

    cout<<waterPointer.x<< " " << water<<endl;
    cout<<"Soil fertily "<<fertilize<<" "<<fertilizeX<<"  "<<fertilizePointer.x<<endl;

    for(int i = 0; i < 10; i ++)
    {
        if(Rubish[i].falling == true)
        {
            if(MouseDragReset(&Rubish[i]) == true)
            {
                int mouseX = 0;
                int mouseY = 0;

                SDL_GetMouseState(&mouseX, &mouseY);

                if(RecycleBin.Hover(mouseX, mouseY) == true)
                {
                    Rubish[i].falling = false;
                    dragOne = false;
                    Rubish[i].draggable = false;
                }
            }
            cout<<"Xpos: "<<Rubish[i].XPos<<" Ypos: "<<Rubish[i].YPos<<endl;
        }
    }

    if(timeRub == 200)
    {
        RandomRubbish();
        timeRub = 0;
    }

    cout<<timeRub<<endl;

    timeRub ++;

    int help = 4;
    MouseDrag(&Level[help]);
    cout<<Level[help].XPos<<" "<<Level[help].YPos<<endl;

}