void Canvas::setPixel( int _x, int _y, const Ogre::ColourValue & value )
	{
		MYGUI_ASSERT( _x >= 0 && _x < getTextureRealWidth() && _y >= 0 && _y < getTextureRealHeight(),
			"Access to non-exists pixel! Check real dimensions of texture!" );

		MYGUI_ASSERT( isLocked(), "Must lock MyGUI::Canvas before set pixel!" );

		Ogre::PixelUtil::packColour( value, getTextureFormat(), pointPixel( _x, _y ) );
	}
	Ogre::ColourValue Canvas::getPixel( int _x, int _y )
	{
		MYGUI_ASSERT( _x >= 0 && _x < getTextureRealWidth() && _y >= 0 && _y < getTextureRealHeight(),
			"Access to non-exists pixel! Check real dimensions of texture!" );

		MYGUI_ASSERT( isLocked(), "Must lock MyGUI::Canvas before set pixel!" );

		Ogre::ColourValue result;

		Ogre::PixelUtil::unpackColour( & result, getTextureFormat(), pointPixel( _x, _y ) );

		return result;
	}
	void* Canvas::pointPixel( int _x, int _y )
	{
		MYGUI_ASSERT( _x >= 0 && _x < getTextureRealWidth() && _y >= 0 && _y < getTextureRealHeight(),
			"Access to non-exists pixel! Check real dimensions of texture!" );

		MYGUI_ASSERT( isLocked(), "Must lock MyGUI::Canvas before point pixel!" );

		size_t _pixelDataSize = Ogre::PixelUtil::getNumElemBytes( mTexPtr->getFormat() );

		MYGUI_ASSERT( _pixelDataSize, "Unknown texture format!" );

		return mTexData + ( _y * getTextureRealWidth() + _x ) * _pixelDataSize;
	}
	void Canvas::correctUV()
	{
		if( mTexResizeMode == TRM_PT_VIEW_REQUESTED )
		{
			_setUVSet( FloatRect( 0, 0,
				(Ogre::Real) mReqTexSize.width  / (Ogre::Real) getTextureRealWidth(),
				(Ogre::Real) mReqTexSize.height / (Ogre::Real) getTextureRealHeight()
				) );
		}

		if( mTexResizeMode == TRM_PT_CONST_SIZE || mTexResizeMode == TRM_PT_VIEW_ALL )
		{
			_setUVSet( FloatRect( 0, 0, 1, 1 ) );
		}
	}
void Player::checkBallCollision() {
    if(pPos.x + getTextureRealWidth()*2 >= ball->getX()
       && pPos.x + getTextureRealWidth() <= ball->getX() + ball->getTexture().getWidth()
       && pPos.y <= ball->getY() && pPos.y + getTextureRealHeight() >= ball->getY() + ball->getTexture().getHeight()
       && !hasTheBall && !isChangingPerspective && !ball->isPossessed() && !ball->hasBeenStolen()) {
        if(isJumping && ball->getY() >= pPos.y && ball->getY() + ball->getTexture().getHeight() <= pPos.y + getTextureRealHeight() && ball->hasCollidedWithThePole()) {
            hasTheBall = true;
            ball->setPossession(true);
            hasThrownTheBall = false;
            ball->setIsThrown(false);
            ball->setVelocity(0, 0);
            ball->resetDimensions();
            //ball->setPosition(pPos.x + getTextureRealWidth()*2 - 30, pPos.y - 5);
        }
        else if(isJumping && facing == LEFT) {
            ball->checkCollision(pPos.x + textureRealWidth,0);
        }
        else if(!isJumping) {
            hasTheBall = true;
            hasThrownTheBall = false;
            ball->setPossession(true);
            ball->setIsThrown(false);
            ball->setVelocity(0, 0);
            if(isDefending) {
                isDefending = false;
            }
            ball->resetDimensions();
            //ball->setPosition(pPos.x + getTextureRealWidth()*2 - 30, pPos.y - 5);

        }
        ball->setHasScored(false);
        hasScored = false;
        if(hasStolenTheBall) {
            hasStolenTheBall = false;
        }
        ball->setIsStolen(false);
    }
    else if (hasTheBall && !ball->isThrown()) {
        ball->setPosition(pPos.x + getTextureRealWidth()*2 - 30, pPos.y - 5);
    }
}
Exemple #6
0
 IntSize Canvas::getTextureRealSize() const
 {
     return IntSize( getTextureRealWidth(), getTextureRealHeight() );
 }