Page 1 of 1

URGENT

PostPosted: Wed Jan 14, 2009 4:18 am
by Hedfone
ok so i desperately need some code before tomorrow morning.
I need to know how to make a light switch on and off on a click.

I have a variable named "Power" and when power==1 i want the light to turn on and when power==0 the light should turn off. but then when it's clicked a third time the light should turn on again. (Power==0) and so on and so on. i've been working on this for the last 2 hours and if i can't get it done soon my art project (a game) will be totally useless. please help!

Re: URGENT

PostPosted: Wed Jan 14, 2009 4:21 am
by DST
Code: Select all
switch(power)
{
case 0:
light turns on
power=1;
break;
case 1:
light turns off
power=0;
break;
}

Re: URGENT

PostPosted: Wed Jan 14, 2009 4:26 am
by Hedfone
thank you SO much, i really can't even get close to expressing how much you just saved me there

Re: URGENT

PostPosted: Wed Jan 14, 2009 9:51 am
by Fuzzy
power = abs(power-1);

Re: URGENT

PostPosted: Wed Jan 14, 2009 9:28 pm
by Rux
I haven't seen you forever Head Phone! Welcome Back :?: