Player-Erstellung korrektur

Ist zwar nicht mein Job, aber hat genervt...
Jetzt tut es
master
SariusRu 8 years ago
parent a37da3c4c9
commit 1332d185f9

@ -65,13 +65,13 @@ public class Colours extends World implements ButtonEvent
//der per Konstruktor die Daten der Colorklasse übertragen werden, dannach wird die Map die aktive Welt //der per Konstruktor die Daten der Colorklasse übertragen werden, dannach wird die Map die aktive Welt
public void buttonClicked (Button b) public void buttonClicked (Button b)
{ {
if ( b == schwarz && possw == true) if ( b == schwarz && possw == true)
{ {
color[x] = sw; color[x] = sw;
pn[x]="Schwarz"; pn[x]="Schwarz";
x+=1; x+=1;
possw = false; possw = false;
System.out.println("HI");
} }
if (b == blau && posbl == true) if (b == blau && posbl == true)
{ {
@ -79,6 +79,7 @@ public class Colours extends World implements ButtonEvent
pn[x] = "Blau"; pn[x] = "Blau";
x+=1; x+=1;
posbl = false; posbl = false;
System.out.println("HI");
} }
if (b == grün && posgr == true ) if (b == grün && posgr == true )
{ {
@ -86,6 +87,7 @@ public class Colours extends World implements ButtonEvent
pn[x]="Grün"; pn[x]="Grün";
x+=1; x+=1;
posgr = false; posgr = false;
System.out.println("HI");
} }
if ( b == rot && posrt == true) if ( b == rot && posrt == true)
{ {
@ -93,6 +95,7 @@ public class Colours extends World implements ButtonEvent
pn[x]="Rot"; pn[x]="Rot";
x+=1; x+=1;
posrt = false; posrt = false;
System.out.println("HI");
} }
if ( b == gelb && posgb == true) if ( b == gelb && posgb == true)
{ {
@ -100,6 +103,7 @@ public class Colours extends World implements ButtonEvent
pn[x]="Gelb"; pn[x]="Gelb";
x+=1; x+=1;
posgb = false; posgb = false;
System.out.println("HI");
} }
if ( b == lila && posli == true) if ( b == lila && posli == true)
{ {
@ -107,6 +111,7 @@ public class Colours extends World implements ButtonEvent
pn[x]="Lila"; pn[x]="Lila";
x+=1; x+=1;
posli = false; posli = false;
System.out.println("HI");
} }
if ( b == weiter && x >=2 ) if ( b == weiter && x >=2 )
{ {
@ -116,10 +121,16 @@ public class Colours extends World implements ButtonEvent
{ {
newpn[i] = pn[i]; newpn[i] = pn[i];
newcolor[i] = color[i]; newcolor[i] = color[i];
} }
World m = new Map(newcolor,x,newpn); World m = new Map(newcolor,x,newpn);
Greenfoot.setWorld(m); Greenfoot.setWorld(m);
} System.out.println("HIFertig");
System.out.println(x);
} }
} }
}

@ -11,8 +11,8 @@ public class Map extends World implements ButtonEvent
private Button map1 = new Button ("map1",16,this); private Button map1 = new Button ("map1",16,this);
private Button map2 = new Button ("map2",16,this); private Button map2 = new Button ("map2",16,this);
private Button fertigst = new Button (" Fertigstellen",16,this); private Button fertigst = new Button (" Fertigstellen",16,this);
int [] colour = new int[6]; int[] colour;
String [] pn = new String [6]; String[] pn;
int pnu; int pnu;
//private int x; //private int x;
//private int y; //private int y;
@ -22,9 +22,10 @@ public class Map extends World implements ButtonEvent
// String [] newpn = new String [pnu]; // String [] newpn = new String [pnu];
public Map( int[] bunt, int zahl , String [] name) public Map( int[] bunt, int zahl , String [] name)
{ {
super (1600,900,1); super (1600,900,1);
for (int i=0; i<pnu; i++) colour = new int[zahl];
pn = new String[zahl];
for (int i=0; i<zahl; i++)
{ {
colour[i] = bunt[i]; colour[i] = bunt[i];
pn[i] = name[i]; pn[i] = name[i];

@ -219,6 +219,10 @@ public class Player extends Actor
public void redrawPlayer() public void redrawPlayer()
{ {
int textSize = 20; int textSize = 20;
if(n == null)
{
n = "leererSpieler";
}
GreenfootImage statistics = new GreenfootImage(137,120); GreenfootImage statistics = new GreenfootImage(137,120);
GreenfootImage Name = new GreenfootImage(n,textSize,new Color(0,0,0),new Color(1.0f,1.0f,1.0f,0.5f)); GreenfootImage Name = new GreenfootImage(n,textSize,new Color(0,0,0),new Color(1.0f,1.0f,1.0f,0.5f));
statistics.drawImage(Name,0,0); statistics.drawImage(Name,0,0);

Loading…
Cancel
Save