Starship Showdown is a fun and thrilling, space-themed, local multiplayer game adapted from "Buckshot Roulette" and implemented in Python using the Pygame library.
You will need to download Python and some additional packages in order to run "Starship Showdown."
Download and install Python from https://www.python.org/downloads/
Run the following command in your terminal to install Pygame:
pip install pygame
Run the following command in your terminal to intsall Pygwidgets:
pip install pygwidgets
You can download the files for Starship Showdown directly from this repository or use Git to clone the repository by running the following command in your terminal:
git clone https://github.com/Kanisorn-S/Buckshot_dev.git
Navigate to the "Buckshot_dev" directory then run the following command in the terminal to start the program:
python main.py
- Players start the game with 6 health, 4 healthy and 2 critical
- Players will take turns to shoot each other with the green box indicating the turn
- The amount of live and blank rounds will show on screen
- When shooting, players will have the choice to shoot the opponent or themselves
- Turns will switch after shooting an opponent or shooting yourself with a live round
- Player will continue their turn when shooting themselves with a blank round
- Shooting anyone will a live round will reduce their health by 1 point
- When out of bullets, the gun will reload and bullets will display again
- When all healthy health are gone player will enter the disrepair state where they cannot gain health and will die on the next shot
- When one player dies, the other wins
- Items are used to affect the games in your favor
- Every time the gun is reloaded, each player will gain 4 random items which can be in duplicates
- Each player can only have a total of 8 items at once and new items won’t be added
- Items can only be used in the corresponding player’s turns
Pot of greed
- Gets 2 additional itemsSuper charger
- The next shot will deal 2 points of damageGN drive
- Increases the evasiveness of the user by 50% for the next shot takenDemon core
- Skips the opponent’s turn and can only be used once in the user’s turnCrewmate
- Restore one healthy heart of the user but will do nothing when in the disrepair stateAccess Card
- Immediately skip the next shot in the gun and show what type of bullet it isLasso
- Takes away one item on the opponent’s side and destroy it
Left/Right Arrow
- Aims the laser cannonSpacebar
- Fire- Click on items to use
F
- Toggle full screen mode
This project is developed as a part of the Programming Methodologies course, focusing on Object-Oriented Programming.
images
- Contains all of the artwork and spritessounds
- Contains all of the music and sound effectssrc
- Contains all of the Class and Function code
main.py
- The main program, used to control which menu to displaygameManager.py
- GameManager class. Manage all elements of the game by initializing, updating, and drawing all elementsplayer.py
- Player class representing a player. Contains attributes like health, evasiveness, id and methods like shot, which updates the player's status after getting shot, and update, which facilitates the player's animation and sprite changesgun.py
- Gun class representing the laser cannon. Contains a stack ofBullet
s. Handle the aiming, shooting mechanisms and displaying of bullets.bullet.py
- Bullet class representing a bullet. Contains class variables to signified its type, LIVE or BLANK. Contains the bullet's damage which is used to calculate a player's health after getting shot.itemStack.py
- ItemStack class representing a deck ofItem
s to be drawn from. Manages and loads item randomly.item.py
- Item abstsraction class, inherits from the pygwidgets.CustomButton class for functionality. Also contains different type of items as a subclass of the Item class, each differing in the usedItem method.starting.py
,ending.py
,rules.py
- Contains functions that display different menus. Return an int that signifies the program's state, which is used bymain.py
to correctly display different menus
main.py
- Display the correct menu by running different functions based on the current state of the program. Check for button press to change state by utilizing the pygwidgets.CustomButton.handleEvent method. Initializes a gameManager when in game state and passes events into the GameManager.handleEvent methodGameManager
- Initializes players using the loadPlayer method, a gun, and an itemStack. Keep tracks of each player's items in the playersItem attribute, the current turn, winner, target, and each object's status and makes appropriate update in the update method. Handles user's input, including aiming the gun, firing, and using items, throught the handleEvent method. Draws all the appropriate objects using the draw methodPlayer
- Have health, id, evading, evasiveness, disrepair as attributes. Contains getter and setter methods for health and evasiveness to employ data validation. The evade and shot methods are used to update the player's status when using the evasive item and getting shot respectively. The update and draw methods are used to do per-frame update and blitGun
- Have a list of players and target as attributes to keep track of the player who's being aimed at. The odds attribute is used , when loading bullets into the bullets attribute through the load method, to set the odds of a bullet being either live or blank, with the live and blank attribute keeping track of how many bullets of each type is left. Has the aimRight, aimLeft, and fire method for implementing the aiming and firing mechanismBullet
- Have type and damage as attribute to determine its effect on a player. The rest of the attributes and methods are for the firing animationItemStack
- Load a stack of items, using the loadItem method, into the items attribute on initialization. The getItem method is used to pop the top most item and the shuffle method shuffles the deckItem
- An abstract class that inherits from pygwidget's CustomButton. Utilizes the CustomButton's handleEvent method to check for item usage. Has the usedItem method, called when an item is clicked on, as an abstract method. The rest of the attributes and methods are used for animation
Encapsulation
- Several classes uses encapsulation by having private attributes, using the property decorator, having a getter and setter function in conjunction with raising Exceptions in order to ensure the validity of the attribute's value. For example, the Player class has health and evasiveness as private. The setter for health ensures that a player's health doesn't exceed a max of 6, while the setter for evasiveness ensures that a player's evasiveness is a probability, that is being between 0 and 1 inclusive. The Gun class's odds attribute also employ a similar data validation as the Player's evasiveness. Furthermore, the target attribute is private, with the setter checking that the target is either 0 (aiming at Player1) or 1 (aiming at Player2)Abstraction
- The update method and many other methods concerning animations is an abstraction. By hiding complicated details of updating the class's attributes, state, and sprite (for animation), the client program, the gameManager in this case, can simply call the update method without worrying about its complexity in its implementationInheritance
- The Item class and its subclasses exhibit inheritance. The Item class inherits from pygwidgets's CustomButton in order to utilize the functionality of a button, while adding additional methods for applying an item's effect. The different items then inherits from the item class, creating a class hierarchy. Each item modifies the usedItem method in order to implement its own functionalityAbstract Class
- By inheriting from ABC, the Item class is an abstract class. An Item object should never be initialized, only its subclass should. The item class also includes an abstract method: usedItem. Each item type must overrides this method in order to implement its own effectPolymorphism
- Every class, except the ItemStack, exhibits polymorphism by having both the update and draw method. This allows the gameManager to call update and draw on every object in the program without worrying about its class. The different items also exhibits polymorphism through the usedItem method. Each item has a different implementation of the usedItem method in order to reflect the difference in effect; however, due to polymorphism, the gameManager can call usedItem on any item object