Skip to content

heathermortensen/PigGame

Repository files navigation

PigGame

Pig face

  • Pig is a dice rolling game (also known as Skunk).
  • Screen #1 allows the user to enter the number of players in the game and their corresponding names.
  • Screen #2 allows players to play Pig and displays a scorecard.

Java version of the dice rolling game = Skunk

  • I first programmed the Skunk game in Java using Eclipse.
  • It produced output to terminal.
  • It is located in the SkunkGame repo of my Github page.
  • A detailed game description can be found in the SkunkGame README.md file.

Python version of the dice rolling game = Pig.

  • Frontend screen designs (screen1.py and screen2.py) were sketchd out in PyCharm using python's Tkinter GUI frameowrk on Windows.
  • The backend will be translated from Java into Python using Spyder IDE shipped with Anaconda on Mac OSX.

Software installs

Software Version Location
Homebrew 2.4.0 Mac: User/local/Cellular
Powershell 7.0.3
OpenSSL 2.8.3
pip
------------- ----------- ----------------------------
Anaconda 3
Python 3.8
Spyder 4.1.4
Kite
------------- ----------- ----------------------------

Step 1.) Frontend sketch

  • I first designed both screens in Tkinter (UI framework inherent to python 3) to sketch out a basic layout for the game (see figures 1 and 2).
  • I use the PIL Imaging Libary, which excludes me from using Pillow. (verify this - which did I install? They are mutually exclusive.)

File: screen1.py

Screen #1 on Windows & Mac

Figure 1. Screen 1 demonstrates basic button click to display game rules

File: screen2.py

Screen #2

Figure 2. Screen 2 is where players take turns rolling dice and a scorecard will be displayed

Step 2.) Program frontend functionality

  • Having aquainted with Tkinter, I started fresh.
  • I programmed into a blank file containing only necessary widgets required to test UI functions.
  • Design elements from screen1.py and screen2.py can be added in quickly later.
  • This file is called piggy.py and contains a class for instantiating Window objects.
  • The window1 object contains the functionality for screen 1 (see figure 3).
  • A second instantiaion of the Window object can be easily adopted to accomidate screen2.

File: piggy.py and its corresponding console output

Window class

Figure 3. The Window class

  • The class based window accepts and validates user input for the number of players and the names of each player.

userInputValidation

Figure 4. User input validation for screen 1

  • This step concludes basic programming for the View in MVC.

console output

Figure 5. User input required to run the program

Step 3.) Program the backend

  • Remember to make the controller navigate to the 2nd window (not the 1st window)
  • write something here...

Resources for merging this frontend (multiple class based windows) together with the python backend:

About

SkunkGame repo java program translated into python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages