public override void Update(GameTime gametime) { base.Update(gametime); rectangle = new Rectangle((int)position.X, (int)position.Y,92,132); if (move) { position.Y += 1; foreach (blok blok in TestLevel.Tiles) { if (rectangle.Intersects(blok.rectangle)) { if (rectangle.TouchTopOf(blok.rectangle)) { position.Y--; } else if (rectangle.TouchLeftOf(blok.rectangle)) { position.X = blok.rectangle.X - rectangle.Width; } else if (rectangle.TouchRightOf(blok.rectangle)) { position.X = blok.rectangle.X + rectangle.Width; } } } } }
public void Update(GameTime gametime) { rectangle = new Rectangle((int)position.X, (int)position.Y, 40, 80); Center = new Vector2(position.X + rectangle.Width / 2, position.Y + rectangle.Height / 2); position.Y += 1; if (FrameIndex == 15) { FrameIndex = 5; } foreach (blok blok in TestLevel.Tiles) { if (rectangle.Intersects(blok.rectangle)) { if (rectangle.TouchTopOf(blok.rectangle)) { position.Y--; } else if (rectangle.TouchLeftOf(blok.rectangle)) { position.X = blok.rectangle.X - rectangle.Width; } else if (rectangle.TouchRightOf(blok.rectangle)) { position.X = blok.rectangle.X + rectangle.Width; } } } }