Fangames > Programming Questions
Kamilia color change
(1/1)
Lurpan:
Hey !
Ive been watching a lot of k3 final boss now and i would like to create a game with the color change feature. Can anyone post a pic for the kid code and the objects he can pass throygh with this color change?
klazen108:
Yeah this is a cool gimmick! Here's how I'd implement it :atkHappy:
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:
--- Code: ---if (place_meeting(x,y,player)) with (player) if (color != c_red) killPlayer();
--- End code ---
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:
--- Code: ---if (color==c_red) color=c_blue;
else color==c_red;
--- End code ---
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 :Kappa: )
Lurpan:
Thank you so much klazen :atkLove:
Navigation
[0] Message Index
Go to full version