public override void UpdatePosition(GameLevel level) { X += Velocity; Collrect = new Rectangle(X, Y, Width, Height); if (Velocity > 0) { int block = CollDet.CollDetection(Collrect, "right", level); if (block >= 0) { X -= block; Velocity *= -1; } } else { int block = CollDet.CollDetection(Collrect, "left", level); if (block >= 0) { X += block; Velocity *= -1; } } Y += gravity; Collrect = new Rectangle(X, Y, Width, Height); int blockY = CollDet.CollDetection(Collrect, "down", level); if (blockY >= 0) { //Y = blockY - Height; Y -= blockY; Collrect = new Rectangle(X, Y, Width, Height); gravity = 0; } else { gravity += 5; } }
public override void UpdatePosition(GameLevel level) { if (level.hero.position.X + level.hero.Width >= X) { drop = true; } if (drop) { Image = new Surface(@"Sprites\enemies\angryStone.png"); Y += Velocity; Collrect = new Rectangle(X, Y, Image.Width, Image.Height); int block = CollDet.CollDetection(Collrect, "down", level); if (block >= 0) { //Y = block - Image.Height; Y -= block; level.spriteArray[startX, startY] = new AngryStoneGround(X, Y, Video); drop = false; } } }
public int UpdatePosition(GameLevel level, bool checkHit = false) { if (!checkHit) // nodig zodat de raket niet 2maal zo snel gaat wanneer er gesprongen wordt { X -= xVelocity; Y += yVelocity; Collrect = new Rectangle(X, Y, Width, Height); } int heroHit = -5; if (!rocketDown) { if (checkHit) { heroHit = CollDet.CollDetection(Collrect, "heroDown", level); } else { CollDet.CollDetection(Collrect, "heroNotDown", level); } } int block = CollDet.CollDetection(Collrect, "left", level); if (block >= 0 || heroHit >= 0) { Image = new Surface(@"Sprites\enemies\rocketDown.png"); xVelocity = 0; yVelocity = 30; rocketDown = true; } return(heroHit); }