fixed stuck rain
refactoring
This commit is contained in:
@@ -84,8 +84,11 @@ public class Level {
|
||||
int rainDrops = (int)Math.Round(rainAmount);
|
||||
|
||||
for (int i = 0; i <= rainDrops; i++) {
|
||||
if (GD.Randf() < rainAmount)
|
||||
WritePixel<Water>((int)(GD.Randi() % (chunkResX * chunksPerX)), 0, 1);
|
||||
if (GD.Randf() < rainAmount) {
|
||||
int d = (int)(GD.Randi() % (chunkResX * chunksPerX));
|
||||
if (GetElement(d, 0).IsEmpty())
|
||||
WritePixel<Water>(d, 0, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,6 +148,13 @@ public class Level {
|
||||
}
|
||||
}
|
||||
|
||||
public Element GetElement(int x, int y) {
|
||||
if (x < 0 || x > chunkResX * chunkResX) return null;
|
||||
if (y < 0 || y > chunkResY * chunkResY) return null;
|
||||
|
||||
return chunks[x / chunkResX, y / chunkResY].Elements[x % chunkResX, y % chunkResY];
|
||||
}
|
||||
|
||||
public Image DrawLevel() {
|
||||
// chunk
|
||||
for (int cx = 0; cx < chunksPerX; cx++) {
|
||||
|
||||
Reference in New Issue
Block a user