bool Bomberman::collision(Wall wall) { if(y + width <= wall.getY()) return 0; if(x + length <= wall.getX()) return 0; if(y >= wall.getY() + wall.getWidth()) return 0; if(x >= wall.getX() + wall.getLength()) return 0; return 1; }
bool Stage::isShipInWall(double x, double y) { for (int z = 0; z < numWalls_; z++) { Wall *wall = walls_[z]; double left = wall->getLeft(); double bottom = wall->getBottom(); if (x > left && x < left + wall->getWidth() && y > bottom && y < bottom + wall->getHeight()) { return true; } } Circle2D *shipCircle = new Circle2D(x, y, SHIP_RADIUS); for (int z = 0; z < numWallLines_; z++) { Line2D* line = wallLines_[z]; if (shipCircle->intersects(line)) { delete shipCircle; return true; } } delete shipCircle; return false; }