To explore Rust + wasm I made a version of the arcade game Asteroids. This version aims for a more physics-based feel; for example, the asteroids split where you hit them and move accordingly. This is my first such Rust project, and building this in Rust was a joy.
This is awesome. What are the rules for blasts striking asteroids? It seems like there's only one face that per asteroid that can be hit to break it up and that must be hit dead center.
All hits should have some effect. A hit splits the asteroid through the line of the blast, resulting in two or more pieces; if a piece is small enough then it explodes. Bigger asteroids can't be destroyed in a single hit; they must be broken into smaller and smaller pieces. Does that help?
To be more realistic, the ship shouldn't have more friction than the asteroids. Without friction or gravity, the only way to decelerate is to accelerate backward (with only one motor, accelerating and decelerating take exactly the same time).
The bullets should not disappear suddenly (unless there is a self-destruct mechanism inside?), but the game would be very difficult... Maybe for a "realistic/hard mode"?
Great points! I like to imagine the ship has small retrorockets that automatically stabilize the ship after a maneuver. (That's how I justify the friction in space to myself anyway.)
Nice game! My only issue is that my screen (and thus my browser page) is smaller than the game's frame. So when I push up to use the thruster, the browser treats that as a scroll event, and scrolls the whole game. In Chrome.
But I managed to play successfully without the thruster, using only the left, right, f and s keys. But detecting the browser frame size would be nice.
Dang this is cool, but damn near impossible to play on my Atreus keyboard. Any chance you could enable hjkl movements? Holding the layer key down for arrow keys means I can't press the F to fire unless I change layers again, lol.
I just started the Web Assembly with Rust book so I look forward to checking out the code!
Sure thing! I added i, j, and l as alternatives to the arrow keys. If you have any trouble, feel free to create an issue or add a comment to this one. Thanks for letting me know!
I like this game but have to agree it's just too easy to hit yourself, in combination with all the asteroid fragments that fly around after a while this makes the game unplayable for me quite quickly
Regarding "friendly fire", I feel like I've seen many versions of Asteroids make your bullets expire after a certain distance, so you can still do intentional wraparound without nearly as high a risk of shooting yourself.
Still very cool how close this is to a polished game considering how little code it takes.