コード例 #1
0
        public override void LoadContent()
        {
            _song     = Game.Content.Load <Song>("bgm/menuBgm");
            _font     = Game.Content.Load <SpriteFont>("Bauhaus");
            _elements = Game.Content.Load <SoundEffect>("sfx/elements01");

            _tutorial = Game.Content.Load <Texture2D>("img/tutorial");

            MediaPlayer.Play(_song);
            _textBounds = new RotatableRectangleF(_font.MeasureString("[Enter] to Play"))
            {
                Center = new Vector2(
                    x: .5f * Game.GraphicsDevice.PresentationParameters.BackBufferWidth,
                    y: Game.GraphicsDevice.PresentationParameters.BackBufferHeight - 100)
            };

            //Should be disposed :)
            _waiter = Wait.Until(time =>
            {
                _textBounds.Rotation = (float)Math.Sin(time.Alive * MathHelper.TwoPi) * .25f;
                _textBounds.Scale    = 1.5f * new Vector2(
                    .5f + (float)Math.Sin((time.Alive * MathHelper.TwoPi) % MathHelper.Pi));
                return(false);
            }, null, -1);
        }
コード例 #2
0
        public void Update(GameTime gameTime, CameraOperator cameraOperator, Entities entities, World world)
        {
            foreach (Coin coin in _coins)
            {
                coin.Update(gameTime);
            }

            _seconds += gameTime.ElapsedGameTime.Milliseconds * 1e-3f;
            if (_seconds > 1f)
            {
                --_seconds;

                RotatableRectangleF cameraViewport = cameraOperator.Camera.Viewport;
                if (_coins.Count == _coins.Capacity)
                {
                    Remove(_coins[0], world);
                }

                //select a way to launch
                if (InfiniteIsland.Random.Next(2) == 0)
                {
                    //Launch from the left
                    _coins.Add(
                        new Coin(
                            position:
                            (cameraViewport.TopLeft +
                             new Vector2(0,
                                         (float)InfiniteIsland.Random.NextDouble() *
                                         cameraViewport.Dimensions.Y * .75f)).ToMeters(),
                            linearVelocity:
                            entities.Player.Body.Wheel.LinearVelocity *
                            new Vector2(1.5f + (float)InfiniteIsland.Random.NextDouble() / 2.5f,
                                        -2 * (float)InfiniteIsland.Random.NextDouble()), world: world));
                }
                else
                {
                    //Launch from the right
                    _coins.Add(
                        new Coin(
                            position:
                            (cameraViewport.TopRight +
                             new Vector2(0, (float)InfiniteIsland.Random.NextDouble() * cameraViewport.Dimensions.Y * .75f)).ToMeters(),
                            linearVelocity:
                            entities.Player.Body.Wheel.LinearVelocity *
                            (new Vector2(
                                 x: 1.5f + (float)InfiniteIsland.Random.NextDouble() / 2.5f,
                                 y: -2 * (float)InfiniteIsland.Random.NextDouble()) - Vector2.UnitX),
                            world: world));
                }
            }
        }
コード例 #3
0
        public Sprite(Animation animation)
        {
            Animation = animation;
            Body      = new RotatableRectangleF(Animation.MaxDimensions);

            Flip            = SpriteEffects.None;
            Tint            = Color.White;
            FramesPerSecond = 30;

            if (Animation.Animations.Count == 1)
            {
                var keys = new string[1];
                Animation.Animations.Keys.CopyTo(keys, 0);
                Key = keys[0];
            }
        }
コード例 #4
0
 public void Setup(Vector2 dimensions)
 {
     Viewport = new RotatableRectangleF(dimensions);
 }