• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Help my Plase

RedboyX

Member
I wanted to make a flashlight system for a horror rpg plus I'm still very new to the game maker and I'm not managing to do this try to leave the system more youPress the F key and the flashlight lights up and pressing f again the flashlight turns off both with sound effects let the code so more still do not know how to do this could someone help me please

if (keyboard_check_pressed(ord("F"))) {
light =+ 1;
}

if (light == 1) {
object_set_visible(obj_light,true)

}else if (light == 0 ) {
object_set_visible(obj_light,false)
}
if (light >= 2) {
light = 0;
}
 

obscene

Member
Code:
if (keyboard_check_pressed(ord("F"))) {
     light = !light;
}
Assuming you start light with a default value of 1 or -1, this will swap between them. Also, object_set_visible() will set EVERY obj_light visible/invisible, so if you add multiple lights this isn't how you want to do it.

Also, use the [ code ] [ / code ] tags on the forum, it preserves the formatting.
 
Top