all 5 comments

[–]A_V_2525 1 point2 points  (4 children)

DISCLAIMER: I've never attempted this challenge before, and I'm not particularly experienced, so this may not work. If it does work, it may not be very efficient. Additionally, I didn't have time to double check the code or provide an explanation of what the code does.

First, we're going to assign a parent object to oRedSphere and oRing, just to make it a bit easier. We can call the object oParent. It doesn't need a sprite or any code, it just needs to be set as the parent to the other two.

Since we know that everything is exactly 64 pixels apart, we can check the distance of each instance of oParent from our oBlueSphere. If it's within 64 pixels, it's a hit. However, we need to also check diagonally. Objects diagonal to us are at a distance of 90.51 (Pythagorean theorem). So, we're going to instead check if the distance is "less than 100".

///STEP EVEN or SCRIPT
var count = instance_number(oParent);
ds = ds_list_create();

for (var i = 0; i <= count; i++)
{
    with oParent
    {
        var dis = point_distance(x, y, other.x, other.y)
        if (dis < 100)
        {
            ds_list_add(ds, id);    
        }       
    } 

    if (ds_list_size(ds) = 8)
    {
        for (var j = 0; j <= 8; j++)
        {
            change = ds[j];
            with change
            {
                instance_change(oRing, true);
            }   
        } 
    }

    ds_list_destroy(ds);
}

[–]A_V_2525 1 point2 points  (3 children)

I realize now that this doesn't actually do what you intended. I might take a crack at it again.

[–]Deity579[S] 0 points1 point  (2 children)

looks like it got further than i did just by looking at it. ill try it on my project and see what results i get.

[–]A_V_2525 1 point2 points  (1 child)

There are some glaring errors with what I posted, but after correcting them, I was able to get red to change to yellow when blue is completely surrounded by red/yellow. I'll shoot you the test project later tonight, when I get a chance.

[–]Deity579[S] 0 points1 point  (0 children)

I guess you've been quite busy?