URGENT

Non-platform specific questions.

URGENT

Postby Hedfone » Wed Jan 14, 2009 4:18 am

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!
User avatar
Hedfone
 
Posts: 174
Joined: Mon Jul 31, 2006 9:47 pm
Score: 2 Give a positive score

Re: URGENT

Postby DST » Wed Jan 14, 2009 4:21 am

Code: Select all
switch(power)
{
case 0:
light turns on
power=1;
break;
case 1:
light turns off
power=0;
break;
}
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: URGENT

Postby Hedfone » Wed Jan 14, 2009 4:26 am

thank you SO much, i really can't even get close to expressing how much you just saved me there
User avatar
Hedfone
 
Posts: 174
Joined: Mon Jul 31, 2006 9:47 pm
Score: 2 Give a positive score

Re: URGENT

Postby Fuzzy » Wed Jan 14, 2009 9:51 am

power = abs(power-1);
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Re: URGENT

Postby Rux » Wed Jan 14, 2009 9:28 pm

I haven't seen you forever Head Phone! Welcome Back :?:
I'm not good at coming up with signatures...
User avatar
Rux
 
Posts: 645
Joined: Sun Apr 29, 2007 9:26 pm
Location: Sitting on your moniter invisable.
Score: 35 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron