Live data from Hacker News

Show HN: Creating a Snake game clone with Rust/Bevy

bbarrows.com

1–10 of 13 posts

Show HN: Creating a Snake game clone with Rust/Bevy

#1
Code is here: https://github.com/bebrws/bevy-snake

I had a lot of fun practicing Rust and Learning some Bevy concepts with this repository.

Bevy has an incredibly powerful dependency injection system and follows a pattern called ECS which makes it very powerful (and new to me).

This simple It also shows how to copmile for the web/WASM and inject a canvas for the game (or use a pre existing div).

Show HN: Creating a Snake game clone with Rust/Bevy
bbarrows.com

Re: Show HN: Creating a Snake game clone with Rust/Bevy

#3
Mobile browsers do support wasm, but the game doesn't offer controls for mobile users who aren't using a keyboard.

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.

Re: Show HN: Creating a Snake game clone with Rust/Bevy

#4
Nice.

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:

https://sotrh.github.io/learn-wgpu/#what-is-wgpu

I once wrote a code editor with wgpu, from font rendering to char/line state management (very rough) for music live coding:

https://github.com/glicol/glicol-wgpu

It runs in browsers, even including Safari!

Re: Show HN: Creating a Snake game clone with Rust/Bevy

#5

Mobile browsers do support wasm, but the game doesn't offer controls for mobile users who aren't using a keyboard. 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.

For sure, but snake also doesn't need a game engine. I don't think the exercise was code golf.

Re: Show HN: Creating a Snake game clone with Rust/Bevy

#6

Mobile browsers do support wasm, but the game doesn't offer controls for mobile users who aren't using a keyboard. 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.

WASM is kind of coming full circle back around to when browsers used to support running Java Applets, or flash, or even ActiveX, however, this time, WASM is safe and is built into the browser.

Figma has been the one platform to take full advantage of it in really jaw-dropping ways that proved you could write real creative professional productive software only in the frame of a Chrome window.

It's just that WASM is not really practical for use for most things you want in a web browser, though the tooling to spit out WASM modules seem to keep getting better.

Re: Show HN: Creating a Snake game clone with Rust/Bevy

#8

Nice. 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: https://sotrh.github.io/learn-wgpu/#what-is-wgpu I once wrote a code editor with wgpu, from font rendering to char/line state management (very rough) for music live coding: https://github.com/glicol/glicol-wgpu It runs in browsers, even inclu…

This is the route I would usually prefer. However I was very happy I experimented with Bevy though just to see how powerful the type system and dependency injection ( https://promethia-27.github.io/dependency_injection_like_bev... ) in Rust can be.

It opened my eyes to a new style of game development and a new way to think about dependency injection and types.

I have always thought that a majority of the hardest software engineering problems relate in some way to gaming and when I see solutions like this it makes me think I am right.

Thanks tho! I'll def be checking that out.

Re: Show HN: Creating a Snake game clone with Rust/Bevy

#9
post #6

Mobile browsers do support wasm, but the game doesn't offer controls for mobile users who aren't using a keyboard. 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.

WASM is kind of coming full circle back around to when browsers used to support running Java Applets, or flash, or even ActiveX, however, this time, WASM is safe and is built into the browser. Figma has been the one platform to take full advantage of it in really jaw-dropping ways that proved you could write real creative professional productive software only in the frame of a Chrome window. It's just that WASM is no…

I mostly agree, but for most of its life, the Flash runtime was ~1MB and shared among every site. Every site needing to download a separate 38MB runtime is an insane amount of overhead.

Re: Show HN: Creating a Snake game clone with Rust/Bevy

#10
post #6

Earlier quoted context omitted.

WASM is kind of coming full circle back around to when browsers used to support running Java Applets, or flash, or even ActiveX, however, this time, WASM is safe and is built into the browser. Figma has been the one platform to take full advantage of it in really jaw-dropping ways that proved you could write real creative professional productive software only in the frame of a Chrome window. It's just that WASM is no…

I mostly agree, but for most of its life, the Flash runtime was ~1MB and shared among every site. Every site needing to download a separate 38MB runtime is an insane amount of overhead.

Could the WASM runtime eventually be shared like that? Also, is there a reason why the overhead is so large compared to Flash?
Post reply on HN