Computer Science Canada What is True? What is False? I dont get it. |
Author: | DanceMacabre [ Mon Apr 17, 2006 6:46 pm ] |
Post subject: | What is True? What is False? I dont get it. |
What does it mean when something is true in turing? or False? how can I use this to move a character on the screen using charpress? |
Author: | Delos [ Mon Apr 17, 2006 7:34 pm ] | ||||
Post subject: | |||||
I'm afraid you'll have to be a little more explicit in what you're asking. Explain your task clearly, show us what you have done so far, and if possible indicate the areas you suspect are giving you problems. As for true/false, I would say they are the same as they are in the real world. You might be specifically referring to Booleans. These are binary variables that are either "true" or "false". For instance:
Notice a few things: in the final if clause, I needn't have explicitely defined the value of the boolean I was comparing:
As for "charpress", no such command exists...there are analogues to it, but again I can't say until you've given us a little more to go on. |
Author: | Cervantes [ Mon Apr 17, 2006 7:43 pm ] | ||||
Post subject: | |||||
In Turing, the only thing that is true is true. The only thing that is false is false. In some other languages, if we need to evaluate a number like 3 (for the purpose of an if statement, for example) to a boolean value, it evaulates to 3. Some languages have 0 evaluate to false when we force it into a boolean, others to true. I'm not sure what "charpress" is, but I'll assume it's like getch. Using getch, we get a single key from the keyboard. We store it in a variable, called key, for example. Now, if key = 'w', we want to move forward (WASD keys, here). Say we press the 'w' key on the keyboard. That sets key to 'w'. So instead of having
we effectively have
Well, it's pretty obvious that 'w' does equal 'w', so this evaluates to true. When the condition given for an if statement is true, we enter the if statement, and execute the code within it. In this case, the code within the if statement would be code to move our player forwards (or up, whatever you choose). Check out the if statements tutorial. I was actually working on fixing that up, though that project has been on hold for a few months. I'll PM you what I've got thus far. It should explain this all very nicely. Edit: Dammit! That's two duel's I've lost today! This one badly. |
Author: | Delos [ Tue Apr 18, 2006 1:38 pm ] |
Post subject: | |
9 minutes Minsc! 9 minutes...that's just wrong. By the way, just saw the screenies of the new syntax highlighting from V3.... Looks awsome. |
Author: | Andy [ Tue Apr 18, 2006 1:48 pm ] |
Post subject: | |
it's okay, I dont know what true and false are neither |