Giter VIP home page Giter VIP logo

go-tank's Introduction

go-tank


Simple multiplayer 'real-time' online game that uses WebSockets and is played via browser. Also known as 'io game' type. Created with Golang (backend) and JavaScript/Phaser 3 (frontend).

more info

Getting Started

Prerequisites

Things you need to install.

  • Golang (tested on 1.19.3)
  • Browser that support JavaScript

Installation and Building

  1. Clone repository using command git clone https://github.com/vytautashi/go-tank.git
  2. Run command go build within /game-server directory
  3. Run command go build within /game-client directory

Running Game

  1. Run game-server executable in /game-server directory
  2. Run game-client executable in /game-client directory
  3. Access game using browser via url http://localhost:8081 (open on multiple tabs to spawn multiple players)

Game Controls

  • Movement - keyboard arrows (up, down, left, right)
  • Fire gun - spacebar

More Info

This repository demonstrates basic created 'io game' using Golang and Phaser. Player can move and fire bullets which collides with other players. Its not blooted with a lot of functionality in order to make it simple and easy to understand.

It does have:

  • Movable game characters (tanks)
  • Bullets collision with players
  • Communication between server and clients via WebSockects
  • Backend uses concurrency (Golang go routines, communication via channels, non-blocking)

It does not have:

  • IP restrictor (same person from same computer can have multiple active players in game) (backend)
  • Spam restrictor (do not limit message count received from clients/players via WebSockects) (backend)
  • Client-side prediction (https://en.wikipedia.org/wiki/Client-side_prediction) (frontend)
  • Code is not performance friendly (highly optimised code would be hard to read/understand)
    • Now bullet objects are recreated everytime in frontend when it gets message about bullets positions from game-server, better would be to track bullets using id and move them accordingly instead of recreating or/and instead of deleting hide somewhere of the game screen and when command received, just set to correct position. (frontend)
    • Might be good to send only once Bullet data (position, speed, lifetime, moving direction) and let frontend calculate every next frame bullets positions, only send additional message to frontend if bullet collided with player and exploded so to remove bullet ealier from frontend. (backend+frontend)
    • And other places.

Screenshots

Screenshot 1

screenshot 1

go-tank's People

Contributors

vytautashi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

hyunsungk

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.