Package simulation
Class Obstacle
java.lang.Object
simulation.Obstacle
- All Implemented Interfaces:
Drawable
public class Obstacle extends java.lang.Object implements Drawable
Obstacles spread on the map making it harder for species to survive.
-
Constructor Summary
Constructors Constructor Description Obstacle(int xStart, int yStart, int xEnd, int yEnd)
Create new obstacle given start position and end position (obstacles are represented by rectangles). -
Method Summary
Modifier and Type Method Description void
draw(javafx.scene.canvas.GraphicsContext gc)
Function required to draw spmething on the screen.boolean
isInObstacle(double x, double y, int width, int height)
Check if given rectangle with given position is touching obstacle.
-
Constructor Details
-
Obstacle
public Obstacle(int xStart, int yStart, int xEnd, int yEnd)Create new obstacle given start position and end position (obstacles are represented by rectangles).- Parameters:
xStart
- x value of obstacle start position.yStart
- y value of obstacle start position.xEnd
- x value of obstacle end position.yEnd
- y value of obstacle end position.
-
-
Method Details
-
isInObstacle
public boolean isInObstacle(double x, double y, int width, int height)Check if given rectangle with given position is touching obstacle.- Parameters:
x
- x value of the position.y
- y value of the position.width
- width of the rectangle.height
- height of the obstacle.- Returns:
- whether this area is touching the obstacle or not.
-
draw
public void draw(javafx.scene.canvas.GraphicsContext gc)Description copied from interface:Drawable
Function required to draw spmething on the screen.
-