Have you ever used a modulus to create color variations in a breeding feature?
I came up with this method a while back and have been using it for a few years with Imagick and GD library.
Let's say we have a pet with different possible spots, stripes, nose markings, and foot markings.
With a modulus, you can have all four marking types controlled by one INT column (instead of having four different columns).
There are 5 nose patterns. The files are named: nose0.png, nose1.png, nose2.png, nose3.png, and nose4.png
There's 6 foot patterns: foot0.png, foot1.png, foot2.png, foot3.png, foot4.png, and foot5.png.
Same thing with spot and stripe patterns, which have 11 and 13 possible layer files respectively.
$markingint is the INT data column for each pet that controls their markings. We set this value, then add this code below it:
$nosepattern = $markingint % 5;
$footpattern = $markingint % 6; //uses up 2 and 3
$spotpattern = $markingint % 11;
$stripepattern = $markingint % 13;
Note that these are all prime numbers, except 6, but we sactifice 2 and 3 to have 6 foot markings.
Using all separate prime numbers allows different marking combinations to be possible.
Anyway...
The images are layered from your image folder as such (in whatever order you want):
"/foot" . $footpattern . ".png";
"/spot" . $spotpattern . ".png";
"/nose" . $nosepattern . ".png";
"/stripe" . $stripepattern . ".png";
So whatever the $markingint is, it'll apply all the different patterns.
Let's look at two example pets.
Pet #1 has $markingint = 87;
This pet will have nose2.png, foot3.png, spot10.png, and stripe9.png.
Pet #2 has $markingint = 145;
Will have nose0.png, foot1.png, spot2.png, and stripe2.png.
In practice, breeding these causes each marking to cycle like this: 0.png 1.png 2.png 3.png 4.png 0.png 1.png 2.png 3.png 4.png, I save the art files to have 0.png aand 4.png to look similar so it feels like you get markings that look similar to the parents when breeding. It's trickier to breed for a specific combination, though, especially if you don't understand the math behind the system.
What do you think? Do you have a better method?
I came up with this method a while back and have been using it for a few years with Imagick and GD library.
Let's say we have a pet with different possible spots, stripes, nose markings, and foot markings.
With a modulus, you can have all four marking types controlled by one INT column (instead of having four different columns).
There are 5 nose patterns. The files are named: nose0.png, nose1.png, nose2.png, nose3.png, and nose4.png
There's 6 foot patterns: foot0.png, foot1.png, foot2.png, foot3.png, foot4.png, and foot5.png.
Same thing with spot and stripe patterns, which have 11 and 13 possible layer files respectively.
$markingint is the INT data column for each pet that controls their markings. We set this value, then add this code below it:
$nosepattern = $markingint % 5;
$footpattern = $markingint % 6; //uses up 2 and 3
$spotpattern = $markingint % 11;
$stripepattern = $markingint % 13;
Note that these are all prime numbers, except 6, but we sactifice 2 and 3 to have 6 foot markings.
Using all separate prime numbers allows different marking combinations to be possible.
Anyway...
The images are layered from your image folder as such (in whatever order you want):
"/foot" . $footpattern . ".png";
"/spot" . $spotpattern . ".png";
"/nose" . $nosepattern . ".png";
"/stripe" . $stripepattern . ".png";
So whatever the $markingint is, it'll apply all the different patterns.
Let's look at two example pets.
Pet #1 has $markingint = 87;
This pet will have nose2.png, foot3.png, spot10.png, and stripe9.png.
Pet #2 has $markingint = 145;
Will have nose0.png, foot1.png, spot2.png, and stripe2.png.
In practice, breeding these causes each marking to cycle like this: 0.png 1.png 2.png 3.png 4.png 0.png 1.png 2.png 3.png 4.png, I save the art files to have 0.png aand 4.png to look similar so it feels like you get markings that look similar to the parents when breeding. It's trickier to breed for a specific combination, though, especially if you don't understand the math behind the system.
What do you think? Do you have a better method?
Last edited by a moderator: