So I'm quite new to programming in general. I'm currently working on a terrain generation program, everything is going great except for this:
public static class Desert
{
public const int iChance = 15;
public static int chance = iChance;
public static int chancepoint = 0;
public const int octaves = 4;
public const int lengthMin = 60;
public const int lengthMax = 90;
public const float scaleMin = 250;
public const float scaleMax = 350;
public const float persistenceMin = 0.5f;
public const float persistenceMax = 0.9f;
public const pType ptype = pType.Lowland;
public const bTag[] tags = { bTag.desert };
}
public static class Meadow
{
public const int iChance = 45;
public static int chance = iChance;
public static int chancepoint = 0;
public const int octaves = 4;
public const int lengthMin = 45;
public const int lengthMax = 70;
public const float scaleMin = 200;
public const float scaleMax = 470;
public const float persistenceMin = 0.35f;
public const float persistenceMax = 0.70f;
public const pType ptype = pType.noAbs;
public const bTag[] tags = { bTag.lush };
}
These are the properties for each different type of 'Biome'.
I currently have about 7 of these and they're all exactly the same except for the values of each field.
Is there a way that I can shorten the code? I looked into inheritance but I ended up with errors and I got a little confused. ><
It would be brilliant if all I had to write was:
public static class Desert
{
iChance = 15;
chance = iChance;
chancepoint = 0;
octaves = 4;
lengthMin = 60;
lengthMax = 90;
scaleMin = 250;
scaleMax = 350;
persistenceMin = 0.5f;
persistenceMax = 0.9f;
ptype = pType.Lowland;
strongTags = { bTag.desert };
}
Thanks in advance.
Oh, and sorry about the nubness of the question, you would probably scream at how terrible my code was if you saw the rest of the program. XD
EDIT: It's probably wise to tell you that I NEVER change the stuff within the class again with the exception of the value of 'chance'.