I need your help one more time:
I want to find all the Feldvariblen around the center postition. the Feldvariablen exists every 50 pixels to the left, up, right and down. It's a class which contains all the Information about this Position
Feldbreite is 50 pixels, as also Feldhöhe.
i Don't really need the *5 but I called it to see better what greenfoot is acting.
the position u start from (this.getX()) is also the place, where a Feldvariable exists.
the setNaehrstoffwert() changes the image the the postition, so i can find out at which position the Feldvariable reacts.
how it reacts:
(Z = Center where u put the code to act, the Center always reacts too.
1 = reaction
0 = no reaction)
000000010
000001110
000001110
000Z11111
000111110
011111110
011111110
111111110
000100000
i tought before the problem is perhaps math so a added two brackets
without the brackets is was:
0111000000
1111000000
1111000000
1111000000
0000Z11111
0000111110
0000111110
0000111110
0000111100
0000100000
I have no idea what the greenfoot system is doing there, b.z.w. where my fault is.
What i want to get is a reaction like this:
0001000 0000000
0011100 0111110
0111110 0111110
111Z111 or 011Z110
0111110 0111110
0011100 0111110
0001000 0000000
If you have questions please just ask. I hope I could make myself understood :)
int distance; for(Object obj : getObjectsInRange((int)(lvl.get_Feldbreite()*5),Feldvariablen.class)) { Feldvariablen feld = (Feldvariablen) obj; distance =((feld.getX()-this.getX())^2)+((feld.getY()-this.getY())^2); if(distance >-1) { feld.setNaehrstoffwert(getNaehrstoffwert()+10); } } getWorld().removeObject(this);
distance =(feld.getX()-this.getX())^2+(feld.getY()-this.getY())^2;