Commit a0ebf39a authored by Lucas Delcros's avatar Lucas Delcros

start to resolve spawnning on water bug

parent 39efe8a3
......@@ -138,11 +138,12 @@ public final class MapBuilder implements Serializable{
surroundSurfaceWithWalls(map, surface);
}
}
private static void addWaterRandomly (TileBuilder[][] map, Surface room, double p){
private void addWaterRandomly (TileBuilder[][] map, Surface room, double p){
Random r = new Random();
if (r.nextDouble() <= p){
int dw = r.nextInt((room.width-2)/2)+1, dh = r.nextInt((room.height-2)/2)+1;
fillSurfaceWith(map, new Surface(room.i1+dh, room.j1+dw, room.i2-dh, room.j2-dw), TileType.WATER);
Surface s = new Surface(room.i1+dh, room.j1+dw, room.i2-dh, room.j2-dw);
if(!s.isOnSurface(positionPlayerAtStart) && !s.isOnSurface(stairsPosition))fillSurfaceWith(map, s, TileType.WATER);
}
}
......
......@@ -21,4 +21,8 @@ public class Surface implements Serializable{
public boolean checkSurface(){
return (height>0 && width>0);
}
public boolean isOnSurface(MapPoint mp){
return mp.getI() >= i1 && mp.getI() <= i2 && mp.getJ() >= j1 && mp.getJ() <= j2;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment