From ba557d98f665505e33659152b4bb40911e4ecbd9 Mon Sep 17 00:00:00 2001 From: Joel Date: Sat, 23 May 2020 20:55:45 +0200 Subject: [PATCH] asd --- Game1/Game1.cs | 4 ++-- Game1/Sources/Crops/Farm.cs | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Game1/Game1.cs b/Game1/Game1.cs index eb32a4b..a4f92a4 100644 --- a/Game1/Game1.cs +++ b/Game1/Game1.cs @@ -44,7 +44,7 @@ namespace Game1 MouseState state; - private int cloudAnimationSpeed = 2; + private int cloudAnimationSpeed = 3; private int cloudFrame = 0; private int cloudSprite; @@ -326,7 +326,7 @@ namespace Game1 { for (int j = -1; j < input.getSize().Y + 1; j++) { - spriteBatch.Draw(Rain, tractorUnit.getFarm().getRainPosition(input.getTileSize(), i, j), new Rectangle(0, cloudSprite * 96, input.getTileSize(), input.getTileSize()), Color.White); + spriteBatch.Draw(Rain, tractorUnit.getFarm().getRainPosition(input.getTileSize(), i, j), new Rectangle(0, cloudSprite * 96, input.getTileSize(), input.getTileSize()), tractorUnit.getFarm().getRainAmount(i, j)); } } } diff --git a/Game1/Sources/Crops/Farm.cs b/Game1/Sources/Crops/Farm.cs index 271c70c..21521e7 100644 --- a/Game1/Sources/Crops/Farm.cs +++ b/Game1/Sources/Crops/Farm.cs @@ -15,7 +15,7 @@ class Farm private Astar astar = new Astar(); private PerlinNoise perlin = new PerlinNoise(); private Vector2 RainPosition; - private Vector2 WindSpeed; + private Vector2 WindSpeed = new Vector2(0,0); private System.Drawing.Color[][] RainfallMap; private float[][] whiteNoise; private float[][] perlinNoise; @@ -137,8 +137,9 @@ class Farm private void updateRainMapPosition() { - float x = WindSpeed.X + (float)r.Next(-5, 5) / 3000; - float y = WindSpeed.Y + (float)r.Next(-5, 5) / 3000; + float x, y; + x = WindSpeed.X + GetRandomNumber(-0.02, 0.02); + y = WindSpeed.Y + GetRandomNumber(-0.02, 0.02); if (x < 0.02f && x > -0.02f) { @@ -168,7 +169,7 @@ class Farm RainPosition.Y = RainPosition.Y + WindSpeed.Y; } resetBitMap++; - if (resetBitMap == 20000) + if (resetBitMap == 100000) { RainPosition.X = r.Next(700, 1300); RainPosition.Y = r.Next(700, 1300); @@ -241,4 +242,9 @@ class Farm { return crops[x, y].getProductionRate(PresetCrops.getPresetCropTypes(Type)); } + + public float GetRandomNumber(double minimum, double maximum) + { + return (float)(Math.Round(r.NextDouble() * (maximum - minimum) + minimum, 2)); + } }