From a0409b6b94e6f5b8c73008b54fd644bae2898e7f Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Fri, 4 Feb 2022 16:04:03 +0100 Subject: [PATCH] Set Layout StartStacks --- src/main/java/solitaer/SolitaerGamePanel.java | 92 +++++++++++-------- 1 file changed, 53 insertions(+), 39 deletions(-) diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java index 7eaf634..374b937 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -8,10 +8,19 @@ import javax.swing.JPanel; public class SolitaerGamePanel extends JPanel { private static final long serialVersionUID = 1L; + + private final int OFFSET_STACKS = 5; + public final int IMAGE_WIDTH = 72; + public final int IMAGE_HIGHT = 96; + private CardDeck deck; private MyMouseListener mouseL; private SaveStack save =new SaveStack(500,250); + private StartStack[] start = new StartStack[7] ; + + + public SolitaerGamePanel() { @@ -20,48 +29,53 @@ public class SolitaerGamePanel extends JPanel { mouseL = new MyMouseListener(save); this.addMouseListener(mouseL); - deck = new CardDeck(); - - - StartStack a = new StartStack(25,125); - - deck.getDeck().get(5).setFaceUp(true); - a.addCard((deck.getDeck().get(5))); - - deck.getDeck().get(4).setFaceUp(true); - a.addCard((deck.getDeck().get(4))); - - deck.getDeck().get(3).setFaceUp(true); - a.addCard((deck.getDeck().get(3))); - deck.getDeck().get(2).setFaceUp(true); - a.addCard((deck.getDeck().get(2))); - - deck.getDeck().get(1).setFaceUp(true); - a.addCard((deck.getDeck().get(1))); - - deck.getDeck().get(0).setFaceUp(true); - a.addCard(deck.getDeck().get(0)); - - this.add(a); - - StartStack b = new StartStack(200,125); - - deck.getDeck().get(32).setFaceUp(true); - b.addCard((deck.getDeck().get(32))); - this.add(b); - - StartStack c = new StartStack(375,125); - - //deck.getDeck().get(20).setFaceUp(true); - c.addCard((deck.getDeck().get(20))); - this.add(c); - - - StartStack d = new StartStack(475,125); - this.add(d); + for(int i = 0; i<7; i++) { + int x = (((IMAGE_WIDTH+OFFSET_STACKS)*i)+OFFSET_STACKS); + System.out.println(x); + start[i] = new StartStack(x, 125); + this.add(start[i]); + } + +// StartStack a = new StartStack(25,125); +// +// deck.getDeck().get(5).setFaceUp(true); +// a.addCard((deck.getDeck().get(5))); +// +// deck.getDeck().get(4).setFaceUp(true); +// a.addCard((deck.getDeck().get(4))); +// +// deck.getDeck().get(3).setFaceUp(true); +// a.addCard((deck.getDeck().get(3))); +// +// deck.getDeck().get(2).setFaceUp(true); +// a.addCard((deck.getDeck().get(2))); +// +// deck.getDeck().get(1).setFaceUp(true); +// a.addCard((deck.getDeck().get(1))); +// +// deck.getDeck().get(0).setFaceUp(true); +// a.addCard(deck.getDeck().get(0)); +// +// this.add(a); +// +// StartStack b = new StartStack(200,125); +// +// deck.getDeck().get(32).setFaceUp(true); +// b.addCard((deck.getDeck().get(32))); +// this.add(b); +// +// StartStack c = new StartStack(375,125); +// +// //deck.getDeck().get(20).setFaceUp(true); +// c.addCard((deck.getDeck().get(20))); +// this.add(c); +// +// +// StartStack d = new StartStack(475,125); +// this.add(d); //save = new SaveStack(500,250); this.add(save);