Online game in space

An online 2D space battler that I have been making for the last couple of weeks, transferring it from old developments and testing the possibility of implementing the network part in default, as well as those things that I have not written here yet. Game
Peculiarities:

  • a completely authoritarian server that does all the calculations (the server is now also on Defold)
  • real online (of course there are bots when there are few players)
  • box2d collision physics
  • seamless “endless” world
  • leaderboard
  • radar for convenience and beauty
  • ships, asteroids, bonuses
  • and many other small things…

PC control: (everything is obvious from the phone)

  • right button (hold) - flight acceleration
  • left - shots
    The metrics at the top are frame rate, number of incoming data per second and ping from the server.



    Some technical details:
    The server is located in Poland, written in Bun.
    Interpolation is fixed - 150ms, if the ping is higher than this number, then the game will be uncomfortable (dynamic adjustment is disabled).

UPD:
now the server is written in Defold.

19 Likes

This is cool!

How does the Bun server communicate with Defold?

Steering and shooting doesn’t work at the same time on a mac mouse (because it’s one button). Keyboard controls would be nice.

1 Like

using web sockets. Binary data.

2 Likes

Today I spent the whole day rewriting the network layer and running physics.
Now both the client and server work on Defold.

Never heard of Bun before. Is it this: https://bun.sh/

“Bun is a JavaScript runtime, package manager, test runner and bundler built from scratch using the Zig programming language. It was designed by Jarred Sumner as a drop-in replacement for Node.js. Bun uses WebKit’s JavaScriptCore as the JavaScript engine, unlike Node.js and Deno, which both use V8.”

Yes, I wrote the server on it.
Since I write all the code in Defold in TypeScript (https://ts-defold.dev/), and the Bun environment supports this language by default, it is quite convenient for me to write a server and compare the work of these 2 options.
And I want to share my conclusions, but they are not clear-cut.
First of all it works :slight_smile:

Pros of Defold:

  • small amount of RAM memory consumption (about 8 times compared to bun)
  • one code base when writing
  • you can flexibly adjust the frequency of operation so that the server does not load the system and select the desired tickrate, but this is also the main problem.

Minuses:

  • requires a build (not the worst thing)
  • after all, in all tests (real-time game), the load is sometimes a little higher (~3-10%), but my test is not the most reliable in the sense that it strongly depends on the game and the implementation of the network part (binary data, serialization in C ++, we spend time on calls). On the contrary, Defold won some tests, for example, only physics simulation with a large number of objects compared to the same test in bun.
  • Defold works at maximum in headless mode and squeezes 100% of the processor time out of the system, this can be partially solved, but it causes other problems, which I wrote about here: Headless build consumes 100% cpu · Issue #8029 · defold/defold · GitHub
3 Likes

This is awesome! I had not taken bun for a spin yet, but you know me, i’m all about web and defold interopeerability!

1 Like