Game: Making Treasure Hunt Game with Kivy

Making games with Kivy (4/4)

*note that this task is a part of a series of tasks, but also self-contained.

(1) Objective

Make a game using Kivy framework that is similar to the Minesweeper, but the other way around. You need to deploy treasures across the board instead of mines, and let player find them out rather than avoid clicking on it.

(2) Requirement

1) Write a class or a function that generates a 16-card deck in python.

  • Keep it mind that the 16 cards will turn into 4x4 board.
  • Your function needs to randomly select 9 out of 16 cards, then mark them as treasures.
  • Count the number of surrounding treasures of each non-treasure card, write the number down to the card. (put 0 in case there is no)

2) Visualize your 4x4 board with Kivy

  • Visualize your card deck with GridLayout.
  • Use Button to represent a card.
  • Make sure that you keep the cards close at beginning.

3) Implement card flipping

  • Handle player’s mouse click event for each button.
  • Reveal the hidden number or treasure mark when it’s clicked.

4) Polish your app so that it looks like a game

  • Limits attempts by 8, so that player can only flip half of cards.
  • Display status using Label widgets; Number of attempts left, Total number of treasures, Number of treasures that player has found.
  • Implement restart game function.

5) Publish your work to your GitHub (or other) repo.

(3) Expected outcome

A complete Treasure Hunt game written in Kivy. See (2) Requirement for detail.

Task tags

  • python
  • game
  • git
  • github
  • kivy

Students who completed this task

Juanvhook, Ronin

Task type

  • code Code