![]() ![]() ![]() A downside to this is possible cheating in inspect elements. In the end, I created a global state object indexed with the game code for state management, and opted for client side computation to decrease load on the server. To solve this, I referred to online tutorials such as this and this to learn more about multiplayer games. Additionally, deciding between client-side computation and server-side computation was also difficult. The idea of maintaining states so a single server can allow a large amount of rooms was very difficult. ![]() When first designing the game, the flow of events was very challenging as this is my first game developed. It is also supported by a firewall allowing public access from VPS#1 to port 27017 Challenges I ran into Architecture Decisions This VPS was started from an image found on the Linode Marketplace. Lastly, the mongodb database is hosted on another Linode running Debian 9. The VPS above is attached to a custom domain from using the DNS manager. The backend is also hosted on the same Linode but with forever - an auto restart tool for NodeJS servers in an event of a crash. The frontend is hosted on a Nginx web server on Linode running Ubuntu 20.04 - provisioned from scratch. The following services from Linode are used: Tetris Rivals is entirely hosted on the cloud using the Linode's suite of services. Once all the clients leave the room, it clears the state and deletes the code for future reuse. After any update to the game state, all (both) clients in the game room are notified and respectively update their UI. These events (and more) continuously update the collection of game states stored at all times on the server. It actively listens to key game events such as: This is accomplished through generating random 6 digit codes, storing them in a database, and listening/emitting events to sync all players. The server is responsible for generating game codes, managing game state, and maintaining game rooms. It keeps a channel open for communication while still offering security. The web socket communication protocol is better suited for real-time data transfer over the https protocol. The backend is a NodeJs server which operates on Socket.IO and MongoDB to implement web sockets. Socket.IO client implementation for real-time updates.Client side computation to alleviate server load and reduce costs.Game logic and construction (collision, validity, line clears, animation and opponent tile substitution).All of this is powered by several JS files which handle the application logic. Additionally, it has 2 CSS files responsible for the styling and the responsiveness of the application. ![]() It consists of an index.html which renders both the home screen, and the game room (more on that in challenges). The frontend is built entirely from vanilla HTML, CSS, and JavaScript.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |