A multiplayer python game inspired by Asteroids
Create a multiplayer Asteroids game that runs on a Raspberry Pi and can handle 3 players.
The player controls a single spaceship in an asteroid field that is traversed by the other players ships. The objective of the game is to shoot and destroy all other ships, whilst not colliding with astroids, or being hit by counter-fire.
This game is based on Asteroids which has it's physics model, control scheme, and gameplay elements derived from Spacewar!, Computer Space, and Space Invaders. The Asteroids game is rendered on a vector display in a two-dimensional view that wraps around both screen axes. As we have 3 players and a very small screen the play area has been made larger and we follow the ship with a camera. The field is still titled for infinacy.
pip install -r requirements.txt
Start the server by running:
py server.py
Then in a separate terminal start the client with:
py client.py
Foreign clients can join by specifying the servers ipaddress eg:
py client.py 192.168.0.1
- Screen Size: 256 x 256 pixels
- 3 Players
Client Messages
Event | [0] Message type | [1] Player ID | [2] Data |
---|---|---|---|
ID Request | 'id_r' | 0 |
0 |
Player Ready | 'pr' | 0 |
0 |
Key Event | 'k' | int |
[Key Data] |
Server Messages
Event | [0] Message type | [1] Data Array |
---|---|---|
Id Assignment | 'id' | [int ] |
Ships Update | 's' | [[Ship Data] ] |
Bullets Update | 'b' | [[Bullet Data] ] |
Asteroid Update | 'b' | [[Asteroid Data] ] |
Key Data
(array):
0. key_updown
1. key_leftright
2. key_bulletshield
Ship Data
(array):
0. OwnerId (int)
1. ObjectId (int)
2. Position X (float)
3. Position Y (float)
4. Direction X (Float)
5. Direction Y (Float)
6. Thruster (Bool)
7. Shield (Bool)
8. Dead (0-2) False, True Animating, True
9. Score (int)
10. High Score (int)
Bullet Data
(array):
0. OwnerId (int)
1. ObjectId (int)
2. Position X (float)
3. Position Y (float)
4. Direction X (Float)
5. Direction Y (Float)
Asteroid Data
(array):
0. OwnerId (int)
1. ObjectId (int)
2. Position X (float)
3. Position Y (float)
4. Direction X (Float)
5. Direction Y (Float)
6. Size (int)
See requirements.txt