|
@ -12,24 +12,23 @@ public class SolitaerGamePanel extends JPanel { |
|
|
private static final long serialVersionUID = 1L; |
|
|
private static final long serialVersionUID = 1L; |
|
|
|
|
|
|
|
|
private final int OFFSET_STACKS_X = 5; |
|
|
private final int OFFSET_STACKS_X = 5; |
|
|
private final int OFFSET_STACKS_Y = 10; |
|
|
|
|
|
|
|
|
private final int OFFSET_STACKS_Y = 15; |
|
|
|
|
|
|
|
|
public final int IMAGE_WIDTH = 72; |
|
|
public final int IMAGE_WIDTH = 72; |
|
|
public final int IMAGE_HIGHT = 96; |
|
|
public final int IMAGE_HIGHT = 96; |
|
|
|
|
|
|
|
|
|
|
|
public final int STARTSTACK_SIZE = 7; |
|
|
|
|
|
public final int ABLAGESTACK_SIZE = 4; |
|
|
|
|
|
|
|
|
private CardDeck deck; |
|
|
private CardDeck deck; |
|
|
private MyMouseListener mouseL; |
|
|
private MyMouseListener mouseL; |
|
|
|
|
|
|
|
|
private SaveStack save;// =new SaveStack(500,250); |
|
|
|
|
|
private StartStack[] start = new StartStack[7] ; |
|
|
|
|
|
|
|
|
private SaveStack save; |
|
|
|
|
|
private StartStack[] start = new StartStack[7]; |
|
|
private AblageStack[] ablage = new AblageStack[4]; |
|
|
private AblageStack[] ablage = new AblageStack[4]; |
|
|
|
|
|
|
|
|
private WasteStack w;// = new WasteStack(85, 10); |
|
|
|
|
|
private GeberStack g;// = new GeberStack(10, 10, w); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private WasteStack waste; |
|
|
|
|
|
private GeberStack geber; |
|
|
|
|
|
|
|
|
public SolitaerGamePanel() { |
|
|
public SolitaerGamePanel() { |
|
|
setLayout(null); |
|
|
setLayout(null); |
|
@ -39,30 +38,27 @@ public class SolitaerGamePanel extends JPanel { |
|
|
|
|
|
|
|
|
deck = new CardDeck(); |
|
|
deck = new CardDeck(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i<7; i++) { |
|
|
|
|
|
int x = (((IMAGE_WIDTH+OFFSET_STACKS_X)*i)+OFFSET_STACKS_X); |
|
|
|
|
|
System.out.println(x); |
|
|
|
|
|
start[i] = new StartStack(x, 125); |
|
|
|
|
|
|
|
|
for (int i = 0; i < STARTSTACK_SIZE; i++) { |
|
|
|
|
|
int y = setLayouty(1); |
|
|
|
|
|
start[i] = new StartStack(setLayoutX(i), y); |
|
|
this.add(start[i]); |
|
|
this.add(start[i]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i<4; i++) { |
|
|
|
|
|
int x = (((IMAGE_WIDTH+OFFSET_STACKS_X)*(3+i))+OFFSET_STACKS_X); |
|
|
|
|
|
|
|
|
for (int i = 0; i < ABLAGESTACK_SIZE; i++) { |
|
|
|
|
|
int x = setLayoutX(((STARTSTACK_SIZE - ABLAGESTACK_SIZE) + i)); |
|
|
|
|
|
int y = setLayouty(0); |
|
|
switch (i) { |
|
|
switch (i) { |
|
|
case 0: |
|
|
case 0: |
|
|
ablage[i] = new AblageStack(x, OFFSET_STACKS_Y, Symbol.Herz); |
|
|
|
|
|
|
|
|
ablage[i] = new AblageStack(x, y, Symbol.Herz); |
|
|
break; |
|
|
break; |
|
|
case 1: |
|
|
case 1: |
|
|
ablage[i] = new AblageStack(x, OFFSET_STACKS_Y, Symbol.Kreuz); |
|
|
|
|
|
|
|
|
ablage[i] = new AblageStack(x, y, Symbol.Kreuz); |
|
|
break; |
|
|
break; |
|
|
case 2: |
|
|
case 2: |
|
|
ablage[i] = new AblageStack(x, OFFSET_STACKS_Y, Symbol.Karo); |
|
|
|
|
|
|
|
|
ablage[i] = new AblageStack(x, y, Symbol.Karo); |
|
|
break; |
|
|
break; |
|
|
case 3: |
|
|
case 3: |
|
|
ablage[i] = new AblageStack(x, OFFSET_STACKS_Y, Symbol.Pik); |
|
|
|
|
|
|
|
|
ablage[i] = new AblageStack(x, y, Symbol.Pik); |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
default: |
|
|
default: |
|
@ -71,31 +67,40 @@ public class SolitaerGamePanel extends JPanel { |
|
|
this.add(ablage[i]); |
|
|
this.add(ablage[i]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int Offset_x_Save = setLayoutX(STARTSTACK_SIZE + 1); |
|
|
|
|
|
int Offset_y_Save = setLayouty(1); |
|
|
|
|
|
|
|
|
int Offset_x_Save = (((IMAGE_WIDTH+OFFSET_STACKS_X)*8)+OFFSET_STACKS_X); |
|
|
|
|
|
JLabel label = new JLabel(); |
|
|
JLabel label = new JLabel(); |
|
|
label.setText("selected Cards"); |
|
|
label.setText("selected Cards"); |
|
|
label.setBounds(Offset_x_Save, 100, 200,25); |
|
|
|
|
|
|
|
|
label.setBounds(Offset_x_Save, Offset_y_Save - 25, 200, 25); |
|
|
this.add(label); |
|
|
this.add(label); |
|
|
|
|
|
|
|
|
save = new SaveStack(Offset_x_Save,125); |
|
|
|
|
|
|
|
|
save = new SaveStack(Offset_x_Save, Offset_y_Save); |
|
|
this.add(save); |
|
|
this.add(save); |
|
|
|
|
|
|
|
|
|
|
|
waste = new WasteStack(setLayoutX(1), OFFSET_STACKS_Y); |
|
|
|
|
|
geber = new GeberStack(setLayoutX(0), OFFSET_STACKS_Y, waste); |
|
|
|
|
|
this.add(waste); |
|
|
|
|
|
this.add(geber); |
|
|
|
|
|
|
|
|
w = new WasteStack((IMAGE_WIDTH+(OFFSET_STACKS_X)*2), OFFSET_STACKS_Y); |
|
|
|
|
|
g = new GeberStack(OFFSET_STACKS_X, OFFSET_STACKS_Y, w); |
|
|
|
|
|
this.add(w); |
|
|
|
|
|
this.add(g); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private int setLayoutX(int _spalte) { |
|
|
|
|
|
return (((IMAGE_WIDTH + OFFSET_STACKS_X) * _spalte) + OFFSET_STACKS_X); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private int setLayouty(int _row) { |
|
|
|
|
|
if(_row == 1) |
|
|
|
|
|
return IMAGE_HIGHT + (OFFSET_STACKS_Y * 3); |
|
|
|
|
|
else |
|
|
|
|
|
return OFFSET_STACKS_Y; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
protected void paintComponent(Graphics g) { |
|
|
protected void paintComponent(Graphics g) { |
|
|
// TODO Auto-generated method stub |
|
|
// TODO Auto-generated method stub |
|
|
super.paintComponent(g); |
|
|
super.paintComponent(g); |
|
|
g.setColor(Color.green); |
|
|
|
|
|
|
|
|
g.setColor(new Color(0, 135, 62)); |
|
|
g.fillRect(0, 0, this.getWidth(), this.getHeight()); |
|
|
g.fillRect(0, 0, this.getWidth(), this.getHeight()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |