public void checkTimeCollide(object sender, EventArgs e) { PhysicsController.Collide(player);////COLLIDE for (int j = (int)player.posX / MapController.cellSize; j < (player.posX + MapController.cellSize) / MapController.cellSize; j++) { for (int i = (int)player.posY / MapController.cellSize; i < (player.posY + MapController.cellSize) / MapController.cellSize; i++) { if (MapController.map[i, j] == 50) { newCheckPoint = 1; player.OldposX = j * 32; player.OldposY = i * 32; } else if (MapController.map[i, j] == 51) { newCheckPoint = 2; player.OldposX = j * 32; player.OldposY = i * 32; } else if (MapController.map[i, j] == 52) { newCheckPoint = 3; player.OldposX = j * 32; player.OldposY = i * 32; } else if (MapController.map[i, j] == 53) { newCheckPoint = 4; player.OldposX = j * 32; player.OldposY = i * 32; } } } if (player.collidedead) { player.posX = player.OldposX; player.posY = player.OldposY; if (newCheckPoint == 0) { delta.X = 0; delta.Y = 0; } else if (newCheckPoint == 1) { delta.X = 0; delta.Y = -3; } else if (newCheckPoint == 2) { delta.X = -165; delta.Y = -459; } else if (newCheckPoint == 3) { delta.X = -3; delta.Y = -1074; } else if (newCheckPoint == 4) { delta.X = -636; delta.Y = -960; } player.HP = 1000; player.Ih = 0; hearts.currentAnimation = 0; reDrawHearts = true; } for (int i = 0; i < flasks.Count; i++) { double distancetoflask = GetDistance((double)player.posX, (double)player.posY, (double)flasks[i].posX, (double)flasks[i].posY); if (distancetoflask <= 15) { player.HP = 1000; player.setAnimationConfiguration(2); hearts.setAnimation(0); player.Ih = 0; flasks.RemoveAt(i); } } }