Code for an arcade pop-a-shot style basketball game on Raspberry Pi

Overview

Basketball-Game

Code for an arcade pop-a-shot style basketball game on Raspberry Pi, made over the course of winter break 2022.

How To Run:

Running this project will require the use of a Raspberry Pi (I used a Raspberry Pi 3 B+) and an SD card of large enough size (32GB should be more than enough). I've made the process of installing this software on a new SD card easy by including a disk image in a zip file that can be found here. Simply download Raspberry Pi Imager, select the disk image as a custom OS installation, and finish the process. You should be left with a copy of the project on your SD card ready to insert into your Raspberry Pi.

Alternatively, if you wish to add this project to an existing OS installation (only tested with Rasbian OS), one can do so by SSHing into the Raspberry Pi remotely when the SD card is inserted, which is how I worked on this project without a monitor directly connect. Find out how to set up a Raspberry Pi without a monitor here. I personally used MobaXTerm to SSH in, as it allows for drag-and-drop file transfer between the local and remote system. After SSHing into the Raspberry Pi, drag the "BasketballProject" folder to the Raspberry Pi's user directory, likely labeled "/home/pi/". Then, clone the RGB LED Matrix Control repository (cited below) also into "/home/pi/".

No matter which option you choose from the above, after your Raspberry Pi is wired, the GPIO pins in "BasketballProject/basketballCode.py" as well as in "rpi-rgb-led-matrix/lib/hardware-mapping.c" can changed to suit your needs. The RGB LED matrix was directly wired to the Raspberry Pi in my case, but you may use something like the Adafruit RGB Matrix Hat or Bonnet, in which case that option should be selected in rpi-rgb-led-matrix/lib/Makefile. Again, more specific instruction on how to use the RGB LED Matrix Control library are on its github page below (I did not code it, I am just reporting my understanding of it). Then, run the proper makefiles in rpi-rgb-led-matrix (follow their instructions) and run basketballCode.py using sudo.

Documentation Notes:

I use "canvas", "scoreboard", and "RGB matrix" interchangably in the code commenting, as they are all the same thing.

"Clock" and "timer" are used interchangably as well.

Known Issues:

The first pair of scrolling text is misaligned the first time it runs, but all other scrolling text is aligned afterwards:

This is because the centering offset is only applied when the text is changed, but not the first time the text is initially set. The centering process uses the distance covered by the drawn text, but when assigning the positions of the first pair of scrolling text, it has not been drawn yet because drawing the text requires the positions to already be set. There are workarounds I know of to fix this, but it is a minor issue that causes no errors.

The RGB LED matrix has a slight flickering issue:

From my research, this is partly because the Raspberry Pi is running too fast for the RGB LED matrix to handle, since something relatively high tech is being used for a comparably simple purpose. The GPIO output to the RGB LED matrix can be slowed down to mitigate this, and has been done in the code provided. My other recommendation is to make sure all of the files are correctly made in the rpi-rgb-led-matrix/ directory. When using Python, there may be as many as three seperate makefiles that must be ran to guarentee changes to hardware-mapping.c are carried over to the program.

All lights sometimes flash once every second, for a few seconds:

This likely won't happen for you unless there is a wiring issue. On my end, this only started occuring once the backboard LEDs and timer electronics were moved onto the backboard piece, while the code remained unchanged. There may be some crossing of wires, since in my testing, the flashing occurs even when code is not running.

The timer glitches for a split second whenever a point is scored, and then reverts back to normal:

This may not happen for you, but for me, I believe this is due to power being drawn when a point is scored in order to change the backboard LEDs, since the backboard LEDs and timer run off the same power wire.

Citations:

Sparkfun Starter Code for Our Model of Seven Segment Display: https://learn.sparkfun.com/tutorials/large-digit-driver-hookup-guide

Translation of Sparkfun Starter Code from Arduino to Python by Jonah Lefkoff: https://medium.com/@jonah.lefkoff/how-to-hook-up-the-sparkfun-7-segment-display-to-a-raspberry-pi-577591ba94b5

RGB LED Matrix Control Library for Raspberry Pi by Henner Zeller: https://github.com/hzeller/rpi-rgb-led-matrix

Owner
Seth Reis
Older repositories such as high school homework assignments have been cleared.
Seth Reis
A Game of Life implementation in Python

Game of Life in Python (Golipy) Golipy is a simulator of John H. Conway's Game of Life, developed in Python based on the Pygame library. This is a toy

Alber 2 Dec 10, 2021
SpiderArcadeGame - A game where the player controls a little spider who is trying to protect herself from other invasive bugs

SpiderArcadeGame - A game where the player controls a little spider who is trying to protect herself from other invasive bugs

Matheus Farias de Oliveira Matsumoto 1 Mar 17, 2022
Lutris desktop client in Python / PyGObject

Lutris Lutris is an open source gaming platform that makes gaming on Linux easier by managing, installing and providing optimal settings for games. Lu

Lutris 6.1k Dec 30, 2022
Projeto Flappy Bird temática doom, projeto python e pygame

Doom-Bird Tecnologias usadas Requisitos para inicializar o jogo: Python faça o download em: https://www.python.org/downloads/ Após instalar o Python d

João Guilherme 1 Dec 08, 2021
A set of tools to help you with running a Project Zomboid game server (Linux only)

Project Zomboid Server Tools A set of tools to help you with running a Project Zomboid game server (Linux only). Features Install Project Zomboid Dedi

24 Dec 25, 2022
A playable version of Chess – classic two-player, various AI levels, and the crazyhouse variant! Written in Python 3

A playable version of Chess – classic two-player, various AI levels, and the crazyhouse variant! Written in Python 3. Requires the installation of PIL/Pillow and Requests

1 Dec 24, 2021
An interactive pygame implementation of quadtree spatial quantization

QuadTree-py An interactive pygame implementation of quadtree spatial quantization Contents Installation Usage API Reference TODO Installation Clone th

Ethan 1 Dec 05, 2021
An asynchronous Minecraft server wrapper written in python3 with asyncio

mark3 (WIP) A modern Minecraft server wrapper written in python3 with asyncio TODO Note: The order of the following checklist doesn't necessarily mean

Colin Andress 7 Jul 29, 2022
Flappy Bird clone in Python using Pyglet

python_Flappy-Bird This is the Game Flappy Bird which was originally developt by Dong Nguyen under .Gears recreated in Python. Requirements (used to d

Konstantin Opora 1 Dec 10, 2021
A Replit Game Know As ROCK PAPER SCISSOR AND ALSO KNOW AS STONE PAPER SCISSOR

🔥 ᴿᴼᶜᴷ ᴾᴬᴾᴱᴿ ᔆᶜᴵᔆᔆᴼᴿ 🔥 ⚙️ Rᴜɴ Oɴ Rᴇᴘʟɪᴛ 🛠️ Lᴀɴɢᴜᴀɢᴇs Aɴᴅ Tᴏᴏʟs If you are taking code from this repository without a fork, then atleast give credit

ANKIT KUMAR 1 Dec 25, 2021
NSI project --> 2D platformer in Python with Pygame

Projet de NSI (2021-2022): Jeu sous Python Collaborateurs: Remi K-S et Nathan D Lien de l'environnement IDE de Python en ligne: https://replit.com/@Re

Remi K-S 3 May 24, 2022
A top-down arcade space shooter made in pygame.

About: Journey Through Space is a top-down arcade shooter made in pygame. You play as a pilot who was left behind after a battle and the goal is to go

Crimson Sane 0 Jan 01, 2022
A Python based program that displays Your Minecraft Server's Status Infos.

Minecraft-server-Status This (very) small python script allows you to view any Minecraft server's status Information Usage Download the file, install

Jonas_Jones 2 Oct 05, 2022
Wordle player - A Class that plays wordle optimally

wordle_player A Class that plays wordle optimally if you want to play wordle opt

Andrés Hernández 1 Jan 31, 2022
PyGame-Tutorial - Refrence for building games in pygame

PyGame-Tutorial How to build games using the python library PyGame End result Ho

St. Mark's Computer Science Club 2 Jan 09, 2022
A python snake game based on pygame.

PySnake A python snake game based on pygame. Requirements Package version pygame = 2.1.2 opencv-python = 4.5.1.48 Run Windows python main.py Linux &

2 Jan 31, 2022
Datamining of 15 Days of (free) Games at the Epic Games Store (EGS).

EGS: 15 Days of Games This repository contains Python code to data-mine the 15 Days of (free) Games at the Epic Games Store (EGS). Requirements Instal

Wok 9 Dec 27, 2022
MiTM proxy server for Darza's Dominion

Midnight A MiTM proxy server for Darza's Dominion, PC version. See this video for a demonstration of godmode: https://youtu.be/uoqvSxmnCJk How to use

2 Oct 24, 2022
Searches the word list in Wordle based on search pattern.

Wordle Searcher Searches the word list in Wordle based on search pattern. Warning: like all forms of cheating, it trivializes the game, and robs you o

Tyler Martin 1 Jan 29, 2022
Cheats for shooter games

Cheats Cheats for shooter games Download Trigger Bot trigger.exe // trigger.sha256 Download Certify Bot certify.exe // certify.sha256 Note: Check sha2

Emin Muhammadi 1 Nov 26, 2021