/// <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(); }
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 ); } }
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(); } }
public void Handle(World _world, GameTime gameTime) { _realHandler(_world, gameTime); }
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; } }
private bool _isInBound(World w) { return true; }