public void SeekPlayer(GameTime gametime, Player player) { UpdateFrame(player); if (position.X < player.position.X) { direction.X = moveRight; speed.X = enemySpeed; } if (position.X > player.position.X) { direction.X = moveLeft; speed.X = enemySpeed; } if (position.Y < player.position.Y) { direction.Y = moveDown; speed.Y = enemySpeed; } if (position.Y > player.position.Y) { direction.Y = moveUp; speed.Y = enemySpeed; } sourceRectangle = new Rectangle(frameSize.X * currentFrame.X, frameSize.Y * currentFrame.Y, frameSize.X, frameSize.Y); destinationRectangle = new Rectangle((int)position.X, (int)position.Y, characterTexture.Width / 2, characterTexture.Height / 1); base.Update(gametime, speed, direction); }
public void Update(Player player) { KeyboardState mKeys = Keyboard.GetState(); UpdateHealth(player); health = (int)MathHelper.Clamp(health, 0, 100); }
public void Update(Player player) { health = player.health; mass = player.mass; hString = "Health: " + health.ToString() + "%"; sString = "Score: " + score.ToString(); mString = "Mass: " + mass.ToString(); score++; }
public void UpdateHealth(Player player) { health = player.health; }
public void UpdateFrame(Player player) { if (player.position.X < position.X) currentFrame.X = 0; if (player.position.X > position.X) currentFrame.X = 1; }
protected override void Initialize() { player = new Player(); enemy = new Enemy(); largeEnemy = new LargeEnemy(); playerHealth = new HealthBar(); stats = new Stats(player); background1 = new Scrolling(Content.Load<Texture2D>("Backgrounds/background1"), new Rectangle(0, 0, screenWidth, screenHeight)); background2 = new Scrolling(Content.Load<Texture2D>("Backgrounds/background1"), new Rectangle(screenWidth, 0, screenWidth, screenHeight)); base.Initialize(); }
String sString; // score string #endregion Fields #region Constructors public Stats(Player player) { health = player.health; mass = player.mass; }
public void Update(Player player) { if (player.position.X >= 700 && player.direction.X == player.moveRight) rec.X -= (int)player.frameSize.X; }