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: Creating a Snake game clone with Rust/Bevy

44 pointsby bebrwsover 1 year ago
Code is here: <a href="https:&#x2F;&#x2F;github.com&#x2F;bebrws&#x2F;bevy-snake">https:&#x2F;&#x2F;github.com&#x2F;bebrws&#x2F;bevy-snake</a><p>I had a lot of fun practicing Rust and Learning some Bevy concepts with this repository.<p>Bevy has an incredibly powerful dependency injection system and follows a pattern called ECS which makes it very powerful (and new to me).<p>This simple &lt; 300 lines of code might help with learning some Bevy concepts.<p>It also shows how to copmile for the web&#x2F;WASM and inject a canvas for the game (or use a pre existing div).

3 comments

chaosprintover 1 year ago
Nice.<p>Speaking of Snake game, if you want to go even deeper, you can try to use the wgpu crate to combine Rust and WebGPU to write everything from scratch. Here is the tutorial:<p><a href="https:&#x2F;&#x2F;sotrh.github.io&#x2F;learn-wgpu&#x2F;#what-is-wgpu" rel="nofollow">https:&#x2F;&#x2F;sotrh.github.io&#x2F;learn-wgpu&#x2F;#what-is-wgpu</a><p>I once wrote a code editor with wgpu, from font rendering to char&#x2F;line state management (very rough) for music live coding:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;glicol&#x2F;glicol-wgpu">https:&#x2F;&#x2F;github.com&#x2F;glicol&#x2F;glicol-wgpu</a><p>It runs in browsers, even including Safari!
评论 #39436099 未加载
charcircuitover 1 year ago
Mobile browsers do support wasm, but the game doesn&#x27;t offer controls for mobile users who aren&#x27;t using a keyboard.<p>Taking 100.6 KB (16.46 KB compressed) of javascript and 37.41 MB (8.15 MB compressed) for snake is quite a lot compared to what it would take for normal javascript.
评论 #39435010 未加载
评论 #39434672 未加载
评论 #39438058 未加载
legerdemainover 1 year ago
Somewhat tangential, but RustConf last year had a talk[1] about a guy picking up Rust to get better times at Battle Snake[2].<p>[1] <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=-I1BfSpoWM0" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=-I1BfSpoWM0</a><p>[2] <a href="https:&#x2F;&#x2F;play.battlesnake.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;play.battlesnake.com&#x2F;</a>