예제 #1
0
        public void setDirection(int rotation)
        {
            switch (rotation)
            {
            case 0:
                windDirection = Direction.UP;

                break;

            case 360:
                windDirection = Direction.UP;
                break;

            case 90:
                windDirection = Direction.LEFT;
                break;

            case 180:
                windDirection = Direction.DOWN;
                break;

            case 270:
                windDirection = Direction.RIGHT;
                break;
            }

            if (windDirection == Direction.LEFT)
            {
                sprite.Rotate(FMath.PI);
            }
            else if (windDirection == Direction.RIGHT)
            {
                sprite.Rotate(FMath.PI);
            }
        }
        public Tank(Scene scene)
        {
            // Tank Base
            texture2D   = new Texture2D("/Application/Assets/tankBase2.png", false);
            numTiles    = new Vector2i(1, 1);      // tiles in the sprite sheet
            tiles       = new Vector2i(0, 0);      // tile you are displaying
            textureInfo = new TextureInfo(texture2D, numTiles);
            sprite      = new SpriteTile(textureInfo);

            sprite.Quad.S      = new Vector2(textureInfo.TextureSizef.X, textureInfo.TextureSizef.Y);
            sprite.TileIndex2D = tiles;             // sets which tile you are viewing
            sprite.CenterSprite();

            // tank turret
            turretTex     = new TextureInfo("/Application/Assets/tankTurret2.png");
            turret        = new SpriteUV(turretTex);
            turret.Quad.S = turretTex.TextureSizef;
            turret.CenterSprite(TRS.Local.Center);

            if (SceneManager.Instance.rand.NextDouble() > 0.5)
            {
                leftRight = true;
                sprite.Rotate((float)System.Math.PI / 2);
                //turret.Rotate((float)System.Math.PI/2);
            }
            else
            {
                leftRight = false;
                sprite.Rotate(-(float)System.Math.PI / 2);
                //turret.Rotate(-(float)System.Math.PI/2);
            }

            speed    = (float)SceneManager.Instance.rand.NextDouble() * 800.0f;
            position = new Vector2(300.0f, 300.0f);
            minSpeed = 100;
            maxSpeed = 200;
            setRandom();


            scene.AddChild(sprite);
            scene.AddChild(turret);
        }
예제 #3
0
        public void setRotation(float rotation)
        {
            float degreesToRad = (rotation * Sce.PlayStation.HighLevel.GameEngine2D.Base.Math.Pi) / 180;

            sprite.Rotate(degreesToRad);
        }