From 860811876e5bb0856ad6aa427209ac2619f6903a Mon Sep 17 00:00:00 2001 From: Zocker1999NET Date: Sun, 3 Jul 2016 20:26:23 +0200 Subject: [PATCH] =?UTF-8?q?Labels=20hinzugef=C3=BCgt=20Diese=20=C3=BCberne?= =?UTF-8?q?hmen=20vorallem=20die=20Anzeige=20der=20bereits=20erstellten=20?= =?UTF-8?q?Spieler.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Colours.java | 65 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 21 deletions(-) diff --git a/Colours.java b/Colours.java index 431e185..399251c 100644 --- a/Colours.java +++ b/Colours.java @@ -16,8 +16,8 @@ public class Colours extends World implements ButtonEvent Button lila = new Button ("Lila", 16, this); Button gelb = new Button ("Gelb", 16, this); Button weiter = new Button ("Weiter", 16, this); - int [] color = new int [6]; - String [] pn = new String [6]; + int[] color = new int [6]; + String[] pn = new String [6]; int x = 0; boolean possw = true; // schwarz boolean posbl = true; // blau @@ -31,6 +31,14 @@ public class Colours extends World implements ButtonEvent int rt = 4; int gb = 5; int li = 6; + + Label header = new Label("Klicke auf eine Farbe, um einen Spieler hinzuzufügen:",16); + Label pl1 = new Label("",16); + Label pl2 = new Label("",16); + Label pl3 = new Label("",16); + Label pl4 = new Label("",16); + Label pl5 = new Label("",16); + Label pl6 = new Label("",16); /** * Constructor for objects of class Colors. @@ -41,13 +49,22 @@ public class Colours extends World implements ButtonEvent super(x, y, z); setBackground(Start_Load.backgroundImage); - addObject(schwarz, 50, 30); - addObject ( blau, 170, 30); - addObject ( grün, 280, 30); - addObject ( rot, 390, 30); - addObject(gelb, 500, 30); - addObject(lila, 610, 30); - addObject (weiter, 335,90); + addObject(header,50, 20); + + addObject(schwarz, 50, 50); + addObject ( blau, 170, 50); + addObject ( grün, 280, 50); + addObject ( rot, 390, 50); + addObject(gelb, 500, 50); + addObject(lila, 610, 50); + addObject (weiter, 335,110); + + addObject(pl1,50,170); + addObject(pl2,50,190); + addObject(pl3,50,210); + addObject(pl4,50,230); + addObject(pl5,50,250); + addObject(pl6,50,270); schwarz.setSize(100, 50); gelb.setSize(100, 50); @@ -64,7 +81,7 @@ public class Colours extends World implements ButtonEvent rot.setForeColor(Color.red); lila.setForeColor(new Color(161,70,255)); - redrawButtons(); + redraw(); } // Überprüft, ob ein Farbbutton geklickt wurde //Überprüft, ob die Farbe noch nicht ausgewählt wurde @@ -82,7 +99,6 @@ public class Colours extends World implements ButtonEvent pn[x]="Schwarz"; x+=1; possw = false; - } if (b == blau && posbl == true) { @@ -90,7 +106,6 @@ public class Colours extends World implements ButtonEvent pn[x] = "Blau"; x+=1; posbl = false; - } if (b == grün && posgr == true ) { @@ -98,7 +113,6 @@ public class Colours extends World implements ButtonEvent pn[x]="Grün"; x+=1; posgr = false; - } if ( b == rot && posrt == true) { @@ -106,7 +120,6 @@ public class Colours extends World implements ButtonEvent pn[x]="Rot"; x+=1; posrt = false; - } if ( b == gelb && posgb == true) { @@ -114,7 +127,6 @@ public class Colours extends World implements ButtonEvent pn[x]="Gelb"; x+=1; posgb = false; - } if ( b == lila && posli == true) { @@ -122,7 +134,6 @@ public class Colours extends World implements ButtonEvent pn[x]="Lila"; x+=1; posli = false; - } if ( b == weiter && x > 2 ) { @@ -132,13 +143,11 @@ public class Colours extends World implements ButtonEvent { newpn[i] = pn[i]; newcolor[i] = color[i]; - } - World m = new Map(newcolor,x,newpn); Greenfoot.setWorld(m); } - redrawButtons(); + redraw(); } private Color getC(boolean pos) { @@ -146,15 +155,29 @@ public class Colours extends World implements ButtonEvent } /** - Passt die Hintergrundfarbe der Buttons daran an, ob der Button noch gedrückt werden darf. + Passt alle adaptiven Parameter automatisch an. */ - private void redrawButtons() { + private void redraw() { schwarz.setBackColor(getC(possw)); blau.setBackColor(getC(posbl)); grün.setBackColor(getC(posgr)); rot.setBackColor(getC(posrt)); lila.setBackColor(getC(posli)); gelb.setBackColor(getC(posgb)); + switch(x) { + case 6: + pl6.setText(pn[5]); + case 5: + pl5.setText(pn[4]); + case 4: + pl4.setText(pn[3]); + case 3: + pl3.setText(pn[2]); + case 2: + pl2.setText(pn[1]); + case 1: + pl1.setText(pn[0]); + } } }