Hi!
Can someone explain me how flags works and global value?
I think I need to know a little bit more about it to continue with my game.
Thanks :)
Printable View
Hi!
Can someone explain me how flags works and global value?
I think I need to know a little bit more about it to continue with my game.
Thanks :)
Global values are variables that can be set and received on any frame.
Flags are like Global values but can only be set to 2 values: 0 (off) and 1 (on). Also, their data is not carried between frames.
Makes sense?
Flags can be set to either on or off
You can then test the value of the flag
So for example
If your character needs a key to open a door
You can set a flag to "ON" when it gets the key
Then you can test for the flag to be "ON" so the character can open the door
Global Value/Global Strings
also
Alterable Values/Alterable Stings
These are all areas to store data in
(Called variables in other languages)
The global ones are for your entire application.
You can get to them on any frame and the data entered into them exist for the entire run of your game.
The alterable values and strings on certain objects (Active for example) are data storage areas that are specific to that object only.
Thank you :)
If I get a key, I set the flag to "on", so I can open the door?
And when I open the door, I don't have any more key left and then I set the flag to "off"? Flag "on" = open door, Flag "off" = close door.
Is this right?
Yes. That's right. If you have more than one key, though, you may want to use global values. You would name a global value "keys." When the player gets a key, add 1 to that value. When the player opens a door, subtract 1 from that value. To test to see if the player can open the door, test if global value "keys" is greater than 0.
So, it's better to use global values instead of alterable values?
It depends on how you are making your game. If you need the data in other frames, use a global value. If you don't, use an alterable value or a counter.
Thanks for the help. I fixed it :)
Just one other question. If I have a green key to the green door and a red key to the red door, Should I for example use flag 0 on green door and flag 1 on red door?
Yes