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: Yare.io – game where you control units with JavaScript

233 pointsby levmiserialmost 4 years ago

31 comments

SamBamalmost 4 years ago
I find the run loop to be fairly confusing. In step 2 of the tutorial we have<p><pre><code> s1.move(star_zxq.position); s1.energize(s1); if (s1.energy == s1.energy_capacity) { s1.move(base.position) s1.energize(base); } </code></pre> What&#x27;s confusing is that it seems like my sprite should execute all four of these actions. So it&#x27;s surprising to see that it only does one of these things at a time.<p>There seem to be at least a couple hidden assumptions:<p>1. If multiple `move` commands are issued in one loop it will only do the last. Ditto(?) for all other commands<p>2. A sprite can only be doing on thing at a time. If you order it to do something that it can&#x27;t do it will simply ignore it. So the `energize` command is simply ignored when it can&#x27;t energize, and when it can, the `move` command is ignored<p>While this does help keep the game syntax much more tidy, it&#x27;s fairly confusing since it doesn&#x27;t seem to match how a script would normally be read.
评论 #27368280 未加载
评论 #27368928 未加载
0XAFFEalmost 4 years ago
That&#x27;s nice.<p>A sandbox mode would be nice, where there&#x27;s just an indestructible enemy base, where you can test and debug your code without the pressure of being attacked.<p>Also in the tutorial the use of for-of would be better in my opinion, as it is better understandable and has less clutter.
silvester23almost 4 years ago
Very nice so far.<p>I noticed a small problem in the tutorial. On step 3 or 4, when the suggested code is<p>if (s1.energy == s1.energy_capacity){<p>memory[s1.id] = &quot;charging&quot;;<p>} else if (s1.energy == 0){<p>memory[s1.id] = &quot;harvesting&quot;;<p>}<p>if (memory[s1.id] == &quot;charging&quot;){<p>s1.move(base.position);<p>s1.energize(base);<p>} else if (memory[s1.id] == &quot;harvesting&quot;){<p>s1.move(star_zxq.position);<p>s1.energize(s1);<p>}<p>My spirit had already transferred a bit of energy to the base, so it entered neither of the states. It was a pretty easy fix to make, but strictly following along the instructions, I would have been stuck there.
评论 #27366722 未加载
评论 #27368115 未加载
remramalmost 4 years ago
I like the concept, but there seems to be a lot of problems for a &quot;beta&quot;:<p><pre><code> - The documentation doesn&#x27;t mention what merging and dividing is for. This is not covered in the tutorial and I don&#x27;t know what kind of advantage this gives. Additionally the details for &quot;divide()&quot; are a copy of the details for &quot;move()&quot; (bad copy&#x2F;paste) - The documentation doesn&#x27;t mention anything about ranges (how far can I be from base or star to transfer energy?) - The documentation doesn&#x27;t mention anything about rates (how fast is energy harvested&#x2F;transferred?) - There are dead links e.g. https:&#x2F;&#x2F;yare.io&#x2F;j2m.cz&#x2F;~jm&#x2F;, consider using a link checker - The game is very slow! Debugging a program takes a very long time. It&#x27;s not slow enough that I can reasonably make any adjustment during gameplay though - The console is undocumented and behaves differently from the browser one (e.g. it only prints its first argument) - The other shapes are undocumented (triangles seem to not have the ability to merge, what is the flip side?) - &quot;my_spirits&quot; keep references to dead spirits which is VERY confusing. The tutorial introduces code that specifically seems designed for the opposite behavior - There are bugs in the match-making, where sometimes it will join a just-finished game from other people (so I see a score screen for people I don&#x27;t know and I have to start match-making again) - A way to show information on the canvas would be very helpful. Simply adding a field &quot;caption&quot; to spirits, that would be shown next to it on the canvas, would already go a long way - &quot;Game cancelled&quot; errors - It seems that while my script is already loaded at the start of the game, it won&#x27;t start executing until I click &quot;update script&quot;, causing a variable delay between players. The bots also don&#x27;t have this issue. - There is a 1 in 4 chance that both players will pick the same color, which leads to a very confusing match. Consider removing the manual selection and always making one red one blue</code></pre>
评论 #27370804 未加载
jiangplusalmost 4 years ago
I have always been trying to make an Elixir version of a screeps-like game. Every unit is just an actor, sending messages to other units, based on the GenServer behavior. You can upload a new version of the unit controller with Beam hot code reload.
joshstrangealmost 4 years ago
It would be really nice if there was some indication of errors in your script. I typo&#x27;d some of the tutorial code and it took me a minute to see what was going wrong (no errors in the console?). Also auto-complete on game functions is really needed. It will apparently auto-complete regular&#x2F;core JS stuff but not game-specific methods. It looks like the starfield is limited to original browser size and resizing the browser window will not resize the starfield (which sucks if you load up the page with a small window, lots of panning around to see stuff).
Kiroalmost 4 years ago
Is the JS run on the server or is it compiled to instructions or something? If the former, how do you prevent people from running malicious code?
评论 #27367560 未加载
warpechalmost 4 years ago
Slightly reminded me of Elevator Saga[0], a much simpler game in which you use JS to move people with elevators<p>[0] <a href="https:&#x2F;&#x2F;play.elevatorsaga.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;play.elevatorsaga.com&#x2F;</a>
awbalmost 4 years ago
Awesome work! Glad to see more programming &#x2F; hacking games out there.<p>For others interested in the genre, my old school JS hacking favorite is: <a href="https:&#x2F;&#x2F;alexnisnevich.github.io&#x2F;untrusted&#x2F;" rel="nofollow">https:&#x2F;&#x2F;alexnisnevich.github.io&#x2F;untrusted&#x2F;</a><p>And for those interested in Go, I made: <a href="https:&#x2F;&#x2F;andybrewer.github.io&#x2F;operation-go&#x2F;" rel="nofollow">https:&#x2F;&#x2F;andybrewer.github.io&#x2F;operation-go&#x2F;</a>
评论 #27373261 未加载
nielsbotalmost 4 years ago
Reminds of Omega--you wrote scripts to operate autonomous tanks, and pitted your tanks against others&#x27; in an obstacle-filled arena. Omega didn&#x27;t have the realtime scripting component though.<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Omega_(video_game)" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Omega_(video_game)</a> reply
NiceWayToDoITalmost 4 years ago
Is there a short video demo ?<p>EDIT: Sorry, I was lazy, just saw walk through tutorial, nice game, but it would be nice to have 1 min trailer.
评论 #27368258 未加载
vort3almost 4 years ago
Wish there was a Python game like that.
评论 #27367783 未加载
kpwagneralmost 4 years ago
Cool! I&#x27;ll play with it more... when I&#x27;m not at work.<p>Suggestion: more keyboard shortcuts: find&#x2F;replace, delete line to name a few. Eventually you could allow customization and&#x2F;or selecting different pre-configs (e.g. Vim, VS Code).
clarlealmost 4 years ago
Great idea, and very cool game. Probably going to mess around with it later, but a few early observations after going through the tutorial and reading the docs:<p>* It&#x27;s perfect information (even the locations of the bases and stars are fully known ahead of time). So there&#x27;s no need to create scouts like you would in other RTS&#x27; AIs.<p>* There&#x27;s definitely some merge &#x2F; divide tactic for attacking that can be exploited. If a merged spirit gets divided, is its remaining energy split between all of the original spirits?<p>* Jump seems incredibly powerful for both resource gathering and ambush hit-and-run attacks given that its cost is always constant.
评论 #27369074 未加载
swyxalmost 4 years ago
this is curiously similar to <a href="https:&#x2F;&#x2F;halite.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;halite.io&#x2F;</a> by Two Sigma
scghostalmost 4 years ago
This looks awesome! A buddy and I made a very similar turn based &#x27;game&#x27; a while back, but never added accounts etc for public matches: <a href="https:&#x2F;&#x2F;ikottman.com&#x2F;apps&#x2F;slime-mind&#x2F;" rel="nofollow">https:&#x2F;&#x2F;ikottman.com&#x2F;apps&#x2F;slime-mind&#x2F;</a><p>Yours looks much more polished, I&#x27;ll give it a try!
einpoklumalmost 4 years ago
Even the API we see in the tutorial is, well, problematic:<p>s1.energize(s2) has the s1 entity transfer energy to the s2 entity ... except that if s2 == s1 (or s2 === s1), s1 tries to harvest energy from somewhere.<p>... that would not pass my code review.
thybagalmost 4 years ago
Is there a way to console log &#x2F; inspect the state of your entities?
评论 #27366935 未加载
Osmiumalmost 4 years ago
Seems like there&#x27;s a lot of potential in code-based games, not just for learning but for a creative outlet. Wish the contrast was a bit higher on this one though!
eventreduce1almost 4 years ago
You need to visually show when the entered code is loading. So often I click &quot;run code&quot; and then nothing happens I it feels like the code is broken.
评论 #27368290 未加载
johnmorrisonalmost 4 years ago
Insanely cool! Ran through the tutorial. Excited to give it a shot for real soon &amp; see the project&#x27;s progress over time.
评论 #27375051 未加载
forgotmypw17almost 4 years ago
Cool game, very original and engaging from the start. I appreciate how clean the tutorial is.<p>Do you have any plans for allowing mouse-less control?
评论 #27367540 未加载
badambadamalmost 4 years ago
Just wanted to say that I absolutely love the UX of the account creation. Wish more website did something so simple like that.
krageonalmost 4 years ago
It looks nice and I like the core gameplay loop, but after uploading a few snippets of code the spirits are constantly moving backwards and forwards (even in the tutorial after just uploading some code that I literally copied off there).<p>I was very excited about coding in a state machine, but if I have to figure out if I&#x27;m bugged or the game is that&#x27;s not a great time for me :)
评论 #27367102 未加载
ciesalmost 4 years ago
This is cool! First time a programming game makes sense to me from a UX perspective.
评论 #27366731 未加载
bgirardalmost 4 years ago
Does anyone know a good programming game that is PvE rather than PvP?
评论 #27372473 未加载
SomaticPiratealmost 4 years ago
Are there other games like this? This looks quite fun!
评论 #27377519 未加载
Buttons840almost 4 years ago
How do computing resource limits work?
评论 #27367096 未加载
numlock86almost 4 years ago
Cool. How can I spectate?
评论 #27366730 未加载
评论 #27366910 未加载
shuringaialmost 4 years ago
so... it&#x27;s a screeps copy?
评论 #27367337 未加载
评论 #27366651 未加载
yhoneycombalmost 4 years ago
Never been a fan of these &quot;programming&quot; games. If I wanted to program, I would just program.
评论 #27370046 未加载
评论 #27367113 未加载