re-enabled rain
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using FOU.Scripts.Elements;
|
||||
using Godot;
|
||||
|
||||
namespace FOU.Scripts;
|
||||
|
||||
@@ -16,6 +18,9 @@ public class Level {
|
||||
private int chunkResX;
|
||||
private int chunkResY;
|
||||
|
||||
private bool enableRain = false;
|
||||
private float rainAmount = 0;
|
||||
|
||||
public Level(Main main, int sizeX, int sizeY) {
|
||||
GD.Print($"Generating level ({sizeX}:{sizeY}) with {chunksX*chunksY} chunks ({chunkResX} * {chunkResY})");
|
||||
|
||||
@@ -51,18 +56,25 @@ public class Level {
|
||||
}
|
||||
|
||||
public void Update() {
|
||||
MakeItRain();
|
||||
|
||||
foreach (Chunk c in chunks)
|
||||
c.Update();
|
||||
}
|
||||
|
||||
// TODO!
|
||||
private void MakeItRain(float rainAmount) {
|
||||
// int rainDrops = (int)Math.Round(rainAmount);
|
||||
//
|
||||
// for (int i = 0; i <= rainDrops; i++) {
|
||||
// if (GD.Randf() < rainAmount)
|
||||
// WritePixel<Water>((int)(GD.Randi() % SizeX), 0, 1);
|
||||
// }
|
||||
public void SetRainAmount(float amount) {
|
||||
rainAmount = amount;
|
||||
}
|
||||
|
||||
private void MakeItRain() {
|
||||
if (rainAmount < .1f) return;
|
||||
|
||||
int rainDrops = (int)Math.Round(rainAmount);
|
||||
|
||||
for (int i = 0; i <= rainDrops; i++) {
|
||||
if (GD.Randf() < rainAmount)
|
||||
WritePixel<Water>((int)(GD.Randi() % (chunkResX * chunksX)), 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void WritePixel<T>(int x, int y, int size) {
|
||||
|
||||
Reference in New Issue
Block a user