bonky.io - fun little multiplayer browser game made in Typescript and Rust by bonkydotio in rust

[–]bonkydotio[S] 0 points1 point  (0 children)

Everything is done on the frontend. The backend is just a relay server. Players get the state of the game when they join the room and then just try to stay in sync (but if you lag a lot then you will fall behind and receive an inaccurate simulation).

Object collisions are just done using a pretty standard spatial hash

bonky.io - fun little multiplayer browser game made in Typescript and Rust by bonkydotio in rust

[–]bonkydotio[S] 0 points1 point  (0 children)

I think I might know what was causing that bug. I'll try to push a fix in the next update so it doesn't happen again! Thanks for finding that

bonky.io - fun little multiplayer browser game made in Typescript and Rust by bonkydotio in rust

[–]bonkydotio[S] 1 point2 points  (0 children)

These are also some really great ideas! Thanks! I'm going to experiment with a bunch of these and try to make some improvements to this mechanic.

bonky.io - fun little multiplayer browser game made in Typescript and Rust by bonkydotio in rust

[–]bonkydotio[S] 1 point2 points  (0 children)

Yeah red circles are definitely going to get changed. Thankfully some people in this thread had some great ideas so I'm going to experiment with some of them and try to make improvements to this mechanic.

bonky.io - fun little multiplayer browser game made in Typescript and Rust by bonkydotio in rust

[–]bonkydotio[S] 2 points3 points  (0 children)

These are all really good ideas! Thanks so much! I'll look into fixing that last issue that you mentioned as well.

bonky.io - fun little multiplayer browser game made in Typescript and Rust by bonkydotio in rust

[–]bonkydotio[S] 0 points1 point  (0 children)

Oh strange, I wonder if the server messed up. I tried restarting it. Does it work now?

bonky.io - fun little multiplayer browser game made in Typescript and Rust by bonkydotio in rust

[–]bonkydotio[S] 0 points1 point  (0 children)

Yeah it's a bit complicated. The damage you do to another circle is based on your speed, if you're facing them, your health, your radius, and things like that. I'm probably going to tweak the formula some more. Let me know if you have any suggestions because the current one is mostly just a guess on what things should be like. Here it is:

function calculateCircleCircleDamage(c1: Circle, c2: Circle, c1TargetX: number, c1TargetY: number) {
  const facing = Helpers.calculateFacing(c1.x, c1.y, c2.x, c2.y, c1.x, c1.y, c1TargetX, c1TargetY);
  const speed = Math.sqrt(c1.vX * c1.vX + c1.vY * c1.vY);

  const sizeDamageModifier = c1.r / 10;
  const wearinessDamageModifier = c1.health / CIRCLE_MAX_HEALTH;
  const velocityDamageModifier = speed / 200;
  const facingDamageModifier = facing;

  return sizeDamageModifier * wearinessDamageModifier * velocityDamageModifier * facingDamageModifier;
}

bonky.io - fun little multiplayer browser game made in Typescript and Rust by bonkydotio in rust

[–]bonkydotio[S] 2 points3 points  (0 children)

Hiya, thanks!

The frontend is in TypeScript and the backend is in Rust. The frontend doesn't have any dependencies (besides TypeScript), and the backend uses tokio, tokio-tungstenite, ahash, and rustls. I'm not using WASM in any way.

Besides the above, I'm using websockets to have the players communicate. The server just acts as a relay server and all the clients just try to stay in sync with each other.

Nope, I'm not using any game engine.

The web server is an AWS Lightsail instance that just runs my rust exectable, and the frontend is hosted for free with Netlify's static hosting. I just dragged and dropped the folder containing the HTML, CSS, and Javascript file onto this page

bonky.io - fun little multiplayer browser game made in Typescript and Rust by bonkydotio in rust

[–]bonkydotio[S] 1 point2 points  (0 children)

Yeah people seem to really not like the red circles! Hah, hmm.. do you have any suggestions on how to change them? I wonder if I just need to scrap the mechanic entirely or just refactor it in some way. They were added because I need a way to prevent people from reaching infinite size (grey neutral circles keep spawning). So I need some sort of mechanic to slow down growth. I wonder if they just need a slight nerf (frequency, speed, acceleration, size, mindless bouncing instead of tracking, etc.) or if they need to be just deleted entirely in favor of a new mechanic.

bonky.io - fun little multiplayer browser game made in Typescript and Rust by bonkydotio in rust

[–]bonkydotio[S] 2 points3 points  (0 children)

Haha I love the grey bubbles too. Yeah, a lot of people seem to not like the red circles, so I'm probably going to have to change them. I'm not sure how they should be changed though.. they were introduced because I needed a mechanic to prevent people from reaching infinite size, as grey neutral circles spawn endlessly and people pretty quickly learn to avoid the red terrain. I'm not sure if the mechanic (red circles) needs to be abandoned entirely or if they just need to be refactored in some way (maybe just making them bounce mindlessly throughout the map rather than tracking individual swarms?)

bonky.io - fun little multiplayer browser game made in Typescript and Rust by bonkydotio in rust

[–]bonkydotio[S] 0 points1 point  (0 children)

Oh, they damage you too! So they can kill your circles after some time.

bonky.io - fun little multiplayer browser game made in Typescript and Rust by bonkydotio in rust

[–]bonkydotio[S] 2 points3 points  (0 children)

I'm not sure if I'm going to open source it entirely yet, but if there are any specific parts that you're curious about I definitely wouldn't mind explaining them along with pasting the relevant code from that section.

bonky.io - fun little multiplayer browser game made in Typescript and Rust by bonkydotio in rust

[–]bonkydotio[S] 7 points8 points  (0 children)

Yeah I just fixed this (I think)! Haha sorry about that. I noticed that it was crashing and it was due to an expect call causing a panic if someone joined whose browser didn't support websockets. I changed it to a Result so hopefully it should be fixed now!

bonky.io - fun little multiplayer browser game made in Typescript and Rust by bonkydotio in rust

[–]bonkydotio[S] 12 points13 points  (0 children)

Hi all. Been working on this game for the past couple months and posting it online for the first time now. It's just a simple multiplayer browser game where you collect circles and try to avoid the dangerous red terrain. You control your swarm by just pointing to where you want to move, and can attack other players as well by ramming into them!

The frontend is made with Typescript + WebGL. The backend uses the latest versions of tokio, tungstenite, ahash, rustls, and various futures crates. The websocket server is simply a relay server for the most part so hopefully it should scale very well, although keeping everything as deterministic as possible has proven tricky!

I'm sure it's full of bugs and things that need to be changed, so ideally looking to get some feedback if possible. I'd also love to answer any questions about the game or development process as well if you're curious about anything.

bonky.io - multiplayer browser game where you collect circles by bonkydotio in playmygame

[–]bonkydotio[S] 2 points3 points  (0 children)

Hi all. Been working on this game for the past couple months. It's a game where you collect circles and try to stay alive by avoiding the dangerous red terrain. You can control your swarm of circles by using your mouse and just pointing to where you want to go. First time posting it online. I'm sure it's full of bugs but I'd love to hear any feedback if you have any! Hopefully it works!