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
This is a python bot to automate BombCrypto game

This is a python bot to automate BombCrypto game. Logs in to the game, reconnects when needed, closes error warnings, sends heroes to work or home automatically, has Telegram integration and lets you

AFKAPP 39 Sep 28, 2022
Online battleships game on python and JS

Battleships Online battleships game Using websockets to connect to the client. SQLite database for storing account data and game logs (for players top

5 Nov 11, 2021
What games should I design next quarter?

Project1_Next-Quarter-Game-Design-Prediction What games should I design next quarter? 상황 : 게임회사 데이터팀 합류 문제 : '다음 분기에 어떤 게임을 설계해야할까' Data Description N

Jayden Lee(JaeHo Lee) 1 Jul 04, 2022
A simple matrix code rain created using Python with Pygame.

Matrix4_code_rain A simple matrix code rain created using Python with Pygame. To run the code you will need Pygame and MS Mincho font. Create a projec

7 Nov 06, 2022
PingPong - Simple Ping Pong Game Made In Python

PingPong Basic Ping Pong Game Made In Python

ʀᴇxɪɴᴀᴢᴏʀ 1 Jan 01, 2022
A use of the python MCPI to enhance the multiplayer and singleplayer gameplay.

Morpheus 2.0 A use of the python MCPI to enhance the multiplayer and singleplayer gameplay. To Use: You will need to install the keyboard, pysimplegui

11 Oct 11, 2022
Tic-Tac-Toe - Tic-Tac-Toe game build With Python

Tic Tac Toe This game is very popular amongst all of us and even fun to build as

PyLaboratory 0 Feb 06, 2022
Wordle-Python - A simple low-key clone of the popular game WORDLE made with python and a 2D Graphics module Pygame

Wordle-Python A simple low-key clone of the popular game WORDLE made with python

Showmick Kar 7 Feb 10, 2022
🐥Flappy Birds🐤 Video game. With your help I can go through🚀 the pipes. All UI is made with 🐍Pygame🐍

🐠 Flappy Fish 🐢 I am Flappy Fish 🐟 . With your help I can jump through the pipes and experience an interesting and exciting flight deep into the fi

MohammadReza 2 Jan 14, 2022
The repository that hosts the code that teaches a reinforcement learning - based bot to play 2048

The repository that hosts the code that teaches a reinforcement learning - based bot (based on policy gradients method) to play 2048

Maxim Rud 1 Dec 16, 2021
Just a simple Tic Tac Toe game, built with Python

TicTacToe Author: Gabriel Lima Table of Contents About Getting Started Linux Windows About This is one of the first projects I built when I first star

1 Nov 28, 2021
The main objective of the game is to destroy multiple waves of asteroids with the help of a blaster mounted on the spaceship.

Astronomia: let the exploration begin The main objective of the game is to destroy multiple waves of asteroids with the help of a blaster mounted on t

Aryan Nath 8 Nov 18, 2022
SelectionSortVisualization - This pygame project is helping you to understand the selection sorting algorithm

SelectionSortVisualization (If you have any comments or suggestion, please conta

Berkay IPEK 3 Feb 17, 2022
Space shooter being built for PyWeek 32

Axium Humanity's expansion into space had lasted centuries by the time we encountered the vicious Threx. The Threx adopted a single, religious mission

Daniel Pope 6 Oct 28, 2021
Nerdle - a nerd's approach to solving Wordle

Nerdle - a nerd's approach to solving Wordle

4 Nov 28, 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
Minesweeper clone with 3 modes of difficulty, UI scaling and custom games feature.

Insect Sweeper Minesweeper clone with 3 modes of difficulty, UI scaling and custom games feature. Mines are replaced with random insects that a player

Piotr Data 1 Nov 05, 2021
For educational purposes, a simple script that assists in solving the word game Wordle.

WordleSolver For educational purposes, a simple script that assists in solving the word game Wordle. Instructions Pick your first word from the sugges

Christian De Leon 2 Mar 25, 2022
Code infrastructure and player algorithms for the Codenames board game.

Codenames Code infrastructure and player algorithms for the Codenames board game. This is the active fork of mkali-personal/codenames. Intro This is b

Asaf Kali 1 May 18, 2022
2DMC is an abrrieviation for 2 Dimensional Minecraft.

2DMC 2DMC is an abrrieviation for 2 Dimensional Minecraft. This idea is originally created and implemented by Griffpatch on Scratch. This is a persona

DaNub 5 Nov 06, 2022