add random number generator helper extension methods
This commit is contained in:
parent
5a7532a598
commit
4ef2082971
|
@ -228,6 +228,7 @@
|
||||||
<Compile Include="Graphics\EulerPerspectiveCamera.cs" />
|
<Compile Include="Graphics\EulerPerspectiveCamera.cs" />
|
||||||
<Compile Include="Graphics\Helpers\SkyBox.cs" />
|
<Compile Include="Graphics\Helpers\SkyBox.cs" />
|
||||||
<Compile Include="Graphics\Atlas\Json\JsonTextureAtlasAnimation.cs" />
|
<Compile Include="Graphics\Atlas\Json\JsonTextureAtlasAnimation.cs" />
|
||||||
|
<Compile Include="Math\RandomExtensions.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
33
Blarg.GameFramework/Math/RandomExtensions.cs
Normal file
33
Blarg.GameFramework/Math/RandomExtensions.cs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Blarg.GameFramework
|
||||||
|
{
|
||||||
|
public static class RandomExtensions
|
||||||
|
{
|
||||||
|
public static float NextFloat(this Random random)
|
||||||
|
{
|
||||||
|
return (float)random.NextDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float NextFloat(this Random random, float maxValue)
|
||||||
|
{
|
||||||
|
return ((float)random.NextDouble()) * maxValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float NextFloat(this Random random, float minValue, float maxValue)
|
||||||
|
{
|
||||||
|
return ((float)random.NextDouble()) * (maxValue - minValue) + minValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double NextDouble(this Random random, double maxValue)
|
||||||
|
{
|
||||||
|
return random.NextDouble() * maxValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double NextDouble(this Random random, double minValue, double maxValue)
|
||||||
|
{
|
||||||
|
return random.NextDouble() * (maxValue - minValue) + minValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Reference in a new issue