Skip to content

About

Multi-player 2D battle arena

Resources

Stars

2 stars

Watchers

1 watching

Forks

Repository files navigation

Pentagon Bullets

A fast multiplayer arena game: pentagons in teams shoot bullets at each other, each with an ability of their choice (on top of everyone's shield), while gods spawn heal units and damage zones, and the mist closes in. The last team standing wins.

Pentagon Bullets was the proof of concept of Battle for Flatland. It now runs on Battle for Flatland's technology: a LÖVE client written in Scala (compiled to Lua), game servers run by the players themselves, and UDP all the way.

How it is made

Sub-project What it is
shared The game logic (GameState, GameActions, entities, abilities, physics), the models and the protocols (JVM and Scala.js)
server The menu server: login, games and their lobbies, the election of the host of a game, the rendezvous
game-server The server of one game, run by one of its players
love-client The game's client, with LÖVE (see its README)
lua-linker The Scala.js IR → Lua linker the client is compiled with (see its README)

The game logic is the one of the former browser version: the game server runs the same game loop (the players' actions, then the server's: bullets hitting, gods spawning things, the mist...), and the clients apply the same actions to their own copy of the game state.

When a game is launched, its game server runs on the computer of one of its players, chosen by the menu server: their client downloads the game server's jar (and a Java runtime, if the menu server has one for their platform) and runs it. The players reach it in UDP, through their NATs, thanks to the menu server's rendezvous. See game-hosting.md for the details.

The menu server is minimal: everything is in memory (the games are forgotten when it stops), there are no passwords (anyone with the address can log in, with any pseudo that is not taken), and it speaks plain HTTP. It is meant to play on a local network, or with friends.

Run locally

You need sbt, Java 17 or later, and LÖVE 12 (in development: on Linux x64, sbt gets its AppImage for you, see the client's README).

  1. Build the game server's jar, which the menu server gives to the players (again after any change in shared or game-server):

    sbt game-server/assembly
    

    Optionally, sbt game-server/gameServerRuntimes makes the Java runtimes that the players run it with (one per platform, about 35 MB each, from Temurin's JDKs): without them, the host needs java 17 or later.

  2. Run the menu server (port 9000, TCP for HTTP and UDP for the rendezvous and the lobby). It listens on all the interfaces, so that the other computers of the network can join (-DisProd=false for this computer only):

    sbt server/reStart
    
  3. Run a client for each player, and type the address of the menu server on the login screen (127.0.0.1 on the same computer, otherwise its address on the network, e.g. 192.168.1.12):

    sbt love-client/luaRun
    

    A game needs players in two teams at least: run two clients to try it alone.

Then create a game, choose your ability and your team, get ready, and launch it.

Controls

By default: move with W, A, S, D; aim with the mouse; shoot with the left button (hold Shift too to shoot faster); your ability with the right button (or 1), your shield with E (or 2). They can be changed in the settings (in the games' list or in a game's lobby). Escape opens the game's menu, F11 toggles fullscreen.

Playing with friends

sbt love-client/luaPackage packages the client for Windows, macOS and Linux (in love-client/target/dist), with LÖVE inside, so that your friends do not need to install anything (see the client's README for what it needs). With PB_MENU_SERVER=<address> sbt love-client/luaPackage, the packages connect to that menu server without asking for it.

Run the menu server on a computer that the others can reach: on the same network, or forward the port 9000, in TCP and in UDP, of the router to that computer. The game servers need no port forwarding: the players reach them through UDP hole punching.

The datagrams of the games are authenticated, not encrypted, and the menu server speaks plain HTTP (the secrets of the games travel there): play with people you trust, on networks you trust.

Tests

sbt test

runs the tests of the protocols (on the JVM and on Scala.js), of the menu server and of the game server. Two scripts run the client itself, with LÖVE:

  • tools/love-udp-test.sh checks the client's UDP sockets, headless;
  • tools/love-client-test.sh plays a whole game, headless: it runs the menu server, and two clients that log in, create and join a game, get ready, launch it, run the game server (downloaded from the menu server), and fight until one of them wins. It needs sbt game-server/assembly love-client/luaLink first. --window plays the first player in a window, with the menus' UI.

About

Multi-player 2D battle arena

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages