TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: I made a browser-based RTS game

212 pointsby Glutenabout 3 years ago
I&#x27;ve posted this game here before, hopefully a repost is fine as the game has changed quite a bit (improved AI, improved mapeditor, much quicker gameplay, etc).<p>Game is based on JavaScript&#x2F;Canvas and WebSockets. On the browser side the map is pre-rendered (as a background image), just the mobile units&#x2F;buildings and animations are dynamically rendered. The lobby server is made in node.js, but the game server is C++ for performance reasons (mainly the pathfinding). I found the C++ WebSocket libraries out there to be too difficult to use so I made my own based on the rfc. Overall I think making a game like this is quite easy with the browser performance&#x2F;features nowadays. The game server and client side JavaScript are around 5000 lines of code each.<p>If you have any questions about the tech I&#x27;m happy to answer them.

20 comments

smegma2about 3 years ago
Hi Gluten, I never wrote a real-time game, so I&#x27;m curious about a lot of things.<p>* Does the server have a tick rate and it updates clients at a set interval, or does it only update when things happen?<p>* Did you ever run into any issues getting enough throughput from the server? e.g. maybe too many events happening at once to update everyone?<p>* Do you have to manage situations where two clients have a different view of the game state (due to extra latency for example)? If so, how do you resolve it? For example, I know that Team Fortress 2 follows the rule for guns that &quot;if the shooter thinks it hit, then it hit&quot;, which means that people get shot around corners sometimes.<p>I&#x27;m working on a turn-based game using websockets which has been hard enough, a real-time game seems much harder to make! Thanks for sharing!
评论 #31299768 未加载
评论 #31302989 未加载
closedloop129about 3 years ago
Is it possible to play the game without having to register an account?
评论 #31298197 未加载
评论 #31298674 未加载
hejpadigabout 3 years ago
Cool, the graphics are very reminiscent of Tibia, an old school MMO that I loved as a kid.
评论 #31297405 未加载
iWillOffshoreUabout 3 years ago
Nice, big fan of browser based multiplayer stuff. I think there&#x27;s so much potential now to make some crazy browser based games given current state of web apps.<p>Edit: How long did it take you to create?
评论 #31298938 未加载
评论 #31296831 未加载
评论 #31297053 未加载
mLubyabout 3 years ago
I&#x27;m curious if it&#x27;s reasonable to push more processing to the browsers to save on server costs.<p>I know multiplayer games generally need a server to &quot;referee&quot; (and to matchmake) but I wonder if games ever offload most of that work so the client does the heavy lifting (e.g. find a path from A to B) and then submits its work for the server to validate (e.g. this path from A to B works) and broadcast rather than the server doing <i>all</i> the game simulation work. My understanding is that multiplayer game clients generally just do graphics&#x2F;sound and user interaction processing.<p>(yeah yeah distributed consensus don&#x27;t say the B word)
评论 #31301497 未加载
评论 #31299816 未加载
评论 #31299624 未加载
评论 #31300451 未加载
bytehowlabout 3 years ago
I would recommend allowing people to just pick a name and hop in. One of the keys to the success of web games is that there&#x27;s (often) literally no barrier to entry, including the need to create an account.
评论 #31298576 未加载
评论 #31297102 未加载
评论 #31297278 未加载
评论 #31297216 未加载
评论 #31301070 未加载
评论 #31297147 未加载
caretak3rabout 3 years ago
Yeah the AI is pretty tough, pretty much only spams workers and warriors. Only issue for me is being able to accurately click on my base and&#x2F;or individual chars. But otherwise pretty fun!
评论 #31297839 未加载
holografixabout 3 years ago
This is so cool! Is there a dev blog?! I’m particularly interested in the netcode and things like path finding and object collision detection at scale.
visoxabout 3 years ago
remind me of my old old abandoned side project where i tried to create a diablo clone in browser with scala.js<p>does not work in most browsers, think in safari it works :D<p><a href="http:&#x2F;&#x2F;diablo-forever.com&#x2F;" rel="nofollow">http:&#x2F;&#x2F;diablo-forever.com&#x2F;</a>
评论 #31299432 未加载
DistrictFun7572about 3 years ago
That looks great.<p>* By JavaScript&#x2F;Canvas I suppose you are talking about WebGL?<p>* Is the source code available for public viewing?<p>* Did you use any of the popular frameworks like ThreeJS?<p>* Do you use differently sized textures depending on whether the user is on a mobile phone or desktop?
评论 #31296838 未加载
Sujetoabout 3 years ago
Had some fun with the ai. That flag has a lot of hp and was tough<p><a href="https:&#x2F;&#x2F;i.imgur.com&#x2F;5AcAD66.jpg" rel="nofollow">https:&#x2F;&#x2F;i.imgur.com&#x2F;5AcAD66.jpg</a>
mikenewabout 3 years ago
This is awesome, but I do have a nitpick. Using left click to select as well as move feels <i>really</i> unnatural to somebody coming from other RTS games. I probably have over 5k hours in StarCraft 2 and WC3, and that&#x27;s a lot of muscle memory to contend with.
评论 #31298214 未加载
评论 #31297517 未加载
评论 #31298559 未加载
评论 #31297551 未加载
hombre_fatalabout 3 years ago
Always impressed by people like you who can do the impossible work of getting a game to the point of launching something.
crickcreekabout 3 years ago
I love rts but i just have an old-ass android phone! look for me, 551154305985 TIM
smegsicleabout 3 years ago
this obviously isn&#x27;t as simple of a game as tagpro or agar.io, but i think one factor for their success was being able to pop in without making an account.. i guess they call that &quot;.io&quot; style browser games?
dandigangiabout 3 years ago
This is pretty cool. I love a good RTS. Nice job.
strongbondabout 3 years ago
Please make the tutorial more prominent.
kwhitefootabout 3 years ago
Why can nicknames not contain spaces?
评论 #31297298 未加载
alisweabout 3 years ago
Looking real good!
tttyabout 3 years ago
Related to multiplayer rts games this is also done with same tech but node.js only to reuse code between client and server side <a href="https:&#x2F;&#x2F;bitplanets.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;bitplanets.com&#x2F;</a><p>I wonder what performance issues you had with node.js that justified a bridge to c++ (including the increase of complexity of the architecture). Pathfinder is not terrible in node.