Ejemplo n.º 1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Menu

            _world = new World();
            _world.Hero = new Hero();

            spriteBatch = new SpriteBatch(GraphicsDevice);
            _keyboard = new KeyboardHandler();

            base.Initialize();
        }
Ejemplo n.º 2
0
 public void fall(World w)
 {
     if (Position.Y >= 300)
     {
         Position = new Vector2(
             Position.X,
             300
         );
         _lockJump = false;
     }
     else
     {
         _lastJump = 500.0f;
         Position = new Vector2(
             Position.X,
             Position.Y + 10
         );
     }
 }
Ejemplo n.º 3
0
        public void inGame(World _world, GameTime gameTime)
        {
            KeyboardState ks = Keyboard.GetState(PlayerIndex.One);
            if (ks.IsKeyDown(Keys.Right))
            {
                _world.Hero.move(new Direction(10, 0));
            }
            if (ks.IsKeyDown(Keys.Left))
            {
                _world.Hero.move(new Direction(-10, 0));
            }

            if (ks.IsKeyDown(Keys.X))
            {
                _world.Hero.jump(_world, gameTime);
            }
            else
            {
                _world.Hero.fall(_world);
            }

            if (ks.IsKeyDown(Keys.W))
            {
                _world.Hero.paperDart();
            }
            if (ks.IsKeyDown(Keys.C))
            {
                _world.Hero.clone();
            }
            if (ks.IsKeyDown(Keys.F))
            {
                _world.Hero.fold();
            }
            if (ks.IsKeyDown(Keys.B))
            {
                _world.Hero.ball();
            }
        }
Ejemplo n.º 4
0
 public void Handle(World _world, GameTime gameTime)
 {
     _realHandler(_world, gameTime);
 }
Ejemplo n.º 5
0
 public void jump(World w, GameTime gameTime)
 {
     if (_lockJump)
     {
         _lastJump += gameTime.ElapsedGameTime.TotalMilliseconds;
         if (_lastJump < 500.0f
             && _isInBound(w))
         {
             float tmp = (float)(_lastJump*_lastJump);
             Position = new Vector2(
                 Position.X,
                 Position.Y - 25000/tmp
             );
         }
         else
         {
             fall(w);
         }
     }
     else
     {
         _lockJump = true;
         _lastJump = .0f;
     }
 }
Ejemplo n.º 6
0
 private bool _isInBound(World w)
 {
     return true;
 }