The main purpose of this project was to create a simple 1v1 game that uses an ESP32 to taze losing player in real life.
However, as I progressed with development, the project evolved, and some of the sub-projects became more general-purpose than originally intended (which is fine). Of course, there's always room for improvement.
- Every players aim is to protect its base, and destroy opponents.
- Players can push each other.
- Initial health is 100
- Traps only effect the opponent spawned on the opposite side
- Traps hit a initial damage that is propotional to collision speed then it drops to a continous steady value.
- Friendly fire is on for bombs
- Bombs got damage of 10
- There is 1 second cooldown for dropping bomb
- Cannot move while dropping bomb
- On drone collisions slow one gets damaged proportional to fast ones speed.
If drone1 (left side) wins pin 33 of ESP32 will get activated as OUTPUT, HIGH. For second player pin 34 will be activated. Tazers and tazer swiches should be wired appropriately :) .
-
Player 1
W - UP
S - DOWN
A - LEFT
D - RIGHT
SPACE - DROP BOMB
-
Player 2
Numpad8 - UP
Numpad5 - DOWN
Numpad4 - LEFT
Numpad6 - RIGHT
Numpad0 - DROP BOMB
Change the values of
WIFI_SSID
,WIFI_PASSWORD
,TCP_HOST
,TCP_PORT
definitons in the main.cpp file of esp32 accordingly.
Communication Messages starts with 9 byte header and following data. You can find struct definitions on protocol.h and Message.cs files.
TYPE => 1 BYTE (char/byte) // Represents type of the data inerpretation
DATA_LENGTH => 8 BYTES (ulong/uint64_t) // Represents lenth of the data in bytes
DATA => DATA_LENGTH BYTES (byte[]/char*) // Byre array of represented data
BOOL = 0,
STRING = 1,
INT = 2,
FLOAT = 3,
DOUBLE = 4,
BYTE = 5,
JSON = 6,
STREAM = 7,
ESP_COMMAND = 8,
APPROVAL_SIGNAL = 9,
ERROR_SIGNAL = 10,
PING = 11,
- After a message is sent by server, Client is expected to send a approved signal
(Header type=9, data length=0)
or an error signal(Header type=10, data=(string error message))
- Client is expected to send Ping Signal
(Header type=11, data length=0)
with max of 10 sec. timeout to not get disconnected.
2D Game engine with physics, uses SFML for rendering. Feasable to extend and re-use out of this projects scope.
- Game Window
- Game Scene
- Game Entity Bases
- Animations
- OBB Collision Detection
- Physics Simulations
- Game Debug Utilities
- Game Events, Entity Events, Physics Events
Multi threaded server that accepts multiple connections and implements a custom protocol to communicate with esp32 (or any other clients) that uses TcpServer fot handling socket connections. Feasable to extend and re-use out of this projects scope.
- Server
- Connection List
- Custom protocol implementation [SEND/RECEIVE]
- Protocol Message Helpers
- Server Events
Souce code for embedded system (ESP32) that used platform.io and implements custom communication protocol. Feasable to extend and re-use out of this projects scope.
- Wifi & Socket Connection
- Custom protocol implementation [SEND/RECEIVE]
- Execute Esp32Command manupulate specified pin as [Input/Output], [Write/Read], [HIGH/LOW].
- Protocol Message Helpers
Console application that implements/runs the Drone Fight game and tcp server, also handles sending message to ESP32 when a player dies. PIN-33-HIGH for drone1 dead PIN-34-HIGH for drone2.
- Game Objects
- Game Sprites, Animations and Mechanics
- ESP32 Server
Helper to prettify console input/output and prettify logs. (multit hreadded).