I made a multiplayer game from scratch because no one is hiring junior devs.

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.
Video description

This is a summary of how I wrote a turn based multiplayer game (from scratch?!) in Go and Typescript. Animations made in Manim lib. play it: https://tankops.xyz/ source code: https://github.com/kodestan/tank-ops visit my personal website: https://kodestan.com/ hexagonal grids: https://www.redblobgames.com/grids/hexagons/ 0:00 - Intro 0:32 - Game idea 0:59 - Graphics and tech used 2:05 - Responsive canvas element 2:19 - Drawing objects 2:49 - Dragging/Zooming 3:42 - Tank navigation system 4:36 - Limiting visibility and range markers 5:07 - UI system 6:40 - Provisional single player server 8:03 - Animations 8:56 - Taking user input 9:35 - Multiplayer server 11:09 - Shrinking and modal notifications 11:48 - Sounds 12:20 - Camera shake 12:58 - Result 13:21 - Other stuff I did to deploy 13:49 - Apple issues sounds/clips/photos from: https://www.zapsplat.com/ https://unsplash.com/ https://pexels.com/