示例#1
0
 private void SetupBindings()
 {
     _bindings.Set(Bindings.Restart, new KeyboardBinding(Keys.R));
     _bindings.Set(Bindings.MoveRight, new KeyboardBinding(Keys.Right), new KeyboardBinding(Keys.D));
     _bindings.Set(Bindings.MoveLeft, new KeyboardBinding(Keys.Left), new KeyboardBinding(Keys.A));
     _bindings.Set(Bindings.Drop, new KeyboardBinding(Keys.Down), new KeyboardBinding(Keys.S));
     _bindings.Set(Bindings.Jump, new KeyboardBinding(Keys.Space));
     _bindings.Set(Bindings.Dash, new KeyboardBinding(Keys.LeftShift), new KeyboardBinding(Keys.RightShift));
     _bindings.Set(Bindings.Skip, new KeyboardBinding(Keys.P));
 }
示例#2
0
        protected override void Initialize()
        {
            _graphics.PreferredBackBufferWidth  = GameProperties.Width * 3;
            _graphics.PreferredBackBufferHeight = GameProperties.Height * 3;
            _graphics.ApplyChanges();

            _renderer = new Renderer(GraphicsDevice,
                                     new ContentManagerProvider <Texture2D>(Content)
            {
                Prefix = "Textures/"
            },
                                     new ContentManagerProvider <SpriteFont>(Content)
            {
                Prefix = "Fonts/"
            });
            _renderTarget = new RenderTarget2D(GraphicsDevice, GameProperties.Width, GameProperties.Height);
            _spriteBatch  = new SpriteBatch(GraphicsDevice);

            IsMouseVisible = true;

            Window.Title             = GameProperties.Name;
            Window.AllowUserResizing = true;

            _inputBindings.Set("move_left", new KeyboardBinding(Keys.Left));
            _inputBindings.Set("move_right", new KeyboardBinding(Keys.Right));
            _inputBindings.Set("select_up", new KeyboardBinding(Keys.Up));
            _inputBindings.Set("select_down", new KeyboardBinding(Keys.Down));
            _inputBindings.Set("jump", new KeyboardBinding(Keys.Space));
            _inputBindings.Set("select", new KeyboardBinding(Keys.Space), new KeyboardBinding(Keys.Z), new KeyboardBinding(Keys.LeftShift));
            _inputBindings.Set("interact", new KeyboardBinding(Keys.Up));
            _inputBindings.Set("attack", new KeyboardBinding(Keys.Z), new KeyboardBinding(Keys.LeftShift));
            _inputBindings.Set("restart", new KeyboardBinding(Keys.R));

            _spriteAnimations.Add("trader_idle", new FixedFrameAnimation("trader", 16, 16)
                                  .AddFrame(0, 0).AddFrame(1, 0).AddFrame(2, 0).AddFrame(1, 0));
            _spriteAnimations.Add("bat_flying", new FixedFrameAnimation("bat", 16, 16)
                                  .AddFrame(0, 0).AddFrame(1, 0).AddFrame(2, 0).AddFrame(3, 0));
            _spriteAnimations.Add("elite_bat_flying", new FixedFrameAnimation("elite_bat", 24, 24)
                                  .AddFrame(0, 0).AddFrame(1, 0).AddFrame(2, 0).AddFrame(3, 0));
            _spriteAnimations.Add("monkey_idle", new FixedFrameAnimation("monkey", 16, 16)
                                  .AddFrame(0, 0).AddFrame(1, 0).AddFrame(2, 0).AddFrame(1, 0));
            _spriteAnimations.Add("beggar_idle", new FixedFrameAnimation("beggar", 32, 32)
                                  .AddFrame(0, 0).AddFrame(1, 0).AddFrame(2, 0).AddFrame(3, 0));
            _spriteAnimations.Add("gem_idle", new FixedFrameAnimation("gem", 16, 16)
                                  .AddFrame(0, 0).AddFrame(1, 0, 0.05f).AddFrame(2, 0).AddFrame(3, 0, 0.05f));
            _spriteAnimations.Add("player_dead", new FixedFrameAnimation("player_dead", 16, 16)
                                  .AddFrame(0, 0));
            _spriteAnimations.Add("angel_idle", new FixedFrameAnimation("angel", 32, 32)
                                  .AddFrame(0, 0).AddFrame(1, 0).AddFrame(2, 0).AddFrame(1, 0));
            _spriteAnimations.Add("waterfall", new FixedFrameAnimation("waterfall", 16, 16)
                                  .AddFrame(0, 0).AddFrame(1, 0).AddFrame(2, 0).AddFrame(3, 0));
            _spriteAnimations.Add("villager_idle", new FixedFrameAnimation("villager", 16, 16)
                                  .AddFrame(0, 0).AddFrame(1, 0).AddFrame(2, 0).AddFrame(3, 0));
            _spriteAnimations.Add("valgox_idle", new FixedFrameAnimation("valgox", 32, 32)
                                  .AddFrame(0, 0).AddFrame(1, 0).AddFrame(2, 0).AddFrame(3, 0));
            _spriteAnimations.Add("player_idle", new FixedFrameAnimation("player", 16, 16)
                                  .AddFrame(0, 0));
            _spriteAnimations.Add("player_walking", new FixedFrameAnimation("player_walking", 16, 16)
                                  .AddFrame(0, 0).AddFrame(1, 0).AddFrame(2, 0).AddFrame(1, 0));
            _spriteAnimations.Add("valgox_aiming", new FixedFrameAnimation("valgox_aiming", 32, 32)
                                  .AddFrame(0, 0));
            _spriteAnimations.Add("projectile", new FixedFrameAnimation("projectile", 12, 12)
                                  .AddFrame(0, 0).AddFrame(1, 0).AddFrame(2, 0).AddFrame(1, 0));

            base.Initialize();
        }