This site requires JavaScript, please enable it in your browser!
Greenfoot back
vampire-wannabe
vampire-wannabe wrote ...

2015/6/2

How do you use flags??

vampire-wannabe vampire-wannabe

2015/6/2

#
so I've been looking online and it doesn't have a tutorial on how to use flags in greenfoot and I'm trying to do the Greeps competition.. I need to set a flag at the tomato piles but i'm not sure how to do it. PLEASE HELP!!
xWanna xWanna

2015/6/2

#
What you mean with "set"? You want to place a picture on the tomato? If yes, there are two ways. First you can edit the photo with gimp or another software for Photoediting. Secondly you can place the picture in Greenfoot. If you have the class with the tomato picture you have to say:
1
2
3
4
5
GreenfootImage img = new GreenfootImage("Name of picture"); // Tomato
img.drawImage(img, x ,y); // replace x and y with coordinates
GreenfootImage im = new GreenfootImage("Name of picture"); //Flag
img.drawImage(im, x, y); //set x and y so it fits with tomato
setImage(img);
This should work I think
danpost danpost

2015/6/2

#
The Creature class has two methods that deal with the flags (a: setter method) public void setFlag(int flagNo, boolean val) (b: getter method) public boolean getFlag(int flagNo) The two flags available (flagNo can only be '1' or '2') can be used to store any boolean value you desire. Say you wanted to "remember" a specific state of being (i.e. at water; at tomato pile; following a specific type of spit trail; whatever), that state can be saved and retrieved later using those methods. You can "remember" either two different states or you can remember one state that has three to four different possible states (for instance: case 1: not following spit; other cases: following specific color spit).
davmac davmac

2015/6/2

#
To put it another way: A flag is just a boolean variable (a boolean variable holds a truth value, either true or false). But in the case of Greeps, you can only set or check the value of this variable via the methods provided (setFlag and getFlag). You said:
I need to set a flag at the tomato piles but i'm not sure how to do it.
It should be pretty obvious that to set a flag you call the setFlag method. So, what is really the problem? See here for some guidance on how to ask your question in a way that allows people to actually help you.
vampire-wannabe vampire-wannabe

2015/6/3

#
@xWanna I mean that I need to set a flag at the tomato so one greep stays there while he helps the rest load the tomato onto their backs. I don't know how to do this..
vampire-wannabe vampire-wannabe

2015/6/4

#
@davmac the problem is I'm stupid and I need to set a flag at the tomato so one greep stays there while he helps the rest load the tomato onto their backs. I don't know how to do this..
You need to login to post a reply.