Battleship game played on Raspberry Pi Zero 2W and LED RGB matrices
- Python 3.11+ installed
- pip
- sudo privileges (e.g. for gpio)
- nmcli (network-manager installed)
-
Clone the code
sudo git clone https://github.com/onyxcherry/battleships-game-on-rpis.git /battleships-game-on-rpis
replace
rpiuser
with your username!sudo chown -R rpiuser:rpiuser /battleships-game-on-rpis
-
Install requirements
cd /battleships-game-on-rpis && python3 -m venv venv && source venv/bin/activate
pip install wheel -r requirements.txt
-
Add
battleships
connectionsudo nmcli con add type wifi ifname wlan0 con-name battleships autoconnect yes ssid battleships mode ap ipv4.method shared connection.autoconnect-priority 200
-
Set the password
nmcli con modify battleships wifi-sec.key-mgmt wpa-psk
replace the password with your own
nmcli con modify battleships wifi-sec.psk "veryveryhardpassword1234"
-
Make the AP running
nmcli con up battleships
-
Verify the AP has been created successfully
List active connections
nmcli -f NAME,UUID,AUTOCONNECT,AUTOCONNECT-PRIORITY c
Now, you should be able to connect to hostname battleships via WiFi with the provided password.
Run
sudo nmcli device wifi connect battleships password veryveryhardpassword1234
In order to run and manage battleships game server automatically, run the server at one device
mkdir -p ~/.config/systemd/user/
cp /battleships-game-on-rpis/infra/server.service ~/.config/systemd/user/battleships-server.service
loginctl enable-linger
systemctl --user daemon-reload && systemctl --user start battleships-server.service && systemctl --user enable battleships-server.service
See the server status by systemctl --user status battleships-server.service
or journal logs by journalctl --user -u battleships-server.service
Run the client on both devices
sudo cp /battleships-game-on-rpis/infra/client.service /etc/systemd/system/battleships-client.service
touch /battleships-game-on-rpis/client-logs /battleships-game-on-rpis/client-error-logs && chmod a+wr /battleships-game-on-rpis/client-*
sudo loginctl enable-linger
sudo systemctl daemon-reload && sudo systemctl start battleships-client.service && sudo systemctl enable battleships-client.service
LED matrices should light up now.