public void updateKnight(GameTime gameTime, SpriteBatch spriteBatch) { myKnight.YPos += (int)velocityY; if (input.IsKeyDown(Keys.Left)) { //Console.WriteLine("moving left"); myKnight.setCurrentAction("run"); myKnight.XPos -= velocityX; myKnight.setCurrentDirection("left"); } else if (input.HasReleasedKey(Keys.Left)) { myKnight.setCurrentAction("idle"); } if (input.IsKeyDown(Keys.Right)) { //Console.WriteLine("moving right"); myKnight.setCurrentAction("run"); myKnight.XPos += velocityX; //knightPos.X += 4; myKnight.setCurrentDirection("right"); } else if (input.HasReleasedKey(Keys.Right)) { myKnight.setCurrentAction("idle"); Console.WriteLine(myKnight.currentActionName); } if (input.IsKeyDown(Keys.Down)) { myKnight.YPos += 4; } if (input.IsKeyDown(Keys.Up)) { myKnight.YPos -= 10; // required amount to get out of box } //velocityY = (int)(GRAVITY * jumpspeed); //myKnight.YPos += velocityY; //jumpspeed = 1; if (input.WasKeyPressed(Keys.Space) && is_grounded == true) { myKnight.YPos -= 15; velocityY = -12; is_grounded = false; } if (is_grounded == false) { float i = 1; velocityY += 0.35f * i; } }
public void patrolling() { enemy.setCurrentAction("run"); enemy.XPos += xVelocity * direction; distanceTrav += 1; if (enemy.XPos <= 3500) { enemy.setCurrentDirection("right"); direction = 1; //distanceTrav += 1; } else if (enemy.XPos >= 4400) { enemy.setCurrentDirection("left"); direction = -1; //distanceTrav -= 1; } }