|
|
@ -12,24 +12,23 @@ public class SolitaerGamePanel extends JPanel { |
|
|
|
private static final long serialVersionUID = 1L; |
|
|
|
|
|
|
|
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_HIGHT = 96; |
|
|
|
|
|
|
|
public final int STARTSTACK_SIZE = 7; |
|
|
|
public final int ABLAGESTACK_SIZE = 4; |
|
|
|
|
|
|
|
private CardDeck deck; |
|
|
|
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 WasteStack w;// = new WasteStack(85, 10); |
|
|
|
private GeberStack g;// = new GeberStack(10, 10, w); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private WasteStack waste; |
|
|
|
private GeberStack geber; |
|
|
|
|
|
|
|
public SolitaerGamePanel() { |
|
|
|
setLayout(null); |
|
|
@ -39,30 +38,27 @@ public class SolitaerGamePanel extends JPanel { |
|
|
|
|
|
|
|
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]); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) { |
|
|
|
case 0: |
|
|
|
ablage[i] = new AblageStack(x, OFFSET_STACKS_Y, Symbol.Herz); |
|
|
|
ablage[i] = new AblageStack(x, y, Symbol.Herz); |
|
|
|
break; |
|
|
|
case 1: |
|
|
|
ablage[i] = new AblageStack(x, OFFSET_STACKS_Y, Symbol.Kreuz); |
|
|
|
ablage[i] = new AblageStack(x, y, Symbol.Kreuz); |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
ablage[i] = new AblageStack(x, OFFSET_STACKS_Y, Symbol.Karo); |
|
|
|
ablage[i] = new AblageStack(x, y, Symbol.Karo); |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
ablage[i] = new AblageStack(x, OFFSET_STACKS_Y, Symbol.Pik); |
|
|
|
ablage[i] = new AblageStack(x, y, Symbol.Pik); |
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
@ -71,31 +67,40 @@ public class SolitaerGamePanel extends JPanel { |
|
|
|
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(); |
|
|
|
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); |
|
|
|
|
|
|
|
save = new SaveStack(Offset_x_Save,125); |
|
|
|
save = new SaveStack(Offset_x_Save, Offset_y_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 |
|
|
|
protected void paintComponent(Graphics g) { |
|
|
|
// TODO Auto-generated method stub |
|
|
|
super.paintComponent(g); |
|
|
|
g.setColor(Color.green); |
|
|
|
g.setColor(new Color(0, 135, 62)); |
|
|
|
g.fillRect(0, 0, this.getWidth(), this.getHeight()); |
|
|
|
} |
|
|
|
} |