From 5d07477de502eddd1c5af31981a82e39473fc0c5 Mon Sep 17 00:00:00 2001 From: rogo Date: Sat, 23 Mar 2024 19:03:49 +0100 Subject: [PATCH] allowed more rain! --- Scenes/SettingsController.cs | 1 + Scenes/main.tscn | 4 ++-- Scripts/Level.cs | 7 +++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Scenes/SettingsController.cs b/Scenes/SettingsController.cs index 76f84ac..8c1e5a2 100644 --- a/Scenes/SettingsController.cs +++ b/Scenes/SettingsController.cs @@ -1,3 +1,4 @@ +using System.Reflection; using Godot; public partial class SettingsController : VBoxContainer diff --git a/Scenes/main.tscn b/Scenes/main.tscn index e803dae..6499996 100644 --- a/Scenes/main.tscn +++ b/Scenes/main.tscn @@ -8,7 +8,7 @@ script = ExtResource("1_k1i8e") BrushSize = 1 TextureResolution = 0.25 -RainAmount = 0.0 +RainAmount = 5.0 [node name="CanvasLayer" type="CanvasLayer" parent="."] @@ -75,6 +75,6 @@ custom_minimum_size = Vector2(150, 0) layout_mode = 2 size_flags_horizontal = 8 size_flags_vertical = 1 -max_value = 1.0 +max_value = 5.0 step = 0.01 value = 1.0 diff --git a/Scripts/Level.cs b/Scripts/Level.cs index f2b740d..726b0c4 100644 --- a/Scripts/Level.cs +++ b/Scripts/Level.cs @@ -45,8 +45,11 @@ public class Level { } private void MakeItRain(float rainAmount) { - if (GD.Randf() < rainAmount) { - WritePixel((int)(GD.Randi() % SizeX), 0, 1); + int rainDrops = (int)Math.Round(rainAmount); + + for (int i = 0; i <= rainDrops; i++) { + if (GD.Randf() < rainAmount) + WritePixel((int)(GD.Randi() % SizeX), 0, 1); } }