[HN Gopher] Show HN: An online 2D MMO game, written in Rust and ...
___________________________________________________________________
Show HN: An online 2D MMO game, written in Rust and JavaScript
I made a game (https://polyfight.io/) which revolves around a
player (a tank) leveling up and upgrading by killing shapes and
other tanks (partially inspired by https://diep.io). It has a bunch
of features, a vast number of tanks, an inbuilt chatting system,
clans to make teams with your friends, a colour scheme maker,
controllable sandboxes which can be public or private, a last man
standing gamemode, and an inbuilt 1v1 system with its own ELO
rankings and a global leaderboard. The game has a few players right
now, and I'd hope to spread the joy players have with this game to
people here, as well as any critiques people have about the game.
Exploits/gray hat hacking is warmly welcomed, as I strive to make
sure my game is secure and hard to script/bot in.
Author : altanis
Score : 155 points
Date : 2024-08-15 02:48 UTC (20 hours ago)
(HTM) web link (polyfight.io)
(TXT) w3m dump (polyfight.io)
| nightpool wrote:
| Seems like I got killed by a glitch that teleported me off screen
| and then marked me as "killed by Unknown"
| cthalupa wrote:
| Something similar for me as well. Played for about 10 minutes
| and had it happen a few times - I'd be in a fight or killing
| some shapes, then it would rocket me across the screen and say
| someone killed me. The "kill cam" would have the person who
| killed me somewhere quite far a way, and I never saw any
| bullets coming from that direction.
| david_shi wrote:
| Same. I was having a lot of fun playing it otherwise!
| altanis wrote:
| Hey sorry, overnight there was performance degradation which
| made the server run very slow (~100MSPT). I restarted the
| server for a temporary fix and will fix it sometime today.
| pdsouza wrote:
| fun!
| nhggfu wrote:
| add a X button to close that huge black info box took me a while
| to realize i had to press ESC
| altanis wrote:
| There should be an X button. It's probably a CSS issue; what
| are the dimensions of your screen?
| nhggfu wrote:
| let's just say it's HUGE.
| cshimmin wrote:
| Very cool, reminiscent of agar.io :)
| brigadier132 wrote:
| It's a really cool technical achievement but if I were you I'd
| put in a lot of effort to distinguish yourself from diep.io
| because at first glance they are identical.
| altanis wrote:
| Of course, I have a bunch of new features in mind to make it
| different from Diep.io when initially playing.
| halware wrote:
| Nothing happens. I click play, it says already connected. I wait,
| nothing happens. I join a lobby, it puts me in the same scenario.
| altanis wrote:
| I think a clientside fingerprint implementation I made was
| faulty, I'll rework it. Sorry.
| echelon wrote:
| Can you tell us about your implementation?
|
| What Rust libraries did you use, what are you using for state
| management, etc.?
| altanis wrote:
| I used Axum for the websocket server, MySQL for the database,
| and the glicko2 crate for elo management. Those are the only 3
| that come to mind, I didn't use any libraries/engines for the
| game itself.
| torgoguys wrote:
| >...the glicko2 crate for elo management
|
| That's kind of funny. When this project said it had elo
| rankings, I had the thought, "it's a shame they're using elo
| when there are better options." It seems like you are already
| using one of those better options!
|
| Other than where elo is used for historical reasons, about
| the only other reason I can think to use it in a new project
| is as a placeholder until you do something better. It's great
| as a placeholder since it is so easy to implement.
| jaaron wrote:
| Looks impressive. Like some others, I'm getting the bug that says
| "You are already connected" when I try to play.
|
| That said, this is still good work, especially considering your
| experience and age (I checked out your 2D physics library on
| github and I found the trailer on youtube).
|
| One suggestion: As someone in the game industry, I personally
| wouldn't label it an MMO as it doesn't include many of the
| features, particularly the "massive" part of MMO, that is usually
| associated with that term. The work is already impressive enough,
| you don't need to give it a label that could open it to
| criticism.
|
| Otherwise, this is solid work. If you're aiming for a career in
| the game industry eventually, it's a good foundation to build on.
| altanis wrote:
| Hey, thanks! You're right, I should've probably labeled it as a
| multi-player game, not an MMO. The connection issue you faced
| was because of a (probably) faulty clientside fingerprint
| implementation I made; your fingerprint probably collided with
| others. I'll rework it in a few hours.
| 10000truths wrote:
| I suggest you use the WebTransport datagram API for your netcode,
| now that it's supported by the latest version of all major
| browsers (except Safari). WebSockets suffer from the typical
| head-of-line blocking issues inherent to TCP, which makes it a
| suboptimal fit for latency sensitive applications like
| multiplayer games, where you only care about the most recent
| state.
| modeless wrote:
| I wouldn't suggest WebTransport unless/until Safari gets
| support. Instead you can use WebRTC DataChannel today for UDP
| in all browsers. Also, WebTransport doesn't support direct P2P
| connections but WebRTC does.
|
| I have ported Quake III to use DataChannel and it works great
| (once all the WebRTC boilerplate is in place). You can test it
| here: https://thelongestyard.link/ Once you click the
| multiplayer link you will get a URL with your server name,
| which others can visit to join your server instantly.
| iAmAPencilYo wrote:
| That is absolutely fantastic. Instant mayhem! Thank you for
| this.
| kaliqt wrote:
| Isn't WebTransport supposed to get P2P via QUIC?
| modeless wrote:
| I think there is an intention to add P2P to WebTransport
| someday. But I wouldn't hold my breath.
| tillcarlos wrote:
| Most underrated comment, and what a blast from the past.
|
| Back then Quake 3 would require 3d accelerators and now we
| can play it in the browser... and some person on HN just
| casually "ported it". Awesome!
|
| What's the technology there? Do you run it on WASM?
| modeless wrote:
| Thanks! Yes, it's ioquake3 compiled to wasm with
| Emscripten, and definitely still uses 3D accelerators via
| WebGL. Quake III is GPL of course and the code is here:
| https://github.com/jdarpinian/ioq3
|
| In addition to WebRTC multiplayer and a bunch of random
| improvements I added web gamepad API support as well as
| touch controls. Yeah, touch controls, because half of
| everyone is browsing on their phone and I don't think you
| can really call it a proper web port if it doesn't work on
| phones. Touch controls for Quake III were a challenge but I
| think I have something that's fun to use. I'm interested to
| hear if it works for people.
|
| I'm also experimenting with a port of Cave Story (the
| classic 2D indie platformer) with touch controls for
| mobile: https://thelongestyard.link/cave-story/
| altanis wrote:
| WebRTC is complicated; there are many more edge cases
| compared to websockets. Off the top of my head, I know I'd
| need to run a TURN server for people behind symmetrical NAT
| or CGNAT networks, which would be a pain. WebSockets are much
| more accessible for everyone. In the future I'll investigate
| UDP protocols, but its likely I'll always use TCP for web
| games.
| modeless wrote:
| Yes, WebRTC is complicated. But you only need a TURN server
| for the P2P case. If you are using it in a client-server
| mode like WebSockets then there is no need for a TURN
| server, and connection establishment should be
| significantly simpler. And if you don't need the
| audio/video stuff then you can ignore that complexity as
| well. (Although voice chat or even video could be a very
| cool and differentiating feature for a multiplayer game.)
| Kiro wrote:
| I thought MMORPGs preferred TCP.
| Chabsff wrote:
| You typically want a mix of UDP and TCP (or sometimes a weird
| TCP-like monstrosity rebuilt on top of UDP).
|
| Taking great care to design your data streams to be self-
| correcting (e.g. transfer a world location where characters
| are going _towards_ instead of which _direction_ they are
| heading) can go a long way towards saving a ton of synching
| headaches, and enables very efficient networking.
|
| One-off events go over the TCP-like channel, but constant
| streaming data that naturally self-correct over time, like
| the example above, can benefit from being on the UDP channel.
| aatd86 wrote:
| If some packet loss is not problematic, UDP is used. Often
| for players positions.
|
| That's also how some speed hacks are made possible.
| diath wrote:
| Have you shipped a multiplayer game yourself?
| altanis wrote:
| I like the idea of UDP, but protocols like WebTransport aren't
| 100% supported and are still relatively new compared to
| websockets. But you're right, using UDP would be a less latent
| approach and clientside prediction can account for any lost
| packets.
| saretup wrote:
| Partially inspired? That's literally a diep.io clone. Not that
| that's necessarily bad, sometimes it's easier to clone an
| existing game you like when learning a new game engine/language.
| But you should own it.
| altanis wrote:
| The base game is inspired from Diep.io with extensive features
| already to differentiate it, but you're right the base game is
| still essentially Diep.io. The game is still relatively new and
| I haven't implemented all my ideas yet, but when I'm done the
| base game mechanics will be completely different.
| knowitnone wrote:
| buggy as hell. die for no reason
| altanis wrote:
| Sorry, the game server degraded overnight. I've restarted the
| server as a temporary fix and will investigate today.
| cuu508 wrote:
| Why does it ask to select a Google account?
| altanis wrote:
| There are some features in-game which I don't want abused by
| bots (creating sandboxes for instance). There's also a 1v1
| system which needs a Google account to associate your rankings
| with. Other than those two sections, you are able to play FFAs
| and join other people's sandboxes without a Google account.
| qingdao99 wrote:
| I think you should implement client-side prediction, it feels
| very laggy.
|
| https://developer.valvesoftware.com/wiki/Prediction
| altanis wrote:
| There already is. The lag you were experiencing was likely from
| the game server degrading; did you check what the MSPT of the
| server was when you were playing? (It was listed at the bottom
| near your ping.)
| feverzsj wrote:
| How can I play the game, if I just get killed within seconds?
| Etherlord87 wrote:
| Seconded. The death report says I died after 2 seconds, but I
| actually have no chance at all to do anything, to control my
| tank, to even discover if the WSAD control works.
|
| Also on Firefox the FPS meter says 40 FPS, but visually the
| game (the interface rather, I was unable to play) is clearly
| not smooth, clearly below stable 24 FPS.
| altanis wrote:
| Hey sorry, there was performance degradation overnight which
| made the game server super slow. It should be better right now.
| throwaway_4638 wrote:
| Can't play. No player icon, random movement, death within
| seconds.
| altanis wrote:
| Hey sorry, there was performance degradation overnight which
| made the game server super slow. It should be better right now.
| tetris11 wrote:
| I'm unable to test this - I spawn, teleport, and then die.
|
| I'm currently enjoying more relaxed MMO settings using threeJS
| libraries with multiplayer built in:
|
| https://summer-afternoon.vlucendo.com/
| cnity wrote:
| This was great! Me and another player were just exploring this,
| and I had fun finding all of the secrets. Well done :)
| tetris11 wrote:
| It's one of the most beautiful WebGL games I've seen in a
| while.
| altanis wrote:
| Hey sorry, there was performance degradation overnight which
| made the game server super slow. It should be better right now.
| torgoguys wrote:
| ...and which libraries are those?
| nkrisc wrote:
| Looks fun, but not an MMO in any common use of the term I've ever
| seen. In modern gaming especially a lobby system is antithetical
| to the concept of an MMO.
| altanis wrote:
| Yeah, I should've labeled it as a multi-player game instead.
| dsfasfd wrote:
| I have no idea how to play. I spawn, don't see myself, the
| background is moving (off the edge of the map?) and I die
| altanis wrote:
| Hey sorry, there was performance degradation overnight which
| made the game server super slow. It should be better right now.
| PUSH_AX wrote:
| I spawn in, there is nothing on screen (no tank or player
| entity), 2 seconds later it says I died by someone
| altanis wrote:
| Hey sorry, there was performance degradation overnight which
| made the game server super slow. It should be better right now.
| tiborsaas wrote:
| It's unplayable at the moment. I can't control my shape and I'm
| instantly killed in a few seconds. M1, Chrome latest.
| GrumpyNl wrote:
| Same here.
| altanis wrote:
| Hey, sorry about that; there was some performance degradation
| overnight which caused the game server to run very slowly. I
| restarted the server to temporarily fix it, I'll look into it
| today.
| supermatt wrote:
| No doubt it was great when you announced it 7 hours ago, but its
| already fallen to abuse :(
| altanis wrote:
| I don't think it's abuse, but just server degradation from 50
| players playing for hours. I restarted the server and it's
| better, I'll fix the degradation later today.
| joeyagreco wrote:
| Reading these comments it seems you're suffering from success
| altanis wrote:
| Yeah, I didn't actually expect this many people to play. I've
| ran benches locally of 100 bots playing together, and the game
| server ran at a decent 5-7 MSPT. I didn't run the benchmark for
| hours though, so I never got performance degradation. I'll run
| the bench for a few hours today and inspect why performance
| degrades.
| 93po wrote:
| Looks like there's a couple bots already sort of ruining it. Oh
| well
| sirjaz wrote:
| Any plans for offline access
| altanis wrote:
| Not at the moment, no. I'll add a tank editor in the future
| which could technically be ported offline, but I don't have too
| big of a desire to port it to a native app.
| altanis wrote:
| If you guys want, there's a Discord server you can join for the
| game since communication through a forum is hard:
| https://discord.gg/UTvaAAgku3 .
| butlike wrote:
| This is really fun! I like the gameplay loop of grinding the
| shapes for exp and avoiding the higher-level players. Some things
| I'd like to see:
|
| - Dying and losing exp (and levels) feels overly brutal. Losing
| ~10 levels a death makes me dejected to re-grind.
|
| - The level scaling might be better logarithmic so the initial
| levels make it super clear as to the benefit the upgrade has.
|
| - Up to level 5 there should be a "noob flag" where you can't
| damage or be damaged by other players. This can be toggled off
| and is only on until the first time you reach level 6.
| altanis wrote:
| Hey, thanks for the suggestions! By the way, you can hold K to
| level up to max, this is temporary though.
|
| Levels are determined by halving your XP then finding the
| correct level, just like Diep.io. I agree with you though; I'll
| probably make it less harsh.
|
| Level scaling is already exponential (its harder to get levels
| as you progress).
|
| I actually really like the noob flag idea; when spectating, a
| bunch of people were confused on what to do and kept dying to a
| higher level person. I will definitely add this feature in the
| following week.
| jncfhnb wrote:
| I think it it feels a little clumsy. Movement is very floaty and
| since everyone moves the same there's not a lot of opportunity to
| do anything if a chase begins. You ultimately will get caught.
| Some sort of boosting would help a lot here.
| altanis wrote:
| You ultimately will need to try to kill the player who is
| chasing you. Choose one tank you think will kill them, and keep
| trying until they die. That's basically the point of the game;
| choose tanks adapted to your environment and get as many points
| as you can.
| jncfhnb wrote:
| Imo the game is clearly not intended to be about forced
| 1:1's. The majority of the tanks seem to be optimized for
| just free for alls.
|
| For one on ones you'd be pretty dumb not to prioritize front
| facing guns
| MrFoof wrote:
| Simple and fun.
|
| In my very first game I got to Rank 6 with 24K points. However,
| there's some cases where the client and server get out of sync
| _(despite only supposed 10-20ms latency)_ where the server
| eventually syncs you with some wild rubber banding. I died
| because during this rubber banding where I was shoved across the
| map, I likely was picked off by the leader with 118K points.
|
| Take care of the latency issues and you have the core of
| something. Something similar-but-different is "Realm of the Mad
| God" which originally was a Ludum Dare entry using the Oryx
| spritesheet. So add in some interesting NPCs, and deal with the
| latency issues and you have the core of something that actually
| is monetizable.
| altanis wrote:
| Yeah that "desync" is because the server mspt (shown next to
| your latency) was likely very high. It's because of a memory
| leak, I'll investigate when I get a chance.
|
| I'll look into that game, I've never heard of it. Not sure how
| I'd incorporate NPCs in a fast paced game like this, if you
| have any ideas let me know!
| MrFoof wrote:
| mspt was consistently ~20msec. It's why the rubber banding
| surprised me: everything was great until it wasn't.
|
| Realm of the Mad God will make your game seem "comfy speed"
| by comparison. You've not yet seen fast. ;)
| aylmao wrote:
| Very cool! I've played diep.io plenty, so no comments on the
| gameplay haha, I'm familiar with the decisions made here, both
| the cool ones and the frustrating ones.
|
| I did encounter a bug where out of nowhere I was jolted onto the
| bounds of the map (specifically the lower-left corner) and died,
| killed by "Unknown".
|
| I think thse bugs in this kind of game are especially scary
| because you lose everything when you die, which makes you a
| little weary of starting again. You might get far just to
| randomly die for no reason. If those are ironed out, I think
| you've got yourself a pretty good .io game to build upon and keep
| evolving here!
| altanis wrote:
| Yeah, that bug is from a memory leak, I haven't had a chance to
| debug it since I'm traveling but I'll figure out the cause by
| this week.
| lowbloodsugar wrote:
| Yeah, the offscreen insta-kill-lose-all-progress is drop-
| controller-walk-away-forever for me thanks. No projectiles on
| screen, no enemy onscreen, just dead.
| sytzez wrote:
| Nice! I've also made a little multiplayer game using Rust and
| Javascript. I used warp for the server, which communicates to a
| vanilla js frontend through websockets. You can play it on
| rpsbrawl.com. I've added some bots too as I never expected many
| players.
| littlekey wrote:
| Just had a lot of fun playing for an hour or so, even got to #1
| for a while. Thanks for building this :).
___________________________________________________________________
(page generated 2024-08-15 23:01 UTC)