Example #1
0
uint8_t Keyboard::keyChanged(uint8_t key)
{
    uint8_t key2;

    key2 = getPressed();
    while(key2 != key) {
        Timer::delayIdle(BUTTON_CHANGE_DELAY);
        key = key2;
        key2 = getPressed();
    }

    speed_ = 0;
    this_speed_ = 0;
    last_key_ = key;

    if(key != BUTTON_NONE) {
        Buzzer::soundKeyboard();
    }

    return last_key_;
}
Example #2
0
uint8_t Keyboard::getPressedWithSpeed()
{
    uint8_t key = BUTTON_NONE;
    for(uint16_t i = 0; i < (BUTTON_DELAY_TIMES / pgm::read(&speedTable[speed_])) + 1; i++) {
        key = getPressed();
        Timer::delayIdle(BUTTON_DELAY);
        if(key == last_key_)
            continue;

        return keyChanged(key);
    }

    if(key != BUTTON_NONE) {
        this_speed_++;
        if(this_speed_ >= pgm::read(&thisSpeedT[speed_])) {
            if(speed_ < sizeof(speedTable) / sizeof(speedTable[0]) - 1)
                speed_ ++;
            this_speed_ = 0;
        }
    }

    return last_key_;
}
Example #3
0
void CPlayer::shootGun()
{
	if (getPressed(input, 4) && !shooting && !playerLocked)
	{
		shooting = true;
		image->setFrame(0);
	}
	shotImage->setY(image->getY() + 12);
	if (!facingLeft)
		shotImage->setX(image->getX() + image->getW());
	if (facingLeft)
		shotImage->setX(image->getX() - shotImage->getW());
	if (shotImage->getAlpha() > 0)
		shotImage->setAlpha(shotImage->getAlpha() - 20);
	if (shotImage->getAlpha() < 0)
		shotImage->setAlpha(0);

	if (shot)
	{
		shotImage->setAlpha(255);
		playerSounds->playSound(2);
		shot = false;
	}
}
Example #4
0
void EventReceiver::checkEvents()
{
    //Need to capture/update each device
    keyboard->capture();
    if (joystick) joystick->capture();

    OIS::JoyStickState joystickState;
    if (joystick) joystickState = joystick->getJoyStickState();
    
#if 0
    if (test_kc == 0)
    {
        test_kc = KeyConfig::getKeyConfig(keyboard, joystickState, deadZone, false);
        if (test_kc)
        {
            dprintf(MY_DEBUG_INFO, "test_kc assigned: %d\n", test_kc->key);
            //assert(0);
        }
    }
    else
    {
        float pressed = test_kc->getPercentage(keyboard, joystickState);
        if (pressed > deadZone)
        {
            dprintf(MY_DEBUG_INFO, "test_kc pressed: %f\n", pressed);
        }
    }
    if (keyboard->isKeyDown(OIS::KC_ESCAPE))
    {
        delete test_kc;
        test_kc = 0;
    }
    

    //printf("%s\n", keyboard->isKeyDown(OIS::KC_K)?"true":"false");
    /*
    printf("Axes: %lu\n", joystickState.mAxes.size());
    for (unsigned int i = 0; i < joystickState.mAxes.size(); i++)
    {
        printf("\t%u: %d (%d)\n", i, joystickState.mAxes[i].abs, joystickState.mAxes[i].rel);
    }
    printf("Sliders:\n");
    for (unsigned int i = 0; i < 4; i++)
    {
        printf("\t%u: %d, %d\n", i, joystickState.mSliders[i].abX, joystickState.mSliders[i].abY);
    }
    */
#else // 0 or 1
    
    if (MenuManager::getInstance()->getMenuInput())
    {
        /*
        if (IS_PRESSED(SWITCH_INPUT))
        {
            MenuManager::getInstance()->clearEventReceiver();
            MenuPageEditor::menuPageEditor->activateAction();
        }
        */
    }
    else
    {
    
        // the real event check

        // mouse
        /*
        mouse->capture();
        const OIS::MouseState mouseState = mouse->getMouseState();
        if (mouseState.buttonDown(OIS::MB_Left))
        {
            printf("mouse button left down\n");
        }

        if (mouseState.buttonDown(OIS::MB_Right))
        {
            printf("mouse button right down\n");
        }

        if (mouseState.buttonDown(OIS::MB_Middle))
        {
            printf("mouse button middle down\n");
        }
        */

        // other
            float perc = 0.f;
            if (IS_PRESSED(BRAKE) && (perc = getPercentage(BRAKE, joystickState))/* > Settings::getInstance()->joystickDeadZone*/)
            {
                //dprintf(MY_DEBUG_NOTE, "brake pressed: %f\n", perc);
                Player::getInstance()->setFirstPressed();
                Player::getInstance()->getVehicle()->setTorque(perc/*perc*/);
            }
            else
            if (IS_PRESSED(ACCELERATE) && (perc = getPercentage(ACCELERATE, joystickState))/* > Settings::getInstance()->joystickDeadZone*/)
            {
                //dprintf(MY_DEBUG_NOTE, "accelerate pressed: %f\n", perc);
                Player::getInstance()->setFirstPressed();
                Player::getInstance()->getVehicle()->setTorque(-1.0f*perc/*perc*/);
            }
            else
            {
                if (Settings::getInstance()->AIPlayer == false ||
                    Settings::getInstance()->editorMode ||
                    Player::getInstance()->getStarter() == 0)
                {
                    Player::getInstance()->getVehicle()->setTorque(0);
                }
            }

        if (Settings::getInstance()->AIPlayer == false ||
            Settings::getInstance()->editorMode ||
            Player::getInstance()->getStarter() == 0)
        {
            if (IS_PRESSED(CLUTCH) && (perc = getPercentage(CLUTCH, joystickState))/* > Settings::getInstance()->joystickDeadZone*/)
            {
                //dprintf(MY_DEBUG_NOTE, "accelerate pressed: %f\n", perc);
                Player::getInstance()->getVehicle()->setClutch(perc*perc);
            }

            const float steerRatePressed = Settings::getInstance()->steerRatePressed; // 0.2f
            float steerRate = Settings::getInstance()->steerRate; // 0.5f
            float desiredSteer = 0.0f;
            perc = 0.0f;
            if (Settings::getInstance()->linearSteering)
            {
                if (IS_PRESSED(LEFT) && (perc = getPercentage(LEFT, joystickState))/* > Settings::getInstance()->joystickDeadZone*/)
                {
                    //dprintf(MY_DEBUG_NOTE, "left pressed: %f\n", perc);
                    //Player::getInstance()->getVehicle()->setSteer(-1.0f*perc*perc);
                    desiredSteer = -1.0f*perc;
                }
                else
                if (IS_PRESSED(RIGHT) && (perc = getPercentage(RIGHT, joystickState))/* > Settings::getInstance()->joystickDeadZone*/)
                {
                    //dprintf(MY_DEBUG_NOTE, "right pressed: %f\n", perc);
                    //Player::getInstance()->getVehicle()->setSteer(perc*perc);
                    desiredSteer = perc;
                }
                else
                {
                    //Player::getInstance()->getVehicle()->setSteer(0.0f);
                }
                if (perc > Settings::getInstance()->joystickDeadZone)
                {
                    steerRate = steerRatePressed;
                }
            }
            else
            {
                if (IS_PRESSED(LEFT) && (perc = getPercentage(LEFT, joystickState))/* > Settings::getInstance()->joystickDeadZone*/)
                {
                    //dprintf(MY_DEBUG_NOTE, "left pressed: %f\n", perc);
                    //Player::getInstance()->getVehicle()->setSteer(-1.0f*perc*perc);
                    desiredSteer = -1.0f*perc*perc;
                }
                else
                if (IS_PRESSED(RIGHT) && (perc = getPercentage(RIGHT, joystickState))/* > Settings::getInstance()->joystickDeadZone*/)
                {
                    //dprintf(MY_DEBUG_NOTE, "right pressed: %f\n", perc);
                    //Player::getInstance()->getVehicle()->setSteer(perc*perc);
                    desiredSteer = perc*perc;
                }
                else
                {
                    //Player::getInstance()->getVehicle()->setSteer(0.0f);
                }
                if (perc*perc > Settings::getInstance()->joystickDeadZone)
                {
                    steerRate = steerRatePressed;
                }
            }
            //printf("steer rate: %f\n", steerRate);
            if (lastSteer + steerRate < desiredSteer)
            {
                lastSteer += steerRate;
            }
            else if (lastSteer - steerRate > desiredSteer)
            {
                lastSteer -= steerRate;
            }
            else
            {
                lastSteer = desiredSteer;
            }

            Player::getInstance()->getVehicle()->setSteer(lastSteer);

            if (IS_PRESSED(HANDBRAKE))
            {
                //dprintf(MY_DEBUG_NOTE, "brake pressed\n");
                Player::getInstance()->getVehicle()->setHandbrake(1.0f);
            }
            else
            {
                Player::getInstance()->getVehicle()->setHandbrake(0);
            }

            if (Settings::getInstance()->manualGearShifting)
            {
                if (Settings::getInstance()->sequentialGearShifting)
                {
                    if (IS_PRESSED(GEAR_UP) && getPressed(GEAR_UP))
                    {
                        Player::getInstance()->getVehicle()->incGear();
                    }
                    if (IS_PRESSED(GEAR_DOWN) && getPressed(GEAR_DOWN))
                    {
                        Player::getInstance()->getVehicle()->decGear();
                    }
                }
                else
                {
                    if (IS_PRESSED(GEAR_1))
                    {
                        Player::getInstance()->getVehicle()->setGear(1);
                    }
                    else
                    if (IS_PRESSED(GEAR_2))
                    {
                        Player::getInstance()->getVehicle()->setGear(2);
                    }
                    else
                    if (IS_PRESSED(GEAR_3))
                    {
                        Player::getInstance()->getVehicle()->setGear(3);
                    }
                    else
                    if (IS_PRESSED(GEAR_4))
                    {
                        Player::getInstance()->getVehicle()->setGear(4);
                    }
                    else
                    if (IS_PRESSED(GEAR_5))
                    {
                        Player::getInstance()->getVehicle()->setGear(5);
                    }
                    else
                    if (IS_PRESSED(GEAR_6))
                    {
                        Player::getInstance()->getVehicle()->setGear(6);
                    }
                    else
                    if (IS_PRESSED(GEAR_R))
                    {
                        Player::getInstance()->getVehicle()->setGear(-1);
                    }
                    else
                    {
                        Player::getInstance()->getVehicle()->setGear(0);
                    }
                }
            }
        } // if (Settings::getInstance()->AIPlayer == false || Settings::getInstance()->editorMode)

        if (IS_PRESSED(PHYSICS))
        {
            TheGame::getInstance()->setPhysicsOngoing(!TheGame::getInstance()->getPhysicsOngoing());
        }
        /*else
        {
            TheGame::getInstance()->setPhysicsOngoing(false);
        }*/

        if (IS_PRESSED(FPS_CAMERA))
        {
            dprintf(MY_DEBUG_NOTE, "switch camera\n");
            TheGame::getInstance()->switchCamera();
        }

        if (IS_PRESSED(SWITCH_HUD))
        {
            dprintf(MY_DEBUG_NOTE, "switch hud\n");
            Hud::getInstance()->setVisible(!Hud::getInstance()->getVisible());
        }

        if (IS_PRESSED(LOOK_LEFT) && getPressed(LOOK_LEFT))
        {
            Player::getInstance()->lookLeft(true);
        }
        else if (getReleased(LOOK_LEFT))
        {
            Player::getInstance()->lookLeft(false);
        }

        if (IS_PRESSED(LOOK_RIGHT) && getPressed(LOOK_RIGHT))
        {
            Player::getInstance()->lookRight(true);
        }
        else if (getReleased(LOOK_RIGHT))
        {
            Player::getInstance()->lookRight(false);
        }

        if (IS_PRESSED(CHANGE_VIEW))
        {
            Player::getInstance()->switchToNextView();
        }

        if (IS_PRESSED(OPEN_EDITOR))
        {
            if (Settings::getInstance()->editorMode)
            {
                MenuManager::getInstance()->open(MenuManager::MP_EDITOR);
            }
        }

        if (IS_PRESSED(RESET_VEHICLE))
        {
            Player::getInstance()->resetVehicle(irr::core::vector3df(
                    TheGame::getInstance()->getCamera()->getPosition().X,
                    TheEarth::getInstance()->getHeight(TheGame::getInstance()->getCamera()->getPosition())+2.5f,
                    TheGame::getInstance()->getCamera()->getPosition().Z));
        }

        if (IS_PRESSED(REPAIR_VEHICLE))
        {
            Player::getInstance()->repairVehicle();
        }

        if (IS_PRESSED(SWITCH_INPUT))
        {
            MenuManager::getInstance()->refreshEventReceiver();
            MenuPageEditor::menuPageEditor->refreshAction();
        }

        if (IS_PRESSED(INC_FPS_SPEED))
        {
            TheGame::getInstance()->incFPSSpeed();
        }

        if (IS_PRESSED(DEC_FPS_SPEED))
        {
            TheGame::getInstance()->decFPSSpeed();
        }

        //if (Settings::getInstance()->navigationAssistant == false)
        //{
            if (IS_PRESSED(ROADBOOK_NEXT))
            {
                Player::getInstance()->stepItiner();
                Hud::getInstance()->updateRoadBook();
            }
            else if (IS_PRESSED(ROADBOOK_PREV))
            {
                Player::getInstance()->stepBackItiner();
                Hud::getInstance()->updateRoadBook();
            }
            if (IS_PRESSED(RESET_PARTIAL))
            {
                Player::getInstance()->resetDistance();
            }
        //}

        if (IS_PRESSED(EXIT_TO_MENU))
        {
            MenuManager::getInstance()->open(MenuManager::MP_INGAME);
        }
#ifdef DETECT_MEM_LEAKS
        if (IS_PRESSED(PRINT_MEM_LEAKS))
        {
            VLDReportLeaks();
            //_CrtDumpMemoryLeaks();
            //assert(0);
        }
        if (IS_PRESSED(PRINT_MEM_LEAKS_IRR))
        {
            TheGame::getInstance()->getSmgr()->addTerrainSceneNode("fake/path");
            //_CrtDumpMemoryLeaks();
            //assert(0);
        }
#endif // DETECT_MEM_LEAKS
    }
#endif // 0 or 1
}
Example #5
0
void CPlayer::buyUpgrades()
{
	if (getShopPlayerIsInX() != -1)
	{
		if (world->getShop(getShopPlayerIsInX(), getShopPlayerIsInY())->getCurrentPrice() != 0 && world->getShop(getShopPlayerIsInX(), getShopPlayerIsInY())->getCurrentPrice() <= money && getPressed(input, 7) && world->getShop(getShopPlayerIsInX(), getShopPlayerIsInY())->getActive())
		{
			world->getShop(getShopPlayerIsInX(), getShopPlayerIsInY())->buyItem();
			money -= world->getShop(getShopPlayerIsInX(), getShopPlayerIsInY())->getCurrentPrice();

			if (world->getShop(getShopPlayerIsInX(), getShopPlayerIsInY())->getCurrentItem() == 0)
			{
				pickaxeLevel++;
			}
			if (world->getShop(getShopPlayerIsInX(), getShopPlayerIsInY())->getCurrentItem() == 1)
			{
				healthLevel++;
			}
			if (world->getShop(getShopPlayerIsInX(), getShopPlayerIsInY())->getCurrentItem() == 2)
			{
				moneyLevel++;
			}
		}
	}
}
Example #6
0
void CPlayer::dig()
{
	int x = image->getX() / 40;
	int y = image->getY() / 40;

	breaking = false;

	if (!shooting && !playerLocked)
	{
		if (y < world->getHeight() && y >= 0 && x - 1 < world->getWidth() && x - 1 >= 0)
		{
			if (getPressed(input, 0) && image->getX() == world->getBlock(x - 1, y)->getRect().x + world->getBlock(x - 1, y)->getRect().w && !world->getBlock(x - 1, y)->getPassable())
			{
				damageDone++;
				breakingX = x - 1;
				breakingY = y;
				if (damageDone > world->getBlock(x - 1, y)->getStrength())
				{
					world->destoryBlock(x - 1, y);
					damageDone = 0;
				}
				breaking = true;
			}
		}

		if (y < world->getHeight() && y >= 0 && x + 1 < world->getWidth() && x + 1 >= 0)
		{
			if (getPressed(input, 1) && !breaking && image->getX() + image->getW() == world->getBlock(x + 1, y)->getRect().x && !world->getBlock(x + 1, y)->getPassable())
			{
				damageDone++;
				breakingX = x + 1;
				breakingY = y;
				if (damageDone > world->getBlock(x + 1, y)->getStrength())
				{
					world->destoryBlock(x + 1, y);
					damageDone = 0;
				}
				breaking = true;
			}
		}

		if (y - 1 < world->getHeight() && y - 1 >= 0 && x < world->getWidth() && x >= 0)
		{
			if (getPressed(input, 2) && !breaking && !world->getBlock(x, y - 1)->getPassable())
			{
				damageDone++;
				breakingX = x;
				breakingY = y - 1;
				if (damageDone > world->getBlock(x, y - 1)->getStrength())
				{
					world->destoryBlock(x, y - 1);
					damageDone = 0;
				}
				breaking = true;
			}
		}

		if (y + 1 < world->getHeight() && y + 1 >= 0 && x < world->getWidth() && x >= 0)
		{
			if (getPressed(input, 3) && !breaking && image->getY() + image->getH() == world->getBlock(x, y + 1)->getRect().y && !world->getBlock(x, y + 1)->getPassable())
			{
				damageDone++;
				breakingX = x;
				breakingY = y + 1;
				if (damageDone > world->getBlock(x, y + 1)->getStrength())
				{
					world->destoryBlock(x, y + 1);
					//world->getBlock(x, y + 1)->setType(0);
					damageDone = 0;
				}
				breaking = true;
			}
		}
	}
	if (!(getPressed(input, 0) | getPressed(input, 1) | getPressed(input, 2) | getPressed(input, 3)) | breakingX != lastBreakingX | breakingY != lastBreakingY | shooting)
		damageDone = 0;

	lastBreakingX = breakingX;
	lastBreakingY = breakingY;

	breakingImage->setX(breakingX * 40);
	breakingImage->setY(breakingY * 40);
	breakingImage->setFrame(10 * ((float)damageDone / (float)world->getBlock(breakingX, breakingY)->getStrength()));
}
Example #7
0
void CPlayer::move()
{
	//x pos
	if (!playerLocked)
	{
		if (!shooting && !(breaking && landed))
		{
			if (getPressed(input, 0) && velocityX >= -5)
			{
				velocityX -= 0.3;
			}
			else if (getPressed(input, 1) && velocityX <= 5)
			{
				velocityX += 0.3;
			}
		}

		//y pos
		if (getPressed(input, 2) && jumpDurration < jumpMaxDurration)
		{
			if (landed && image->getX() / 40 >= 0 && image->getX() / 40 < world->getWidth() && image->getY() / 40 - 1 >= 0 && image->getY() / 40 - 1 < world->getHeight())
			{
				if (world->getBlock(image->getX() / 40, image->getY() / 40 - 1)->getPassable())
				{
					velocityY = -5;
					jumpDurration++;
					if (landed)
						jumpedLast = SDL_GetTicks();
				}
			}
			else if (landed && image->getX() / 40 + 1 >= 0 && image->getX() / 40 + 1 < world->getWidth() && image->getY() / 40 - 1 >= 0 && image->getY() / 40 - 1 < world->getHeight())
			{
				if (world->getBlock(image->getX() / 40 + 1, image->getY() / 40 - 1)->getPassable())
				{
					velocityY = -5;
					jumpDurration++;
					if (landed)
						jumpedLast = SDL_GetTicks();
				}
			}
			else
			{
				velocityY = -5;
				jumpDurration++;
				if (landed)
					jumpedLast = SDL_GetTicks();
			}
		}
		if (!getPressed(input, 2) && !landed)
		{
			jumpDurration = jumpMaxDurration + 1;
		}
		if (landed)
			jumpDurration = 0;

		if (!landed && getPressed(input, 2) && touchingRight && jumpDurration > jumpMaxDurration && jumpedLast + 200 < SDL_GetTicks())
		{
			velocityY = -5;
			velocityX = -6;
			jumpDurration = 0;
			jumpedLast = SDL_GetTicks();
		}
		else if (!landed && getPressed(input, 2) && touchingLeft && jumpDurration > jumpMaxDurration && jumpedLast + 200 < SDL_GetTicks())
		{
			velocityY = -5;
			velocityX = 6;
			jumpDurration = 0;
			jumpedLast = SDL_GetTicks();
		}
	}
	//gravity and friction
	if (((!getPressed(input, 0) && !getPressed(input, 1)) | shooting | breaking | playerLocked) && landed)
	{
		if (velocityX > 0)
			velocityX -= 0.3;
		else if (velocityX < 0)
			velocityX += 0.3;
		if (abs(velocityX) < 0.3)
			velocityX = 0;
	}
	velocityY += gravity;
	if (velocityY > 40)
		velocityY = 40;

	//x pos wall collisions
	image->setX(image->getX() + velocityX);
	
	for (int y = image->getY() / 40; y < (image->getY() / 40) + 2; y++)
	{
		for (int x = image->getX() / 40; x < (image->getX() / 40) + 2; x++)
		{
			if (x >= 0 && x < world->getWidth() && y >= 0 && y < world->getHeight())
			{
				if (!(image->getX() + image->getW() <= world->getBlock(x, y)->getRect().x || world->getBlock(x, y)->getRect().x + world->getBlock(x, y)->getRect().w <= image->getX() || image->getY() + image->getH() <= world->getBlock(x, y)->getRect().y || world->getBlock(x, y)->getRect().y + world->getBlock(x, y)->getRect().h <= image->getY()))
				{
					//solid block mechanics
					if (!world->getBlock(x, y)->getPassable())
					{
						if (velocityX > 0) { image->setX(world->getBlock(x, y)->getRect().x - image->getW()); }
						if (velocityX < 0) { image->setX(world->getBlock(x, y)->getRect().x + world->getBlock(x, y)->getRect().w); }
						velocityX = 0;
					}
					// waterfall mechanics
					if (world->getBlock(x, y)->getType() == 7)
					{
						if (velocityX > 3 && !landed)
							velocityX--;
						else if (velocityX < -3 && !landed)
							velocityX++;
						if (velocityY > 3)
							velocityY--;
						else if (velocityY < -3)
							velocityY++;
					}
				}
			}
		}
	}

	touchingLeft = false;
	touchingRight = false;
	if (image->getX() / 40 - 1 >= 0 && image->getX() / 40 - 1 < world->getWidth() && image->getY() / 40 >= 0 && image->getY() / 40 < world->getHeight())
	{
		if (image->getX() == world->getBlock(image->getX() / 40 - 1, image->getY() / 40)->getRect().x + world->getBlock(image->getX() / 40 - 1, image->getY() / 40)->getRect().w && !world->getBlock(image->getX() / 40 - 1, image->getY() / 40)->getPassable())
			touchingLeft = true;
	}
	if (image->getX() / 40 + 1 >= 0 && image->getX() / 40 + 1 < world->getWidth() && image->getY() / 40 >= 0 && image->getY() / 40 < world->getHeight())
	{
		if (image->getX() + image->getW() == world->getBlock(image->getX() / 40 + 1, image->getY() / 40)->getRect().x && !world->getBlock(image->getX() / 40 + 1, image->getY() / 40)->getPassable())
			touchingRight = true;
	}

	//y pos ground and celling collisions
	image->setY(image->getY() + velocityY);

	for (int y = image->getY() / 40; y < (image->getY() / 40) + 2; y++)
	{
		for (int x = image->getX() / 40; x < (image->getX() / 40) + 2; x++)
		{
			if (x >= 0 && x < world->getWidth() && y >=0 && y < world->getHeight())
			{
				if (!world->getBlock(x, y)->getPassable() && !(image->getX() + image->getW() <= world->getBlock(x, y)->getRect().x || world->getBlock(x, y)->getRect().x + world->getBlock(x, y)->getRect().w <= image->getX() || image->getY() + image->getH() <= world->getBlock(x, y)->getRect().y || world->getBlock(x, y)->getRect().y + world->getBlock(x, y)->getRect().h <= image->getY()))
				{
					if (velocityY > 0)
					{
						image->setY(world->getBlock(x, y)->getRect().y - image->getH());
						if (velocityY > 10)
							takeDamage(velocityY - 10);
						velocityY = 0;
					}
					if (velocityY < 0)
					{
						image->setY(world->getBlock(x, y)->getRect().y + world->getBlock(x, y)->getRect().h);
						velocityY = 0;
						jumpDurration = jumpMaxDurration;
					}
				}
			}
		}
	}
	
	bool wasLanded = landed;
	landed = false; //makes sure to check everytime
	if ((image->getY() / 40) + 1 < world->getHeight() && (image->getY() / 40) + 1 >= 0 && image->getX() / 40 < world->getWidth() && image->getX() / 40 >= 0)
	{
		if (image->getY() + image->getH() == world->getBlock(image->getX() / 40, (image->getY() / 40) + 1)->getRect().y && !world->getBlock(image->getX() / 40, (image->getY() / 40) + 1)->getPassable())
			landed = true;
	}
	if ((image->getY() / 40) + 1 < world->getHeight() && (image->getY() / 40) + 1 >= 0 && image->getX() / 40 + 1 < world->getWidth() && image->getX() / 40 + 1 >= 0 && wasLanded)
	{
		if (image->getY() + image->getH() == world->getBlock(image->getX() / 40 + 1, (image->getY() / 40) + 1)->getRect().y && !world->getBlock(image->getX() / 40 + 1, (image->getY() / 40) + 1)->getPassable())
			landed = true;
	}

	//update players position in world
	world->setPlayerPosition(image->getX(), image->getY());
}