Friday, 10 April 2015

Possibly the Point of No Return

Oh, this is great! I just had a "yes, it's starting to come together" moment. Just a minor thing, but it felt like a milestone.



Here's the game when you start:






And here it is after running for a while:


It might not look like much, but what's happened there is the light and dark dots are spreading their influence over the neutral ones and converting them to their causes.

In under-the-hood terms, each dot has a value, lightMeter, which can vary from 0-100. Neutrals start with it at 50 (I may randomise that later), light dots at 100 and dark ones at 0. Each step, the neutrals check if they're close enough to a dark or light dot to be influenced (I've created a global variable called influenceDistance, currently set at 30). The distance is checked with distance_to_object. Here's the section for neutral dots being influenced by the dark dots (I call them "People" in the code, as thats what they represent, regardless of the current graphics!):

// Influenced by Dark People

if distance_to_object (oPersonDark) < influenceDistance
{
    lightMeter = ( lightMeter - influenceSpeed);
}

In simple terms, each step, if the distance from the neutral dot to the nearest dark dot is less than 30 (the global value stored in influenceDistance), then the neutral dot's lightMeter value is reduced by 0.2 (which is what influenceSpeed is set as). Next:

// Transformations based on Lightmeter

if ( lightMeter < 1 )
{
    //transform to oDarkPerson
    instance_change (oPersonDark, true);
}

Thats the bit that changes the formerly neutral dots into a dark one. instance_change is what changes the neutral dot into a dark one (oPersonDark is the object it's changing into). The second value in the bracket is either "true" or "false" and it refers to whether or not to run the new object's create code. Seeing as all I have in the oPersonDark create code is the lightMeter being set to 0, I've put "true" here but it doesn't make much difference in this particular case.

I've left the game running while I wrote this. It looks like the black dots have won 8:6 against the light ones this time - there are no neutrals left to convert. Which reminds me, once I put in the code to allow light and dark dots to also be influenced, I'll need to add in code to the buildings so they can spawn new dots..

Anyway, I'm off to celebrate this update with a cup of tea. I'm such a party animal..

No comments:

Post a Comment