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

2014/5/5

Problem with getObjectsInRange()

1
2
danpost danpost

2014/5/7

#
Jonche wrote...
Yes it is done. Meanwhile I changed the way I looked for monsters by the way. It looks like this : < Code Omitted > As the attack method used twice the method to look for a monster and created one list for each method, I thought it would be better to have only one list instead of two and therefore directly check the position of the nearest monster in the list and attack this monster. I initialized a private Monster field at the start of my Class
Is there a question here or is this resolved?
Jonche Jonche

2014/5/7

#
Nothing of that, I'm still working on this problem, but I just modified the code, so that if you found something, you may adapt it to the new version
danpost danpost

2014/5/7

#
Where is the code that actually makes the change in the value of the 'healthpoints' field of the monsters?
Jonche Jonche

2014/5/7

#
On line 7 of the last code I posted
danpost danpost

2014/5/7

#
Jonche wrote...
On line 7 of the last code I posted
Oh, I see (it was not easy to spot). And neither is the cause of your issue. I have not yet been able to determine the cause of your problem (nothing 'pops' out at me). Maybe you should show one of your Monster subclasses.
Jonche Jonche

2014/5/7

#
There is only some field declaration in the subclasses, no method at all. If you really want it there it is :
public Boulotte()
    {
        healthPoints = 20;
        maxHealth = 20;
        standLeft = new GreenfootImage("BoulotteLeftStand.png");
        standRight = new GreenfootImage("BoulotteRightStand.png");
        setImage(standRight);
        monsterDamage = 1;
        expDrop = 15;
    }
danpost danpost

2014/5/7

#
Jonche wrote...
There is only some field declaration in the subclasses, no method at all. If you really want it there it is : < Code Omitted >
Ok, those are not field declarations. Those are field assignments. When declaring a field or variable, you will use the type (or class) of it in front of it (you know, like 'int' or 'GreenfootImage'). The only line that is not a field assignment (which kind of actually is in a round-about way) is line 7, which sets the image for this Boulotte object (it calls a method that assigns the image to a hidden field in the Actor class). Please show the entire code for that class (not just the constructor).
Jonche Jonche

2014/5/7

#
Oh yes sorry, I miswrote myself ^^ . There you have the entire class :
import greenfoot.*;
import java.util.List;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Simple here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Boulotte extends Monster
{
    public Boulotte()
    {
        healthPoints = 20;
        maxHealth = 20;
        standLeft = new GreenfootImage("BoulotteLeftStand.png");
        standRight = new GreenfootImage("BoulotteRightStand.png");
        setImage(standRight);
        monsterDamage = 1;
        expDrop = 15;
    }
}


danpost danpost

2014/5/7

#
Jonche wrote...
There you have the entire class : < Code Omitted >
Well, I guess that did not help any. What is at the top of your Monster class (anything before that which you already posted)?
Jonche Jonche

2014/5/7

#
The only thing I ommited was this I think :
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.List;

/**
 * Write a description of class Monster here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Monster extends Animal
{
So yeah, nothing irrelevant...
danpost danpost

2014/5/7

#
Jonche wrote...
The only thing I ommited was this I think : < Code Omitted > So yeah, nothing irrelevant...
Well ... you mean 'nothing relevant' -- and you are right. The Animal class does not have anything in it that would be contributing to this issue.
Jonche Jonche

2014/5/7

#
I'm too tired to type properly :P . And yes the animal class has nothing more useful, though it is an "animal" class, I designed myself. This project has no class (except actor and world) belonging to any book scenarios...
You need to login to post a reply.
1
2