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

You might also like...
Ice-Walker-Game - This repository is about the Ice Walker game made in Python.

Ice-Walker-Game Ce dépot contient le jeu Ice Walker programmé en Python. Les différentes grilles du jeu sont contenues dans le sous-dossier datas. Vou

Deal Or No Deal was a very popular game show. Even now, for a family party, it's a fun game to pass time

Deal Or No Deal was a very popular game show. Even now, for a family party, it's a fun game to pass time. I made a code to play the game right in your terminal/console. This isn't made to be a game which can be installed by everyone and played, I just made it as a fun project as I just started out with python. So if you have python installed and wanna have some fun, or just curious to see how I did this, feel free to check the code out!

Mastermind-Game - A game to test programming and logical skills

Bem vindo ao jogo Mastermind! O jogo consiste em adivinhar uma senha que será ge

Quiz Game: answering questions naturally with a friendly UI to enjoy the game
Quiz Game: answering questions naturally with a friendly UI to enjoy the game

About Quiz Game : The Game is about answering questions naturally with a friendl

This is a simple telegram bot for the game Pyal, a word guessing game inspired by Wordle

Pyal Telegram Bot This is a simple telegram bot for the game Pyal, a word guessing game inspired by Wordle. How does it work? Differently from the ori

Adventure-Game - Adventure Game which is created using Python

Adventure Game 🌇 This is a Adventure Game which is created using Python. Featur

Game-of-life - A simple python program to simulate and visualise the Conway's Game of life
Game-of-life - A simple python program to simulate and visualise the Conway's Game of life

Conway's game of life A simple python program to simulate and visualise the Conw

Launcherpi - Minecraft Launcher for Raspberry Pi computers

launcherpi Minecraft Launcher for Raspberry Pi computers. ASLO BIG THANKS TO KLO

Game code for Evennia servers designed for use with ALPACASclient.
Game code for Evennia servers designed for use with ALPACASclient.

ALPACASgame Game code for Evennia servers designed for use with ALPACASclient. This code is meant to be a type of "compatability layer" between the AL

Owner
Seth Reis
Older repositories such as high school homework assignments have been cleared.
Seth Reis
Software Design | Spring 2020 | Classic Arcade Game

Breakout Software Design Final Project, Spring 2020 Team members: Izumi, Lilo For our Interactive Visualization, we implemented the classic arcade gam

Lilo Heinrich 1 Jul 26, 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 1, 2022
Blender Game Engine Game Type Templates Logic Bricks (and Python script) based Game Templates for Blender

Blender-Game-Engine-Templates Blender Game Engine Game Type Templates Logic Bric

null 3 Oct 25, 2022
Mandaw 2 Mar 1, 2022
Snake game mixed with Conway's Game of Life

SnakeOfLife Snake game mixed with Conway's Game of Life The rules are the same than a normal snake game but you have to avoid cells created by Conway'

Aidan 5 May 26, 2022
Lint game data metafiles against GTA5.xsd for Rockstar's game engine (RAGE)

rage-lint Lint RAGE (only GTA5 at the moment) meta/XML files for validity based off of the GTA5.xsd generated from game code. This script accepts a se

GoatGeek 11 Sep 18, 2022
HTTP API for FGO game data. Transform the raw game data into something a bit more manageable.

FGO game data API HTTP API for FGO game data. Transform the raw game data into something a bit more manageable. View the API documentation here: https

Atlas Academy 51 Dec 26, 2022
A near-exact clone of google chrome's no internet game, or the "google dinosaur game", with some additions and extras.

dinoGame A near-exact clone of google chrome's no internet game, or the "google dinosaur game", with some additions and extras. Installation Download

null 1 Oct 26, 2021
Quantum version of the classical Nim game. An automatic opponent allows to game to not be as easy as it seems.

Nim game Running the game To run the program just launch : python3 game.py Rules This game is inspiring from the Nim game. You are 2 players face to f

Michaël 1 Jan 8, 2022
Average Clicker Game (AVG) is a Python made game using tkinter

Average-Clicker-Game Average Clicker Game (AVG) is a Python clicker game not made with pygame but with tkinter, it has worker, worker upgrades, times

Zacky2613 1 Dec 21, 2021