crazy2be / buildblast

Build a base, shoot intruders
MIT License
5 stars 1 forks source link

BuildBlast

BuildBlast Screenshot

Try it at BuildBlast.com

Or try it on a dev server

Installation

Install go, (or sudo apt install golang on a modern ubuntu)

git clone https://github.com/crazy2be/buildblast.git buildblast
cd buildblast && ./runserver
google-chrome http://localhost:8081

You may need to do some config setup due to some things being slightly broken, see #189

To run the www server, enable authentication, and enable multiple worlds, see WEBREADME.md

Coordinate Systems

We use two main coordinates systems in the code:

In map generation and geometry code, which is particularly concerned with the existence of chunks, you may also see the following coordinate systems used:

Lag hiding

In order to make the game playable with hundreds of milliseconds of lag we apply multiple algorithms to reduce the appearance of lag. You might find this article by Valve to be helpful if you are interested in this.

Lag Compensation (Shooting is accurate regardless of lag)

If the client shoots at time 0 ms, and the server receives it at time 100 ms, it is likely the person they were shooting at has moved since the time they shot. So, we "lag compensate" players (entities). This means the server stores the history of positions for every player, and the player timestamps its shoot events, so when the server receives the shoot it can simulate it with the player positions that existed when the shot was fired.

Input Prediction (No player movement lag)

When the player presses a movement key technically we need to wait until the server confirms the message to know if we can move, since the server is the "master". However, it's much nicer from a user's perspecitve if the controls respond immediately. Thus, we use the client's game state to make predictions about what will happen, and show that state to the player. If the server thinks something different happened, we'll throw away our predictions, and follow it's command.

Lag Induction (Smooth other player movement and easier gameplay)

The server may send messages at a varying speed, and we may receive them at a varying speed. This means other player's will appear to jerk around as we receive movement messages. To get around this we store don't immediately show player positions as we receive them, instead we show players where they were lagInduction time in the past. This gives us a buffer to hide the impact of lag (and smooth out movement). clock.entityTime() is the current time that entities are being displayed at.

Architecture (client side)

The architecture is based on a few fairly simple structures, which communicate through a few objects (similar to http://yuml.me/d5f4fb7b). Specifically:

Bugs

If you find any bugs, please report them in the issue tracker with your hardware specs, screenshot, and steps taken to trigger the issue.

Firefox is not supported pending #504553.

Experiments

If you want to try out something hard, and possibly impossible, attempt one of these:

Or checkout the bug list (for bugs or features, whichever suits your fancy).