From cc6fc4e0a5db7da0459a405d5e5024a14575153a Mon Sep 17 00:00:00 2001 From: Zocker1999NET Date: Sun, 3 Jul 2016 19:39:15 +0200 Subject: [PATCH 01/24] =?UTF-8?q?Kommentare=20erg=C3=A4nzt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Um leichter mit der Datei weiterarbeiten zu können. --- Colours.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Colours.java b/Colours.java index 82f15d3..2048c87 100644 --- a/Colours.java +++ b/Colours.java @@ -18,12 +18,12 @@ public class Colours extends World implements ButtonEvent int [] color = new int [6]; String [] pn = new String [6]; int x = 0; - boolean possw = true; - boolean posbl = true; - boolean posgr = true; - boolean posrt = true; - boolean posgb = true; - boolean posli = true; + boolean possw = true; // schwarz + boolean posbl = true; // blau + boolean posgr = true; // gruen + boolean posrt = true; // rot + boolean posgb = true; // gelb + boolean posli = true; // lila int sw = 1; int bl = 2; int gr = 3; From cb34dc4d427a84e90458e1208eb73787f2c825fa Mon Sep 17 00:00:00 2001 From: Zocker1999NET Date: Sun, 3 Jul 2016 20:02:08 +0200 Subject: [PATCH 02/24] =?UTF-8?q?Passende=20Textfarben=20f=C3=BCr=20die=20?= =?UTF-8?q?Buttons=20Damit=20man=20als=20Spieler=20schneller=20die=20Farbe?= =?UTF-8?q?n=20zu=20den=20Buttons=20zuweisen=20kann.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Colours.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Colours.java b/Colours.java index 2048c87..bfc8a3a 100644 --- a/Colours.java +++ b/Colours.java @@ -36,10 +36,10 @@ public class Colours extends World implements ButtonEvent * */ public Colours(int x, int y, int z) - { - - super(x, y, z); + { + super(x, y, z); setBackground(Start_Load.backgroundImage); + addObject(schwarz, 50, 30); addObject ( blau, 170, 30); addObject ( grün, 280, 30); @@ -47,6 +47,7 @@ public class Colours extends World implements ButtonEvent addObject(gelb, 500, 30); addObject(lila, 610, 30); addObject (weiter, 335,90); + schwarz.setSize(100, 50); gelb.setSize(100, 50); blau.setSize(100, 50); @@ -54,7 +55,13 @@ public class Colours extends World implements ButtonEvent rot.setSize(100, 50); lila.setSize(100, 50); weiter.setSize(100, 50); - + + schwarz.setTextColor(Color.black); + gelb.setTextColor(Color.yellow); + blau.setTextColor(Color.blue); + grün.setTextColor(Color.green); + rot.setTextColor(Color.red); + lila.setTextColor(new Color(161,70,255)); } // Überprüft, ob ein Farbbutton geklickt wurde //Überprüft, ob die Farbe noch nicht ausgewählt wurde From 6a8c581a7dd2906426457d7074a194641e2418fb Mon Sep 17 00:00:00 2001 From: Zocker1999NET Date: Sun, 3 Jul 2016 20:02:56 +0200 Subject: [PATCH 03/24] =?UTF-8?q?Automatische=20Anpassung=20der=20Hintergr?= =?UTF-8?q?undfarbe=20der=20Buttons=20Diese=20=C3=84nderungen=20sorgen=20d?= =?UTF-8?q?af=C3=BCr,=20dass=20die=20Buttons=20automatisch=20ausgegraut=20?= =?UTF-8?q?werden,=20sobald=20sie=20verwendet=20wurden.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Colours.java | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Colours.java b/Colours.java index bfc8a3a..79f3308 100644 --- a/Colours.java +++ b/Colours.java @@ -1,4 +1,5 @@ import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) +import java.awt.Color; /** * Write a description of class Colors here. @@ -62,6 +63,8 @@ public class Colours extends World implements ButtonEvent grün.setTextColor(Color.green); rot.setTextColor(Color.red); lila.setTextColor(new Color(161,70,255)); + + redrawButtons(); } // Überprüft, ob ein Farbbutton geklickt wurde //Überprüft, ob die Farbe noch nicht ausgewählt wurde @@ -135,7 +138,23 @@ public class Colours extends World implements ButtonEvent World m = new Map(newcolor,x,newpn); Greenfoot.setWorld(m); } - + redrawButtons(); + } + + private Color getC(boolean pos) { + return (pos) ? Color.white : Color.gray; + } + + /** + Passt die Hintergrundfarbe der Buttons daran an, ob der Button noch gedrückt werden darf. + */ + private void redrawButtons() { + schwarz.setTextColor(getC(possw)); + blau.setTextColor(getC(posbl)); + grün.setTextColor(getC(posgr)); + rot.setTextColor(getC(posrt)); + lila.setTextColor(getC(posli)); + gelb.setTextColor(getC(posgb)); } } From 520e0964613985bf9a58f1a1d46975db80912f94 Mon Sep 17 00:00:00 2001 From: Zocker1999NET Date: Sun, 3 Jul 2016 20:04:29 +0200 Subject: [PATCH 04/24] Debug Colours.java setTextColor -> setForeColor & setBackColor --- Colours.java | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Colours.java b/Colours.java index 79f3308..dd92812 100644 --- a/Colours.java +++ b/Colours.java @@ -57,12 +57,12 @@ public class Colours extends World implements ButtonEvent lila.setSize(100, 50); weiter.setSize(100, 50); - schwarz.setTextColor(Color.black); - gelb.setTextColor(Color.yellow); - blau.setTextColor(Color.blue); - grün.setTextColor(Color.green); - rot.setTextColor(Color.red); - lila.setTextColor(new Color(161,70,255)); + schwarz.setForeColor(Color.black); + gelb.setForeColor(Color.yellow); + blau.setForeColor(Color.blue); + grün.setForeColor(Color.green); + rot.setForeColor(Color.red); + lila.setForeColor(new Color(161,70,255)); redrawButtons(); } @@ -149,12 +149,12 @@ public class Colours extends World implements ButtonEvent Passt die Hintergrundfarbe der Buttons daran an, ob der Button noch gedrückt werden darf. */ private void redrawButtons() { - schwarz.setTextColor(getC(possw)); - blau.setTextColor(getC(posbl)); - grün.setTextColor(getC(posgr)); - rot.setTextColor(getC(posrt)); - lila.setTextColor(getC(posli)); - gelb.setTextColor(getC(posgb)); + 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)); } } From 2897cafc3bc6d0bf94b42bab45c594aeea47df77 Mon Sep 17 00:00:00 2001 From: Zocker1999NET Date: Sun, 3 Jul 2016 20:13:55 +0200 Subject: [PATCH 05/24] =?UTF-8?q?Anpassung=20der=20Hintergrundfarbe=20Auf?= =?UTF-8?q?=20dem=20wei=C3=9Fen=20Hintergrund=20kann=20man=20den=20gelben?= =?UTF-8?q?=20Text=20nicht=20so=20leicht=20lesen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Colours.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Colours.java b/Colours.java index dd92812..50a691c 100644 --- a/Colours.java +++ b/Colours.java @@ -142,7 +142,7 @@ public class Colours extends World implements ButtonEvent } private Color getC(boolean pos) { - return (pos) ? Color.white : Color.gray; + return (pos) ? Color.lightGray : Color.gray; } /** From 4a130251392a255b30914fd34c39daec72f9cbad Mon Sep 17 00:00:00 2001 From: Zocker1999NET Date: Sun, 3 Jul 2016 20:25:49 +0200 Subject: [PATCH 06/24] =?UTF-8?q?Anpassung=20der=20n=C3=B6tigen=20Spielera?= =?UTF-8?q?nzahl=20N=C3=B6tige=20Anzahl=20erh=C3=B6ht=20auf=203,=20da=20f?= =?UTF-8?q?=C3=BCr=202=20Spieler=20keine=20definierte=20Provinz-Verteilung?= =?UTF-8?q?=20vorliegt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Colours.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Colours.java b/Colours.java index 50a691c..431e185 100644 --- a/Colours.java +++ b/Colours.java @@ -124,7 +124,7 @@ public class Colours extends World implements ButtonEvent posli = false; } - if ( b == weiter && x >=2 ) + if ( b == weiter && x > 2 ) { String[] newpn = new String[x]; int[] newcolor = new int[x]; From 860811876e5bb0856ad6aa427209ac2619f6903a Mon Sep 17 00:00:00 2001 From: Zocker1999NET Date: Sun, 3 Jul 2016 20:26:23 +0200 Subject: [PATCH 07/24] =?UTF-8?q?Labels=20hinzugef=C3=BCgt=20Diese=20?= =?UTF-8?q?=C3=BCbernehmen=20vorallem=20die=20Anzeige=20der=20bereits=20er?= =?UTF-8?q?stellten=20Spieler.?= 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]); + } } } From 92f6e12886c16251a4248aba6a6e8d5a31749303 Mon Sep 17 00:00:00 2001 From: Zocker1999NET Date: Sun, 3 Jul 2016 20:36:29 +0200 Subject: [PATCH 08/24] =?UTF-8?q?Debug=20Buttons=20&=20Labels=20auf=20Colo?= =?UTF-8?q?rs=20*=20Colours:=20Positionen=20verbessert=20*=20Button:=20Red?= =?UTF-8?q?raw=20angepasst=20bei=20den=20verwendeten=20Farben=20*=20Label:?= =?UTF-8?q?=20Redraw=20angepasst=20f=C3=BCr=20AutoSize?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Button.java | 11 +++++------ Colours.java | 14 +++++++------- Label.java | 3 +++ 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Button.java b/Button.java index 0c0975a..131f3a0 100644 --- a/Button.java +++ b/Button.java @@ -149,13 +149,12 @@ public class Button extends GUI_Interface { sy = tI.getHeight() + (6 * 2) + 4; } GreenfootImage all = new GreenfootImage(sx,sy); - Color gray = new Color(133,133,133,255); - Color black = new Color(0,0,0,255); + Color border = backC.brighter(); Color trans = new Color(0,0,0,0); - Utils.drawInsideRectangle(all,gray,0); - Utils.drawInsideRectangle(all,black,2); - Utils.drawInsideRectangle(all,gray,6); - Utils.drawInsideRectangle(all,black,7); + Utils.drawInsideRectangle(all,border,0); + Utils.drawInsideRectangle(all,backC,2); + Utils.drawInsideRectangle(all,border,6); + Utils.drawInsideRectangle(all,backC,7); all.setColorAt(0,0,trans); all.setColorAt(sx-1,0,trans); all.setColorAt(0,sy-1,trans); diff --git a/Colours.java b/Colours.java index 399251c..b09ea74 100644 --- a/Colours.java +++ b/Colours.java @@ -49,7 +49,7 @@ public class Colours extends World implements ButtonEvent super(x, y, z); setBackground(Start_Load.backgroundImage); - addObject(header,50, 20); + addObject(header,100,20); addObject(schwarz, 50, 50); addObject ( blau, 170, 50); @@ -59,12 +59,12 @@ public class Colours extends World implements ButtonEvent 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); + addObject(pl1,100,170); + addObject(pl2,100,190); + addObject(pl3,100,210); + addObject(pl4,100,230); + addObject(pl5,100,250); + addObject(pl6,100,270); schwarz.setSize(100, 50); gelb.setSize(100, 50); diff --git a/Label.java b/Label.java index d820642..b572eb6 100644 --- a/Label.java +++ b/Label.java @@ -90,6 +90,9 @@ public class Label extends GUI_Interface { */ public void redraw() { GreenfootImage tI = new GreenfootImage(text,textSize,foreC,backC); + if(text == "") { + tI = new GreenfootImage(0,0); + } if(autoSize) { sx = tI.getWidth(); sy = tI.getHeight(); From 97646640777c0fa209763aa305ecd0de6a38c845 Mon Sep 17 00:00:00 2001 From: Zocker1999NET Date: Sun, 3 Jul 2016 20:47:36 +0200 Subject: [PATCH 09/24] Label Debug Automatische Transparenz bei leerem Text --- Label.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Label.java b/Label.java index b572eb6..1dfd81b 100644 --- a/Label.java +++ b/Label.java @@ -91,7 +91,9 @@ public class Label extends GUI_Interface { public void redraw() { GreenfootImage tI = new GreenfootImage(text,textSize,foreC,backC); if(text == "") { - tI = new GreenfootImage(0,0); + tI = new GreenfootImage(1,1); + tI.setColor(new Color(0,0,0,0)); + tI.fill(); } if(autoSize) { sx = tI.getWidth(); From d0b2d41f32e3a9b91ee152f98665906df337d9cd Mon Sep 17 00:00:00 2001 From: Zocker1999NET Date: Sun, 3 Jul 2016 20:48:33 +0200 Subject: [PATCH 10/24] =?UTF-8?q?Button=20Renderer=20ge=C3=A4ndert=20Nun?= =?UTF-8?q?=20wird=20die=20Grundfl=C3=A4che=20des=20Buttons=20=C3=BCber=20?= =?UTF-8?q?Java-Libaries=20gerendert,=20was=20f=C3=BCr=20hoffentlich=20bes?= =?UTF-8?q?sere=20Ergebnisse=20sorgen=20wird.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Button.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/Button.java b/Button.java index 131f3a0..d43ccd3 100644 --- a/Button.java +++ b/Button.java @@ -1,5 +1,7 @@ import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.awt.Color; +import java.awt.BufferedImage; +import java.awt.Graphics2D; /** Diese Klasse stellt einen Button dar. @@ -149,16 +151,9 @@ public class Button extends GUI_Interface { sy = tI.getHeight() + (6 * 2) + 4; } GreenfootImage all = new GreenfootImage(sx,sy); - Color border = backC.brighter(); Color trans = new Color(0,0,0,0); - Utils.drawInsideRectangle(all,border,0); - Utils.drawInsideRectangle(all,backC,2); - Utils.drawInsideRectangle(all,border,6); - Utils.drawInsideRectangle(all,backC,7); - all.setColorAt(0,0,trans); - all.setColorAt(sx-1,0,trans); - all.setColorAt(0,sy-1,trans); - all.setColorAt(sx-1,sy-1,trans); + Graphics2D g = all.getAwtImage().createGraphics(); + g.fillRoundRect(0,0,sx,sy,6,6); all.drawImage(tI,(sx-tI.getWidth())/2,(sy-tI.getHeight())/2); setImage(all); } From bfe41887a092e14abbbd099216be84b9c9118d76 Mon Sep 17 00:00:00 2001 From: Zocker1999NET Date: Sun, 3 Jul 2016 20:49:42 +0200 Subject: [PATCH 11/24] Button Debug Import-Anweisung --- Button.java | 1 - 1 file changed, 1 deletion(-) diff --git a/Button.java b/Button.java index d43ccd3..2f1afb8 100644 --- a/Button.java +++ b/Button.java @@ -1,6 +1,5 @@ import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.awt.Color; -import java.awt.BufferedImage; import java.awt.Graphics2D; /** From 45b37bb514d369efaedf313f3bd4e92f6ed14a60 Mon Sep 17 00:00:00 2001 From: Zocker1999NET Date: Sun, 3 Jul 2016 20:56:58 +0200 Subject: [PATCH 12/24] =?UTF-8?q?Button=20Debug=20Renderer=20*=20Hintergru?= =?UTF-8?q?ndfarbe=20vergessen=20*=20St=C3=A4rke=20des=20abgerundeten=20Re?= =?UTF-8?q?chtecks=20erh=C3=B6ht=20*=20Transparenter=20Hintergrund=20einge?= =?UTF-8?q?richtet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Button.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Button.java b/Button.java index 2f1afb8..41c45ee 100644 --- a/Button.java +++ b/Button.java @@ -151,8 +151,11 @@ public class Button extends GUI_Interface { } GreenfootImage all = new GreenfootImage(sx,sy); Color trans = new Color(0,0,0,0); + all.setColor(trans); + all.fill(); Graphics2D g = all.getAwtImage().createGraphics(); - g.fillRoundRect(0,0,sx,sy,6,6); + g.setColor(backC); + g.fillRoundRect(0,0,sx,sy,12,12); all.drawImage(tI,(sx-tI.getWidth())/2,(sy-tI.getHeight())/2); setImage(all); } From 2470ea1f10f79b95f0eebd4c4e7f9e3544ae29e0 Mon Sep 17 00:00:00 2001 From: Zocker1999NET Date: Sun, 3 Jul 2016 21:04:36 +0200 Subject: [PATCH 13/24] =?UTF-8?q?Colours=20Debug=20*=20Button=20Gr=C3=B6?= =?UTF-8?q?=C3=9Fe=20Festlegen=20vereinfacht=20*=20Header-Label=20verschob?= =?UTF-8?q?en=20*=20Player-Labels=20transparent=20gemacht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Colours.java | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Colours.java b/Colours.java index b09ea74..b6aea3e 100644 --- a/Colours.java +++ b/Colours.java @@ -49,7 +49,10 @@ public class Colours extends World implements ButtonEvent super(x, y, z); setBackground(Start_Load.backgroundImage); - addObject(header,100,20); + Button[] bList = new Button[] {schwarz,gelb,blau,grün,rot,lila,weiter}; + Label[] lList = new Label[] {pl1,pl2,pl3,pl4,pl5,pl6}; + + addObject(header,200,20); addObject(schwarz, 50, 50); addObject ( blau, 170, 50); @@ -66,14 +69,6 @@ public class Colours extends World implements ButtonEvent addObject(pl5,100,250); addObject(pl6,100,270); - schwarz.setSize(100, 50); - gelb.setSize(100, 50); - blau.setSize(100, 50); - grün.setSize(100, 50); - rot.setSize(100, 50); - lila.setSize(100, 50); - weiter.setSize(100, 50); - schwarz.setForeColor(Color.black); gelb.setForeColor(Color.yellow); blau.setForeColor(Color.blue); @@ -81,6 +76,13 @@ public class Colours extends World implements ButtonEvent rot.setForeColor(Color.red); lila.setForeColor(new Color(161,70,255)); + for(int i = 0; i < bList.length; i++) { + bList[i].setSize(100,50); + } + for(int i = 0; i < lList.length; i++) { + lList[i].setBackColor(new Color(0,0,0,0)); + } + redraw(); } // Überprüft, ob ein Farbbutton geklickt wurde From 3a27398772c702cff897b601f742fc01be7b2d70 Mon Sep 17 00:00:00 2001 From: Zocker1999NET Date: Sun, 3 Jul 2016 21:08:48 +0200 Subject: [PATCH 14/24] Colours Debug 2 * Objektpositionen angepasst * Header durchsichtig gemacht --- Colours.java | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Colours.java b/Colours.java index b6aea3e..60d2ac2 100644 --- a/Colours.java +++ b/Colours.java @@ -50,24 +50,24 @@ public class Colours extends World implements ButtonEvent setBackground(Start_Load.backgroundImage); Button[] bList = new Button[] {schwarz,gelb,blau,grün,rot,lila,weiter}; - Label[] lList = new Label[] {pl1,pl2,pl3,pl4,pl5,pl6}; + Label[] lList = new Label[] {header,pl1,pl2,pl3,pl4,pl5,pl6}; - addObject(header,200,20); + addObject(header,200,15); - 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(schwarz, 70, 50); + addObject ( blau, 190, 50); + addObject ( grün, 300, 50); + addObject ( rot, 410, 50); + addObject(gelb, 520, 50); + addObject(lila, 630, 50); + addObject (weiter, 355,110); - addObject(pl1,100,170); - addObject(pl2,100,190); - addObject(pl3,100,210); - addObject(pl4,100,230); - addObject(pl5,100,250); - addObject(pl6,100,270); + addObject(pl1,355,160); + addObject(pl2,355,180); + addObject(pl3,355,200); + addObject(pl4,355,220); + addObject(pl5,355,240); + addObject(pl6,355,260); schwarz.setForeColor(Color.black); gelb.setForeColor(Color.yellow); From 0d77bc86cd073311fd5aed6387005e9928cd03e7 Mon Sep 17 00:00:00 2001 From: Zocker1999NET Date: Sun, 3 Jul 2016 21:09:17 +0200 Subject: [PATCH 15/24] =?UTF-8?q?Button=20Debug=20Renderer=202=20*=20Runde?= =?UTF-8?q?=20Ecken=20verst=C3=A4rkt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Button.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Button.java b/Button.java index 41c45ee..ac8a972 100644 --- a/Button.java +++ b/Button.java @@ -155,7 +155,7 @@ public class Button extends GUI_Interface { all.fill(); Graphics2D g = all.getAwtImage().createGraphics(); g.setColor(backC); - g.fillRoundRect(0,0,sx,sy,12,12); + g.fillRoundRect(0,0,sx,sy,24,24); all.drawImage(tI,(sx-tI.getWidth())/2,(sy-tI.getHeight())/2); setImage(all); } From 3ea3e43c3f0278438541d9b89d374824a723c237 Mon Sep 17 00:00:00 2001 From: Zocker1999NET Date: Sun, 3 Jul 2016 21:21:16 +0200 Subject: [PATCH 16/24] =?UTF-8?q?Colours=20Entfernen=20M=C3=B6glichkeit=20?= =?UTF-8?q?hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Colours.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Colours.java b/Colours.java index 60d2ac2..2b57fb0 100644 --- a/Colours.java +++ b/Colours.java @@ -33,6 +33,7 @@ public class Colours extends World implements ButtonEvent int li = 6; Label header = new Label("Klicke auf eine Farbe, um einen Spieler hinzuzufügen:",16); + Button remove = new Button("Rückgängig",16,this); Label pl1 = new Label("",16); Label pl2 = new Label("",16); Label pl3 = new Label("",16); @@ -60,7 +61,8 @@ public class Colours extends World implements ButtonEvent addObject ( rot, 410, 50); addObject(gelb, 520, 50); addObject(lila, 630, 50); - addObject (weiter, 355,110); + addObject(remove,300,110); + addObject (weiter, 410,110); addObject(pl1,355,160); addObject(pl2,355,180); @@ -137,6 +139,17 @@ public class Colours extends World implements ButtonEvent x+=1; posli = false; } + if(b == remove && x > 0) { + x -= 1; + switch(color[x]) { + case sw: possw = true; break; + case bl: posbl = true; break; + case gr: posgr = true; break; + case rt: posrt = true; break; + case gb: posgb = true; break; + case li: posli = true; break; + } + } if ( b == weiter && x > 2 ) { String[] newpn = new String[x]; @@ -166,6 +179,7 @@ public class Colours extends World implements ButtonEvent rot.setBackColor(getC(posrt)); lila.setBackColor(getC(posli)); gelb.setBackColor(getC(posgb)); + remove.setBackColor((x > 0) ? Color.black : Color.gray); switch(x) { case 6: pl6.setText(pn[5]); From 0e5ae0809ac2b244b7f237b07d81d02b86a1ee39 Mon Sep 17 00:00:00 2001 From: Zocker1999NET Date: Sun, 3 Jul 2016 21:22:37 +0200 Subject: [PATCH 17/24] Debug Colours Switch --- Colours.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Colours.java b/Colours.java index 2b57fb0..cdabfa8 100644 --- a/Colours.java +++ b/Colours.java @@ -142,12 +142,12 @@ public class Colours extends World implements ButtonEvent if(b == remove && x > 0) { x -= 1; switch(color[x]) { - case sw: possw = true; break; - case bl: posbl = true; break; - case gr: posgr = true; break; - case rt: posrt = true; break; - case gb: posgb = true; break; - case li: posli = true; break; + case 1: possw = true; break; + case 2: posbl = true; break; + case 3: posgr = true; break; + case 4: posrt = true; break; + case 5: posgb = true; break; + case 6: posli = true; break; } } if ( b == weiter && x > 2 ) From 0f070cb3f2647be3419ad5544ec085abb06acf6f Mon Sep 17 00:00:00 2001 From: Zocker1999NET Date: Sun, 3 Jul 2016 21:24:25 +0200 Subject: [PATCH 18/24] Colours Debug Redraw --- Colours.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Colours.java b/Colours.java index cdabfa8..b81bdd0 100644 --- a/Colours.java +++ b/Colours.java @@ -180,6 +180,12 @@ public class Colours extends World implements ButtonEvent lila.setBackColor(getC(posli)); gelb.setBackColor(getC(posgb)); remove.setBackColor((x > 0) ? Color.black : Color.gray); + pl1.setText(""); + pl2.setText(""); + pl3.setText(""); + pl4.setText(""); + pl5.setText(""); + pl6.setText(""); switch(x) { case 6: pl6.setText(pn[5]); From da6b946f079bcbf66027c7109e526bcd01a40644 Mon Sep 17 00:00:00 2001 From: Zocker1999NET Date: Sun, 3 Jul 2016 21:25:14 +0200 Subject: [PATCH 19/24] Colours Debug 3 --- Colours.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Colours.java b/Colours.java index b81bdd0..29e7800 100644 --- a/Colours.java +++ b/Colours.java @@ -50,7 +50,7 @@ public class Colours extends World implements ButtonEvent super(x, y, z); setBackground(Start_Load.backgroundImage); - Button[] bList = new Button[] {schwarz,gelb,blau,grün,rot,lila,weiter}; + Button[] bList = new Button[] {schwarz,gelb,blau,grün,rot,lila,weiter,remove}; Label[] lList = new Label[] {header,pl1,pl2,pl3,pl4,pl5,pl6}; addObject(header,200,15); From e596faa7e2d9757bc8cb5dde5924af050c39834b Mon Sep 17 00:00:00 2001 From: Zocker1999NET Date: Sun, 3 Jul 2016 21:32:37 +0200 Subject: [PATCH 20/24] =?UTF-8?q?Spielername=20Abfrage=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Colours.java | 57 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/Colours.java b/Colours.java index 29e7800..d635576 100644 --- a/Colours.java +++ b/Colours.java @@ -1,5 +1,6 @@ import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.awt.Color; +import javax.swing.JOptionPane; /** * Write a description of class Colors here. @@ -100,44 +101,56 @@ public class Colours extends World implements ButtonEvent if ( b == schwarz && possw == true) { color[x] = sw; - pn[x]="Schwarz"; - x+=1; - possw = false; + pn[x]=getName(x,"Schwarz"); + if(pn[x] != null) { + x+=1; + possw = false; + } } if (b == blau && posbl == true) { color[x] = bl; - pn[x] = "Blau"; - x+=1; - posbl = false; + pn[x]=getName(x,"Blau"); + if(pn[x] != null) { + x+=1; + posbl = false; + } } if (b == grün && posgr == true ) { color[x] = gr; - pn[x]="Grün"; - x+=1; - posgr = false; + pn[x]=getName(x,"Grün"); + if(pn[x] != null) { + x+=1; + posgr = false; + } } if ( b == rot && posrt == true) { color[x] = rt; - pn[x]="Rot"; - x+=1; - posrt = false; + pn[x]=getName(x,"Rot"); + if(pn[x] != null) { + x+=1; + posrt = false; + } } if ( b == gelb && posgb == true) { color [x] = gb; - pn[x]="Gelb"; - x+=1; - posgb = false; + pn[x]=getName(x,"Gelb"); + if(pn[x] != null) { + x+=1; + posgb = false; + } } if ( b == lila && posli == true) { color [x] = li; - pn[x]="Lila"; - x+=1; - posli = false; + pn[x]=getName(x,"Lila"); + if(pn[x] != null) { + x+=1; + posli = false; + } } if(b == remove && x > 0) { x -= 1; @@ -201,6 +214,14 @@ public class Colours extends World implements ButtonEvent pl1.setText(pn[0]); } } + + private String getName(int id, String col) { + String name = JOptionPane.showInputDialog(null, "Wie soll Spieler Nr. "+id+" mit der Farbe "+col+" heißen?"); + if(name == "") { + name = null; + } + return name; + } } From ce5d24e65359261714a405e84118c29ad0080d67 Mon Sep 17 00:00:00 2001 From: Zocker1999NET Date: Sun, 3 Jul 2016 21:34:51 +0200 Subject: [PATCH 21/24] Debug Spielername Abfrage --- Colours.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Colours.java b/Colours.java index d635576..0b26752 100644 --- a/Colours.java +++ b/Colours.java @@ -102,7 +102,7 @@ public class Colours extends World implements ButtonEvent { color[x] = sw; pn[x]=getName(x,"Schwarz"); - if(pn[x] != null) { + if(pn[x] != "") { x+=1; possw = false; } @@ -111,7 +111,7 @@ public class Colours extends World implements ButtonEvent { color[x] = bl; pn[x]=getName(x,"Blau"); - if(pn[x] != null) { + if(pn[x] != "") { x+=1; posbl = false; } @@ -120,7 +120,7 @@ public class Colours extends World implements ButtonEvent { color[x] = gr; pn[x]=getName(x,"Grün"); - if(pn[x] != null) { + if(pn[x] != "") { x+=1; posgr = false; } @@ -129,7 +129,7 @@ public class Colours extends World implements ButtonEvent { color[x] = rt; pn[x]=getName(x,"Rot"); - if(pn[x] != null) { + if(pn[x] != "") { x+=1; posrt = false; } @@ -138,7 +138,7 @@ public class Colours extends World implements ButtonEvent { color [x] = gb; pn[x]=getName(x,"Gelb"); - if(pn[x] != null) { + if(pn[x] != "") { x+=1; posgb = false; } @@ -147,7 +147,7 @@ public class Colours extends World implements ButtonEvent { color [x] = li; pn[x]=getName(x,"Lila"); - if(pn[x] != null) { + if(pn[x] != "") { x+=1; posli = false; } @@ -217,8 +217,8 @@ public class Colours extends World implements ButtonEvent private String getName(int id, String col) { String name = JOptionPane.showInputDialog(null, "Wie soll Spieler Nr. "+id+" mit der Farbe "+col+" heißen?"); - if(name == "") { - name = null; + if(name == null) { + name = ""; } return name; } From c8ad76e8718ac0005b2e2f412c0b22ae4890e471 Mon Sep 17 00:00:00 2001 From: Zocker1999NET Date: Sun, 3 Jul 2016 21:36:45 +0200 Subject: [PATCH 22/24] Colours Spielername Abfrage Debug 2 --- Colours.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Colours.java b/Colours.java index 0b26752..748645a 100644 --- a/Colours.java +++ b/Colours.java @@ -102,7 +102,7 @@ public class Colours extends World implements ButtonEvent { color[x] = sw; pn[x]=getName(x,"Schwarz"); - if(pn[x] != "") { + if(pn[x].length <= 0) { x+=1; possw = false; } @@ -111,7 +111,7 @@ public class Colours extends World implements ButtonEvent { color[x] = bl; pn[x]=getName(x,"Blau"); - if(pn[x] != "") { + if(pn[x].length <= 0) { x+=1; posbl = false; } @@ -120,7 +120,7 @@ public class Colours extends World implements ButtonEvent { color[x] = gr; pn[x]=getName(x,"Grün"); - if(pn[x] != "") { + if(pn[x].length <= 0) { x+=1; posgr = false; } @@ -129,7 +129,7 @@ public class Colours extends World implements ButtonEvent { color[x] = rt; pn[x]=getName(x,"Rot"); - if(pn[x] != "") { + if(pn[x].length <= 0) { x+=1; posrt = false; } @@ -138,7 +138,7 @@ public class Colours extends World implements ButtonEvent { color [x] = gb; pn[x]=getName(x,"Gelb"); - if(pn[x] != "") { + if(pn[x].length <= 0) { x+=1; posgb = false; } @@ -147,7 +147,7 @@ public class Colours extends World implements ButtonEvent { color [x] = li; pn[x]=getName(x,"Lila"); - if(pn[x] != "") { + if(pn[x].length <= 0) { x+=1; posli = false; } From 181720c0302d74b2f58a81ed74ea874840620a1c Mon Sep 17 00:00:00 2001 From: Zocker1999NET Date: Sun, 3 Jul 2016 21:38:17 +0200 Subject: [PATCH 23/24] Colours Debug Spielername Abfrage 3 --- Colours.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Colours.java b/Colours.java index 748645a..e94599e 100644 --- a/Colours.java +++ b/Colours.java @@ -102,7 +102,7 @@ public class Colours extends World implements ButtonEvent { color[x] = sw; pn[x]=getName(x,"Schwarz"); - if(pn[x].length <= 0) { + if(pn[x].length() <= 0) { x+=1; possw = false; } @@ -111,7 +111,7 @@ public class Colours extends World implements ButtonEvent { color[x] = bl; pn[x]=getName(x,"Blau"); - if(pn[x].length <= 0) { + if(pn[x].length() <= 0) { x+=1; posbl = false; } @@ -120,7 +120,7 @@ public class Colours extends World implements ButtonEvent { color[x] = gr; pn[x]=getName(x,"Grün"); - if(pn[x].length <= 0) { + if(pn[x].length() <= 0) { x+=1; posgr = false; } @@ -129,7 +129,7 @@ public class Colours extends World implements ButtonEvent { color[x] = rt; pn[x]=getName(x,"Rot"); - if(pn[x].length <= 0) { + if(pn[x].length() <= 0) { x+=1; posrt = false; } @@ -138,7 +138,7 @@ public class Colours extends World implements ButtonEvent { color [x] = gb; pn[x]=getName(x,"Gelb"); - if(pn[x].length <= 0) { + if(pn[x].length() <= 0) { x+=1; posgb = false; } @@ -147,7 +147,7 @@ public class Colours extends World implements ButtonEvent { color [x] = li; pn[x]=getName(x,"Lila"); - if(pn[x].length <= 0) { + if(pn[x].length() <= 0) { x+=1; posli = false; } From 72e1f0c22d12524e3065487a53d1e3a0cdcf0e38 Mon Sep 17 00:00:00 2001 From: Zocker1999NET Date: Sun, 3 Jul 2016 21:39:50 +0200 Subject: [PATCH 24/24] Colours Debug Spielername Abfrage 4 --- Colours.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Colours.java b/Colours.java index e94599e..61a4a98 100644 --- a/Colours.java +++ b/Colours.java @@ -102,7 +102,7 @@ public class Colours extends World implements ButtonEvent { color[x] = sw; pn[x]=getName(x,"Schwarz"); - if(pn[x].length() <= 0) { + if(pn[x].length() > 0) { x+=1; possw = false; } @@ -111,7 +111,7 @@ public class Colours extends World implements ButtonEvent { color[x] = bl; pn[x]=getName(x,"Blau"); - if(pn[x].length() <= 0) { + if(pn[x].length() > 0) { x+=1; posbl = false; } @@ -120,7 +120,7 @@ public class Colours extends World implements ButtonEvent { color[x] = gr; pn[x]=getName(x,"Grün"); - if(pn[x].length() <= 0) { + if(pn[x].length() > 0) { x+=1; posgr = false; } @@ -129,7 +129,7 @@ public class Colours extends World implements ButtonEvent { color[x] = rt; pn[x]=getName(x,"Rot"); - if(pn[x].length() <= 0) { + if(pn[x].length() > 0) { x+=1; posrt = false; } @@ -138,7 +138,7 @@ public class Colours extends World implements ButtonEvent { color [x] = gb; pn[x]=getName(x,"Gelb"); - if(pn[x].length() <= 0) { + if(pn[x].length() > 0) { x+=1; posgb = false; } @@ -147,7 +147,7 @@ public class Colours extends World implements ButtonEvent { color [x] = li; pn[x]=getName(x,"Lila"); - if(pn[x].length() <= 0) { + if(pn[x].length() > 0) { x+=1; posli = false; }