solitaire_04.py Diff

solitaire_04.py
--- /home/docs/checkouts/readthedocs.org/user_builds/arcade-library/checkouts/2.5.7/doc/tutorials/card_game/solitaire_03.py
+++ /home/docs/checkouts/readthedocs.org/user_builds/arcade-library/checkouts/2.5.7/doc/tutorials/card_game/solitaire_04.py
@@ -30,6 +30,15 @@
 
 # The X of where to start putting things on the left side
 START_X = MAT_WIDTH / 2 + MAT_WIDTH * HORIZONTAL_MARGIN_PERCENT
+
+# The Y of the top row (4 piles)
+TOP_Y = SCREEN_HEIGHT - MAT_HEIGHT / 2 - MAT_HEIGHT * VERTICAL_MARGIN_PERCENT
+
+# The Y of the middle row (7 piles)
+MIDDLE_Y = TOP_Y - MAT_HEIGHT - MAT_HEIGHT * VERTICAL_MARGIN_PERCENT
+
+# How far apart each pile goes
+X_SPACING = MAT_WIDTH + MAT_WIDTH * HORIZONTAL_MARGIN_PERCENT
 
 # Card constants
 CARD_VALUES = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"]
@@ -69,6 +78,9 @@
         # they have to go back.
         self.held_cards_original_position = None
 
+        # Sprite list with all the mats tha cards lay on.
+        self.pile_mat_list = None
+
     def setup(self):
         """ Set up the game here. Call this function to restart the game. """
 
@@ -78,6 +90,32 @@
         # Original location of cards we are dragging with the mouse in case
         # they have to go back.
         self.held_cards_original_position = []
+
+        # ---  Create the mats the cards go on.
+
+        # Sprite list with all the mats tha cards lay on.
+        self.pile_mat_list: arcade.SpriteList = arcade.SpriteList()
+
+        # Create the mats for the bottom face down and face up piles
+        pile = arcade.SpriteSolidColor(MAT_WIDTH, MAT_HEIGHT, arcade.csscolor.DARK_OLIVE_GREEN)
+        pile.position = START_X, BOTTOM_Y
+        self.pile_mat_list.append(pile)
+
+        pile = arcade.SpriteSolidColor(MAT_WIDTH, MAT_HEIGHT, arcade.csscolor.DARK_OLIVE_GREEN)
+        pile.position = START_X + X_SPACING, BOTTOM_Y
+        self.pile_mat_list.append(pile)
+
+        # Create the seven middle piles
+        for i in range(7):
+            pile = arcade.SpriteSolidColor(MAT_WIDTH, MAT_HEIGHT, arcade.csscolor.DARK_OLIVE_GREEN)
+            pile.position = START_X + i * X_SPACING, MIDDLE_Y
+            self.pile_mat_list.append(pile)
+
+        # Create the top "play" piles
+        for i in range(4):
+            pile = arcade.SpriteSolidColor(MAT_WIDTH, MAT_HEIGHT, arcade.csscolor.DARK_OLIVE_GREEN)
+            pile.position = START_X + i * X_SPACING, TOP_Y
+            self.pile_mat_list.append(pile)
 
         # Sprite list with all the cards, no matter what pile they are in.
         self.card_list = arcade.SpriteList()
@@ -93,6 +131,9 @@
         """ Render the screen. """
         # Clear the screen
         arcade.start_render()
+
+        # Draw the mats the cards go on to
+        self.pile_mat_list.draw()
 
         # Draw the cards
         self.card_list.draw()