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

2011/6/11

On fixing 'Infect'

1
2
3
4
5
kiarocks kiarocks

2011/6/13

#
how would i write that? and sorry for the code-its from the wombat scenario. and , you dont have to tell me, but what time zone are you in?
kiarocks kiarocks

2011/6/14

#
how would i do such?
danpost danpost

2011/6/14

#
I am in Eastern Daylight Time- U.S. Do you want me to upload something called 'epidemic' that would be your scenario with code to see how I would do it?
kiarocks kiarocks

2011/6/14

#
im in pacific and sure
danpost danpost

2011/6/14

#
As soon as you have it, let me know. I will remove it immediately.
danpost danpost

2011/6/14

#
It has been removed. Let me know what you think. If you have any questions about it, I would be glad to help (if possible).
kiarocks kiarocks

2011/6/14

#
ok, now how would you add the infected Boolean thing? With integer?
danpost danpost

2011/6/14

#
I am not sure what you are asking. If you already added the 'private boolean gotInfected = false;' from my post 22 hours ago, then is it that you do not know how to make use of the boolean variable (where to put the code to make use of it). If you already added it and are using it, then are you asking how can you convert it to an integer and make use of it that way?
kiarocks kiarocks

2011/6/14

#
danpost wrote...
As far as preventing infecteds from changing again, give UnInfecteds a boolean (true/false) variable, call it something like 'gotInfected' as such (add the line below 'private int direction')
private boolean gotInfected = false;
Then, when infecting, if this value is 'false', infect and change the value to 'true', else do not infect (again). Actually, you could make it an integer set to zero, and track the stage of infection; the higher the value, the worse the case of infection. If the value is zero, he is not infected yet.
no im not using it now. how do i use it? how would i use integer set to zero?
danpost danpost

2011/6/14

#
Instead of:
private boolean gotInfected = false;
insert the line:
private int infectionStage = 0;
Then, where your code is checking to infect, use:
if (infectionStage == 0) { infect(); } else { infectWorse(); }
or something like that. You would need to add a method 'infectWorse' -- something that would show that the infection has worsened, and increment 'infectionStage'.
kiarocks kiarocks

2011/6/14

#
how would i increase something? Like the infection stage.
kiarocks kiarocks

2011/6/14

#
never mind, is it possible for something to change class? like the Uninfected turns in to a InfectLv1?
danpost danpost

2011/6/14

#
I do not believe Greenfoot has a method to change an Actor from one type to another. The only ways to get around that is to save the variables for the current Actor, remove it, and create the new Actor of different type, and re-instate the variable associated with it. The only other thing you can do is change the image and change a variable that stores the state or type the object is.
kiarocks kiarocks

2011/6/15

#
thats what i thought. ill associate with our infectionStage method
kiarocks kiarocks

2011/6/15

#
how would i get the variable with objectsInRange?
There are more replies on the next page.
1
2
3
4
5