Yeah this is a cool gimmick! Here's how I'd implement it
First off, we all know most deadly objects in fangames have "playerKiller" as their parent:
For this gimmick, the color-dependent objects you make (I'm going to refer to them as red/blue just for the sake of clarity, they don't have to be only red/blue)
should not do this. Instead, make two new objects, redPlayerKiller and bluePlayerKiller. Inside each of these, add an end step event with the following code:
if (place_meeting(x,y,player)) with (player) if (color != c_red) killPlayer();
Note that the code above is for the redPlayerKiller, make sure to change
c_red to
c_blue for bluePlayerKiller! You can kinda read it like a sentence: "if I'm touching the player, then if the player's color isn't red, kill him" - that's what we want!
Now, you make your red/blue killer objects, and give those objects
redPlayerKiller and
bluePlayerKiller for parents.
For the player, add a Key Press <Up> event (can be any key you want, I think it was up in K3?) and add the following code:
if (color==c_red) color=c_blue;
else color==c_red;
This will switch the color between red & blue.
In order to show the user what color he has selected, you can draw some white object above him; use player.color for the image_blend and it'll show you the color you are! Take a look at this example object to see what I mean:
Just give that a white sprite, and it'll be tinted red if the player has selected red, and blue if the player selected blue.
Note that the player's going to start out with no color - so make sure you set
color=c_red or
color=c_blue in the player's create event, or you can add the player's color to the save code (an exercise left to the reader
)