I made a multiplayer game from scratch because no one is hiring junior devs.
Software Job Hunt and Game Development Journey
Introduction to the Project
- The speaker expresses feelings of being stuck in their programming job, prompting a software job hunt in 2024.
- To enhance their resume and demonstrate computer literacy, they decide to create a multiplayer browser game.
Game Concept and Design
- The game is a one-on-one turn-based tactics game on a hexagonal grid where players control tanks.
- Players will have limited visibility around their vehicles, adding uncertainty; the map will shrink over time to prevent stalling.
Graphics and Technical Choices
- The aesthetic chosen for the game is pixelated, isometric graphics, utilizing previously created low poly models for sprites.
- The client side will be developed using TypeScript for better error management, while the server side will use Google's Gopher language without frameworks.
Initial Development Steps
- The first task was making the canvas responsive to different screen sizes and resolutions.
- Implemented functionality to display images on the canvas by packing sprites into a single PNG file with specific offsets.
Interactivity Features
- Added interactivity through dragging mechanics using vector offset values; established architecture with GameState object managing data.
- Developed tank navigation allowing movement and shooting in six directions; implemented limits on movement range.
Advanced Gameplay Mechanics
- Introduced "fog of war" limiting player visibility based on tank position; distant areas are darkened out.
- Created markers indicating valid movement cells considering obstacles, calculated via breadth-first search algorithms.
User Interface Development
- Designed an adaptive UI system using invisible panels that resize according to screen dimensions for button placement.
- Buttons were implemented as painted areas on the canvas rather than traditional HTML elements, requiring custom event handling.
Interaction Management
- Ensured that UI interactions do not interfere with gameplay actions by distinguishing between map navigation and button clicks.
Game Development Progress Update
Implementing Server-Side Logic
- The Notifier component is designed to relay button and game events from the UI and Grid to the Game instance. A file server was established to serve static files alongside a websocket endpoint for player interactions.
- The server will handle players' intended moves, resolve them, and return results using JSON for simplicity instead of creating a custom binary message format.
- Key features include tracking projectile paths, ensuring they do not exceed limits or collide with obstacles, and managing tank visibility to prevent unfair advantages.
Enhancing Gameplay Mechanics
- Tanks can now be destroyed upon being hit; however, animations are still pending implementation. The focus is on adding shooting mechanics first.
- Movement complexity can vary from simple constant speed to more natural acceleration patterns, requiring mathematical calculations involving integrals for realistic motion.
Multiplayer Functionality
- Two player matching modes are proposed: private rooms via codes or open rooms for random matches. Mobile compatibility poses challenges in input handling.
- To address mobile input issues, an HTML input element will be integrated into the game interface despite breaking some abstraction principles.
Managing Player Actions
- Golang's channels are utilized for communication between players and rooms, leading to complex channel connections that require careful management to avoid goroutine leaks.
- Validating player actions involves multiple checks such as path continuity and collision detection with other tanks or buildings.
Final Touches and Features
- While core multiplayer logic is functional, it requires further optimization. Current checks may lead to bugs due to redundancy in loops or inefficient data representation.
- A shrinking map feature is planned to encourage engagement during gameplay by dissolving areas around the center over time.
Audio Integration
- Additional messages from the server regarding room disconnections or match results have been implemented through a new modal-like UI element. Sound effects were added using .mp3 files sourced online.
- An explosion shake effect was created using sine waves for realism in visual feedback during gameplay.
Game Development Insights and Challenges
Game Deployment and Features
- The game has been successfully deployed at tankops.xyz, with a link to the GitHub repository provided in the description.
- Additional features implemented include OAuth2, persistent database, rate limiting, a landing page, quick tutorial, and single-player mode.
- Enhancements made to the user interface consist of explicit markers on tanks, an updated HUD displaying game information, GitHub-like avatars, a rotating tank in the main menu, a speed-up button, and pinch gesture support for zooming on mobile devices.
Issues with iOS Compatibility
- A significant challenge arose when testing the game on an iPhone; it disconnected during window changes due to aggressive throttling of websocket connections by iOS.