fast fast fertig
This commit is contained in:
parent
ad2b1845a4
commit
dc87650ab5
@ -55,13 +55,13 @@ public class Garten extends Kompositum
|
||||
flbeet.zeichneBeete(beete);
|
||||
}
|
||||
|
||||
public Beet getBeet(int[] mausposition)
|
||||
public Beet getBeet(MouseEvent e)
|
||||
{
|
||||
Beet tempBeet = null;
|
||||
for (Beet b : beete)
|
||||
{
|
||||
int[] koordinvergleich = b.getKoordinaten();
|
||||
if (koordinvergleich[0] < mausposition[0] && koordinvergleich[1] < mausposition[1] && (koordinvergleich[2] + koordinvergleich[0]) > mausposition[0] && (koordinvergleich[3] + koordinvergleich[1]) > mausposition[1])
|
||||
if (koordinvergleich[0] < e.getX() && koordinvergleich[1] < e.getY() && (koordinvergleich[2] + koordinvergleich[0]) > e.getX() && (koordinvergleich[3] + koordinvergleich[1]) > e.getY())
|
||||
{
|
||||
tempBeet = b;
|
||||
}
|
||||
@ -98,7 +98,7 @@ public class Garten extends Kompositum
|
||||
for (Beet b : beete)
|
||||
{
|
||||
PflanzengruppenKonfigurator konfig = new PflanzengruppenKonfigurator();
|
||||
int randomAlter = (int) (Math.random() * 3 + 1);
|
||||
int randomAlter = (int) (Math.random() * 2 + 1);
|
||||
int randomTyp = (int) (Math.random() * 3 + 1);
|
||||
|
||||
int[] temp = b.getKoordinaten();
|
||||
@ -185,6 +185,7 @@ public class Garten extends Kompositum
|
||||
public Pflanze getmovePflanze(MouseEvent e)
|
||||
{
|
||||
Pflanze diePflanze = null;
|
||||
Beet StartBeet = null;
|
||||
int abstand = 15;
|
||||
|
||||
for (int i = 0; i < pflanzen.size(); i++)
|
||||
@ -193,6 +194,8 @@ public class Garten extends Kompositum
|
||||
if (Math.abs(pflanzen.get(i).getPositionx() - e.getX()) + Math.abs(pflanzen.get(i).getPositiony() - e.getY()) < abstand)
|
||||
{
|
||||
diePflanze = pflanzen.get(i);
|
||||
StartBeet = getBeet(e);
|
||||
|
||||
abstand = Math.abs(pflanzen.get(i).getPositionx() - e.getX()) + Math.abs(pflanzen.get(i).getPositiony() - e.getY());
|
||||
System.out.println("Pflanze: " + diePflanze.getPositionx() + " " + diePflanze.getPositiony());
|
||||
|
||||
@ -200,14 +203,17 @@ public class Garten extends Kompositum
|
||||
System.out.println("Alte Position: " + pflanzen.get(intmovePflanze).getPositionx() + " " + pflanzen.get(intmovePflanze).getPositiony());
|
||||
}
|
||||
}
|
||||
StartBeet.pflgruppe.removePflanze(diePflanze);
|
||||
return diePflanze;
|
||||
}
|
||||
|
||||
public void setmovePflanze(MouseEvent e)
|
||||
{
|
||||
|
||||
pflanzen.get(intmovePflanze).setPositionx(e.getX());
|
||||
pflanzen.get(intmovePflanze).setPositiony(e.getY());
|
||||
pflanzen.get(intmovePflanze).setAlgorithm();
|
||||
getBeet(e).pflgruppe.addPflanze(pflanzen.get(intmovePflanze));
|
||||
zeichnePflanzen();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user