Page 1 of 1

Tip: Use an a/b choice.

Posted: Fri Nov 05, 2004 1:26 am
by Wargod2293
This tip was designed for beginners in Qbasic. The following can be used for a process in which you need somthing to happen on/off repeatedly.

Code: Select all

variable = 0
do
if variable > 1 then
variable = variable - 2
end if
loop until vatiable < 2
if variable = 1 then

step 1

else

step 2

end if
This is probably basic knowledge to all of you, but I'm only in the ninth grade and have only made a handful of games, and therefore this is useful to my peers.

Posted: Sat Nov 06, 2004 1:37 am
by Buff
How about this.

Code: Select all

If YourChoice& then
  YourChoice&=0
else
  YourChoice&=1
end if
Print something on the screen here

'somewhere else  in the program
'responds to the 'choice' you made
If YourChoice& then
  yourcode here
else
  yourcode here
end if

Use an a/b choice

Posted: Sat Dec 25, 2004 6:08 am
by Visiter
If, for example, you are toggling between two players in a game I like to use:

Code: Select all

Player% = -Player%
So Player% will always equal either one (1) or negative one (-1) and will toggle from one to the other each time the instruction is executed.

I'm not certain what your objective is.

Regards.

Posted: Sat Dec 25, 2004 9:14 am
by Dr_Davenstein
Why not just use a boolean operator? ;)

switch = NOT switch

If switch Then
'Evaluate
Else
'Dont
End If

That's the method I prefer.