public void Update(GameTime gameTime) { if (current == null) return; deltaTime = gameTime.ElapsedGameTime.Milliseconds; if(punching) { animationPlayTime += deltaTime; if (animationPlayTime > 0.46f) current = idle; } velocity.Y += (deltaTime / 100) * 2; HandleInput(); position += velocity; Landed(); current.Update(gameTime, (int)position.X, (int)position.Y); deltaTime = 0; }
public void Load(ContentManager Content) { sheet = Content.Load<Texture2D>("RyuSheet"); if (sheet != null) { idle = new Animation(0, 5, 48, 82, 9, sheet); jump = new Animation(0, 267, 40, 90, 6, sheet); punch = new Animation(0, 89, 50, 80, 6, sheet); } input = new PlayerInput(Keys.Up, Keys.Down, Keys.Left, Keys.Right, Keys.Space); current = idle; }
private void Landed() { if (position.Y > 400) { if (landed == false) { landed = true; //current.Stop(); current = idle; current.Start(); } position.Y = 400; jumping = false; } }
public void Punch() { punching = true; current = punch; }
//velocity.Y += (deltaTime / 100) * 2; private void Jump() { jumping = true; landed = false; velocity.Y = (deltaTime / 100) * -50; if(current != jump) { //current.Stop(); current = jump; current.Start(); } }