Spellbreak Arena 2D

A 2D multiplayer arena game

Screenshot of spellbreak game

This game was based of the original version of Spellbreak which was in 3D and inspired me to make a 2D version because of its unique style and fun mechanics. The way I started off my project was by creating a class based system for all the objects in the game. These objects included players, projectiles, obstacles, and consumables. This way I could structure the game while maintaining flexibility if something new needs to be added to a class. Once I had the classes set up, the next step for me was to start adding functionality as well as working with canvas. In the single player version, everything was going smooth. I was able to create functional collision detections for all the objects, create event listners to listen for movement and mouse position, and to draw everything on the canvas in their correct position and angles.

Although the game worked in single player, I wanted to try to make it multiplayer as it would be hard for 2 people to play on one computer. After this decision, I learned that I had to restructure the whole architecture and assign roles to what the server should be doing along with the client. To implement this communication I used Socket.io and Express. I set it up so that the client would listen to user events and share them with the server through designated sockets. The server would take that data, run it through the games logic, and then update the rest of the clients with a tick rate of about 33. This means it would be sending 33 updates per second. Finally, the client side would render everything using canvas for that specific client by using socket ID's. To make the game more interactive, I added animated sprites along with sound effects. I learned that having a proper architecture when dealing with a full-stack application is key for avoiding bugs and simpler coding.

There is a lot more I could have added to this game to improve it but felt it getting quite complicated so I decided to leave it as is. Some aspirations I had were to add Socket.io rooms. This would allow multiple rooms with specific ID's so that it would be playable by as many people the server could handle. Since I didn't use rooms, the game is currently only available to the first 2 people who joined the server. Another aspiration I have for the future is to improve optimization. Right now, the game is super laggy because I am sending a lot of unnecassary data. I learned that one way to improve optimization is to first send an initialization package and then send an update package which only sends the difference between the two. Hopefully, I will be able to add these features and more as I learn more about the backend.

Check out my site: Spellbreak Arena 2D Multiplayer