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.

Writing space invaders with Go

179 pointsby dcuover 7 years ago

12 comments

takumoover 7 years ago
Looks cool but really should mention early on that it doesn't use SDL or OpenGL to render the game but uses a specific feature of iTerm2 to render a series of images in the terminal, on other terminals it just shows a black screen.
评论 #16291067 未加载
评论 #16291145 未加载
masswerkover 7 years ago
It may be worth noting that the sprites are registered trademarks of Taito. So be careful…<p>(I learned this the hard way: I once had a rather poplar 404 page featuring a variant of the game [1], until I received a cease and desist letter from Taito…)<p>[1] Compare: <a href="https:&#x2F;&#x2F;gizmodo.com&#x2F;this-space-invaders-404-page-is-the-funnest-404-error-p-510768455" rel="nofollow">https:&#x2F;&#x2F;gizmodo.com&#x2F;this-space-invaders-404-page-is-the-funn...</a>
评论 #16292934 未加载
AndrewOMartinover 7 years ago
The invaders positions shouldn&#x27;t all be updated every cycle, they should be updated one at a time, or in a separate thread, this is what the arcade machine does and due to its limited processing speed this naturally leads to the aliens speeding up as fewer aliens remain.<p>This implementation starts with the aliens going at what might be considered &quot;full speed&quot;, and is probably much more difficult.<p><a href="https:&#x2F;&#x2F;www.giantbomb.com&#x2F;space-invaders&#x2F;3030-5099&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.giantbomb.com&#x2F;space-invaders&#x2F;3030-5099&#x2F;</a>
JayOtterover 7 years ago
For anyone interested in making little games in Golang, Termloop[1] is a terminal-based engine (though it uses text to render rather than this iTerm-specific feature).<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;joelotter&#x2F;termloop" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;joelotter&#x2F;termloop</a>
评论 #16291120 未加载
rileyphoneover 7 years ago
My understanding is that Go&#x27;s ffi overhead[1] makes game development impractical at a certain level, due to the amount of opengl calls you have to make. Is this still the case?<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;dyu&#x2F;ffi-overhead&#x2F;blob&#x2F;master&#x2F;README.md" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;dyu&#x2F;ffi-overhead&#x2F;blob&#x2F;master&#x2F;README.md</a>
评论 #16292068 未加载
评论 #16294433 未加载
评论 #16292973 未加载
评论 #16293267 未加载
评论 #16292173 未加载
darethasover 7 years ago
This is awesome, and something I was doing as well for fun! Go&#x27;s image package has some pretty nice primitives. One thing I think would make this even simpler is you could simply sequence the individual sprites using image.NewRGBA and simply setting the Pix slice to the values to draw the appropriate images, then you can avoid going to the os at all!
crehnover 7 years ago
FWIW, here&#x27;s a single-file terminal snake in Go: <a href="https:&#x2F;&#x2F;github.com&#x2F;hoffa&#x2F;snake" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;hoffa&#x2F;snake</a>
评论 #16291382 未加载
wmielover 7 years ago
Here&#x27;s also a cool example of a game written in go, although using JS to display GUI: <a href="http:&#x2F;&#x2F;blog.u2i.com&#x2F;we-made-a-multiplayer-browser-game-in-go-for-fun&#x2F;" rel="nofollow">http:&#x2F;&#x2F;blog.u2i.com&#x2F;we-made-a-multiplayer-browser-game-in-go...</a>
JustSomeNobodyover 7 years ago
As someone who is just learning Go, this is a really cool bite-size project to read and learn from.<p>Very cool!
JoeAltmaierover 7 years ago
Cool, and a great programming tutorial!<p>I was thinking I might see Go in a device-control application, but alas not. The program uses a modern computer&#x27;s video system. The original Space Invaders code likely had to shift pixels out to the video display in realtime. So a different programming feat entirely, but still cool!
评论 #16290995 未加载
评论 #16290951 未加载
shoshinoover 7 years ago
<a href="https:&#x2F;&#x2F;github.com&#x2F;asib&#x2F;spaceinvaders" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;asib&#x2F;spaceinvaders</a> &#x2F; <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=10078928" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=10078928</a>
krappover 7 years ago
Dupe - posted yesterday by the original project author, but with only two comments[0]<p>I think a moderator should consider merging this thread with the original, if possible.<p>[0]<a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=16287030" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=16287030</a>