示例#1
0
        public Spring(Scene scene, Vector2 position)
        {
            rand           = new Random();
            springReleased = false;
            missedSpring   = false;
            beingPushed    = false;
            magmaTrap      = true;

            // Initialise spring texture and sprite, get bounds and set position minus height offset
            springTextureInfo = new TextureInfo("/Application/textures/Spring.png");

            springSprite  = new SpriteUV(springTextureInfo);
            springSprite2 = new SpriteUV(springTextureInfo);

            springSprite.Quad.S  = springTextureInfo.TextureSizef;
            springSprite2.Quad.S = springTextureInfo.TextureSizef;

            Bounds2 springBounds = springSprite.Quad.Bounds2();

            springWidth          = springBounds.Point10.X;
            springOriginalHeight = springBounds.Point01.Y;
            springCurrentHeight  = springBounds.Point01.Y;


            // Initialise spring texture and sprite, get bounds and set position minus height offset
            springTopTextureInfo   = new TextureInfo("/Application/textures/SpringTop.png");
            springTopSprite        = new SpriteUV(springTopTextureInfo);
            springTopSprite.Quad.S = springTopTextureInfo.TextureSizef;
            Bounds2 springTopBounds = springTopSprite.Quad.Bounds2();

            springTopHeight = springTopBounds.Point01.Y;
            springTopWidth  = springTopBounds.Point10.X;
            float sizeDifference = 12;             // Spring width is 100, spring top is 76, half it for x offset

            springSprite.Position  = new Vector2(position.X, position.Y);
            springSprite2.Position = springSprite.Position + new Vector2(58.0f, 48.0f);              // Offset second spring for 3d effect

            trap = new Trap(scene, new Vector2((position.X + 125 + sizeDifference), 60));
            pit  = new Pit(scene, new Vector2((position.X + 125 + sizeDifference), 60));

            springTopSprite.Position = new Vector2(position.X + sizeDifference, springSprite.Position.Y + springBounds.Point01.Y - 20);

            // Add sprites to scene
            scene.AddChild(springSprite);
            scene.AddChild(springSprite2);
            scene.AddChild(springTopSprite);
        }
示例#2
0
        public Seasaw(Scene scene, float xPos, float floorHeight)
        {
            //Initialise Variables
            rand = new Random();

            _scale         = 1.00f;
            _rotationSpeed = 0.01f;
            _scaleLimiter  = 0.3f;
            _tempScale     = 1.0f;
            _rotateLeft    = false;
            _onObstacle    = false;
            _floorHeight   = floorHeight;
            _defaultYPos   = floorHeight + 45.0f;


            //SpriteSheet Info
            _textureInfo = new TextureInfo("/Application/textures/Seasaw.png");

            //Create Sprite
            _sprite        = new SpriteUV();
            _sprite        = new SpriteUV(_textureInfo);
            _sprite.Quad.S = _textureInfo.TextureSizef;
            _sprite.Scale  = new Vector2(_scale, _scale);
            _sprite.CenterSprite();
            _sprite.Position = new Vector2(xPos + 180, _defaultYPos);

            _hypotenuse   = (_textureInfo.TextureSizef.X * _scale);
            _angle        = -0.32f;
            _angle2       = (FMath.PI / 2) - _angle;
            _opposite     = FMath.Cos(_angle2) * _hypotenuse;
            _adjacent     = FMath.Tan(_angle) * _opposite;
            _sprite.Angle = _angle;
            _scalerValue  = _tempScale / (_angle * 10);

            _trap = new Trap(scene, new Vector2(xPos, 60.0f));
            _pit  = new Pit(scene, new Vector2(xPos, 60));

            //Add to the current scene.
            scene.AddChild(_sprite);
        }