Skip to content

JCTec/Pente

Repository files navigation

Pente game made for school, feel free to use.

Pente(object)

Properties:

  • • n : Number of intersections.
  • • turn : The current turn.
  • • greenTile : The tile for the green player (1 or 0).
  • • blueTile : The tile for the blue player (1 or 0).
  • • greenPoints : Capture Points Green Player.
  • • bluePoints : Capture Points Blue Player.
  • • x : Array with all the x coordinates for vertical lines (plus a 1000 at the end for various purposes).
  • • y : Array with all the y coordinates for vertical lines (plus a 1000 at the end for various purposes).
  • • width : pygame canvas width.
  • • height : pygame canvas height
  • • boardImage : The board image to use loaded from "Pieces/penteBoard.png"
  • • blue : The blueGlassPiece loaded from "Pieces/blueGlassPiece.png"
  • • green : The blueGlassPiece loaded from "Pieces/greenGlassPiece.png"
  • • screen : pygame screen (loaded with "pygame.display.set_mode((self.width, self.height))").
  • • background_colour : Color to use (R:224, G:195, B:112).
  • • board : Matrix that saves the state of the board.
  • Board Example:

          [['1', '0', '1', '0', '1', '1', '0', '1', '0', '1'], \
          ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.'], \
          ['0', '.', '1', '.', '.', '0', '.', '1', '.', '.'], \
          ['.', '.', '.', '.', '1', '.', '.', '.', '.', '1'], \
          ['.', '.', '1', '0', '.', '.', '.', '1', '0', '.'], \
          ['1', '0', '1', '0', '1', '1', '0', '1', '0', '1'], \
          ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.'], \
          ['0', '.', '1', '.', '.', '0', '.', '1', '.', '.'], \
          ['.', '.', '.', '.', '1', '.', '.', '.', '.', '1'], \
          ['.', '.', '1', '0', '.', '.', '.', '1', '0', '.']]
    

    Draw a the board in pygame screen, should be call in a loop.

  • def makeBoard(self):
  • Returns empty board.

  • def getNewBoard(self):
  • Validates a move.

  • def isValidMove(self, move):
  • Check if the move can capture pieces and deletes the captured pieces.

  • def isCaptureMove(self, jugador, move):
  • Saves the move to self.board

  • def makeMove(self, jugador, move):
  • Checks if self.board is full

  • def isBoardFull(self):
  • Check if a player won.

  • def isWinner(self, tile):
  • Randomize the start (Return 'blue' or 'green')

  • def randomStart(self):
  • Function to call when user makes click

  • def didClickMouse(self):
  • Get Mouse coordinates relative to the board.

  • def getCoordinates(self):
  • move(object)

    Properties:

  • • x : x Coordinate of the move.
  • • y : y Coordinate of the move.
  • Makes the object printable.

  • def __str__(self):
  • About

    No description, website, or topics provided.

    Resources

    License

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

    No packages published