Hey everyone,
I started learning Java some weeks ago and tried to make a little game. It should be like this game.
I made some walls using rectangles and also a little ball. The collision works really great, but only with one rectangle, wich I wrote in the code like this:
public void checkCollision(){
player = new Rectangle(player.x,player.y,player.width,player.height);
rect = floor_mid;
if (player.intersects(rect)){
stopMovement();
setOffWall(rect);
}
}
And the rectangles i’m using:
public Rectangle floor_south;
public Rectangle floor_north;
public Rectangle floor_east;
public Rectangle floor_west;
public Rectangle floor_mid;
public Rectangle player;
How can I code it so the player would stop on every rectangle?