The Daily Click ::. Forums ::. Klik Coding Help ::. What are flags?
 

Post Reply  Post Oekaki 
 

Posted By Message

G. Hull



Registered
  07/01/2009
Points
  125

Wii Owner
10th January, 2009 at 04:07:34 -

Hello people, my question is, what are flags? This question is about MMF2 flag, I'm not sure if any other game makers have flags. Please reply.

Thanks, Rannug

 
n/a

Silveraura

God's God

Registered
  08/08/2002
Points
  6747

Game of the Week WinnerKlikCast StarAlien In Training!VIP Member360 OwnerWii OwnerSonic SpeedThe Cake is a LieComputerChristmas Tree!
I am an April Fool
10th January, 2009 at 04:12:08 -

Flags are basically markers that are associated with objects that can be marked on or off. They are called for by a value between 0 and 32.
So basically if you set an objects Flag 1 to On, then you can use the condition "Is Object Flag 1 On" and it will fire.

The 2 major significance in flags are basically 1, they are a lot more simple then alterable values, since they can be more specific to simply being On and Off, while alterable values are better suited for unlimited values. And one major significance to flags is simply that they can be toggled. This takes a way a small amount of complexity in the code, which over time, can mean dropping a good 2 to 10 or more events from your code if your game gets big.


Sorry, this post is kind of long for something so simple. I assure you, flags aren't complex at all, even if I kind of made them seem like it. They are just markers that turn On and Off.

 
http://www.facebook.com/truediamondgame

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
10th January, 2009 at 04:13:59 -

Flags are very simply a way of keeping track of things. You can set a flag to being on or off.

For instance, you can use flags to determine whether or not you have selected something that you want to cling to the mouse.

Upon clicking Object A > Set Object A's Flag 0 to on.

Object A's flag 0 is on > SET X Position to XMouse and Y position to YMouse.



There are an infinite amount of things you can use flags for. Just remember that if you want to keep track of anything, you can use a flag. (BTW, I put flag 0 simply because it is the first available one.)

Hope that makes sense.

EDIT: Whoops, BrandonC beat me to it. But really, they are fairly simple. You can use them for literally anything and everything. Essential to any mid-sized game, probably.

Edited by OMC

 

  		
  		

Deleted User
10th January, 2009 at 04:19:00 -

I'm used to hearing them being compared to a light switch. Think of them like that.

 

-J-



Registered
  05/10/2008
Points
  228

VIP MemberThe Cake is a Lie
10th January, 2009 at 04:21:27 -

Flags are just variables that can only hold two values (on and off)

Objects can have up to 32 flags I think, so say you are trying to edit an "enemy" object's 14th flag.

You could use the flag to say whether or not the enemy has seen the player, so it could be something like this:

+Enemy sees player
> turn flag 14 of enemy on

+Enemy can't see player
> turn flag 14 of enemy off

+ Enemy's flag 14 is on
> Chase the player and kill him

That's pretty self explanatory...

You can also toggle flags, which if a flag is on, changes it to off and vice-versa. So you could use for something like this:

+User clicked on light-switch
> toggle flag 7 of light-switch

+ flag 7 of light-switch is on
>Display a bright light

+ flag 7 of light-switch is off
>Display darkness

That's also quite self explanatory.

On important thing to remember about flags is that they are off by default, so in this case, before the user has clicked the light-switch, there is darkness being displayed because flag 7 is set to off by default and the start of the frame.

Flags are handy because they don't use as much memory as alterable values and are easily toggled. If you've ever learnt a programming language like C++ or Java, flags are kind of the MMF2 equivalent of boolean variables, which only return a 0 or 1 value.

 
n/a ...

Ski

TDC is my stress ball

Registered
  13/03/2005
Points
  10130

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!KlikCast HelperVIP MemberWii OwnerStrawberryPicture Me This Round 28 Winner!PS3 OwnerI am an April Fool
Candy Cane
10th January, 2009 at 04:23:11 -


Originally Posted by jneumann1
I'm used to hearing them being compared to a light switch. Think of them like that.



Yes, that's exactly how I think of them. Sometimes people make things seem so much more complex than they are.

 
n/a

-J-



Registered
  05/10/2008
Points
  228

VIP MemberThe Cake is a Lie
10th January, 2009 at 04:25:20 -

I just tried to edit my post as "Looks like you guys beat me to it" but by the time I'd written that, Adam had already made a reply, so I guess I'll say:

Looks like you beat me to beating me to it, Adam.

 
n/a ...

Silveraura

God's God

Registered
  08/08/2002
Points
  6747

Game of the Week WinnerKlikCast StarAlien In Training!VIP Member360 OwnerWii OwnerSonic SpeedThe Cake is a LieComputerChristmas Tree!
I am an April Fool
10th January, 2009 at 05:11:10 -


Originally Posted by -Adam-

Originally Posted by jneumann1
I'm used to hearing them being compared to a light switch. Think of them like that.



Yes, that's exactly how I think of them. Sometimes people make things seem so much more complex than they are.



Because some people have enough respect to share their critical thinking with others. It's just not always wanted, or presented in the way that any sane person would easily be able to comprehend. You make it sound like a bad thing.

But yes, flags at their most simple form, are best compared to a light switch.

Edited by Silveraura

 
http://www.facebook.com/truediamondgame

UnknownAlly



Registered
  01/09/2007
Points
  195
10th January, 2009 at 05:21:08 -

Flags are banners used by countries, and states.

They display the national colors etc.

 
-UnknownAlly http://unknownally.110mb.com

G. Hull



Registered
  07/01/2009
Points
  125

Wii Owner
10th January, 2009 at 05:28:46 -

Hey, thanks guys, all those explanations make sense, now I finally understand flags, once again, you guys were extremely helpful, happy game making!


Regards,

-Rannug

 
n/a

G. Hull



Registered
  07/01/2009
Points
  125

Wii Owner
10th January, 2009 at 05:39:11 -

Just came up with another question. How do you get to the flags for an item? Here's an example, I'm trying to make a double jump for a character, making it so when it reaches its apogee it tuns on its "Jump" flag and jumps one more time. Is that the best way to do that, or do you have any other suggestions?

 
n/a

aphant



Registered
  18/05/2008
Points
  1242
10th January, 2009 at 06:10:06 -

The conditions for flags are listed under "alterable values," while events are listed under "flags."

To make a reliable double jump, I find that it's best to use a combination of an alterable value and flags. Use the flags to denote that you've jumped, and the alt value to measure when you're able to make the second jump. Using two flags gives you the ability to denote that you made the first jump, if you don't want players to walk over an edge and be able to double jump away.

There are multiple ways to do a double jump, though. I don't use the method I mentioned, because I find it rather primitive.

EDIT: I should point out that if you're using a custom platform movement that uses an alterable value to control "gravity," then you can just make a range check on that value instead of using a new value.

Edited by aphant

 

G. Hull



Registered
  07/01/2009
Points
  125

Wii Owner
10th January, 2009 at 06:40:41 -

Thanks Adam, although it's still a little confusing, i appreciate the effort.


-Rannug


 
n/a

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
10th January, 2009 at 07:20:17 -

Sometimes it's better to write the code yourself and figure it out. It's easier to understand if you write it yourself.. but better to write it on paper first, in English (not code) if you can't figure out what to do.

(This does the first jump. The flags check if the character is already jumping/double jumping)
On Pressing jump
AND Flag 0 of Character is off
AND Flag 1 of Character is off
> Turn Flag 0 of Character on.
> [Jumping code]

(This does the code for the second jump. It only works if the character hasn't double jumped)
If Flag 0 on
AND Flag 1 off
AND On pressing jump:
> Turn Flag 1 on
> [Double jump code]

(On hitting the ground, reset flags)
If Character touches ground:
> Turn Flag 0 off
> Turn Flag 1 off

Also, on the topic of flags, you should know that there are only 32 flags in MMF2. From Flag 0 to Flag 31. The others are fake, trying to confuse you. Maybe you knew that, but I didn't know it, until I messed up my game using something like Flag 322

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image

UnknownAlly



Registered
  01/09/2007
Points
  195
10th January, 2009 at 12:51:21 -

Ooow, double jump sounds fun.

 
-UnknownAlly http://unknownally.110mb.com
   

Post Reply



 



Advertisement

Worth A Click