Rewrite SpaceWar in Rust + WebAssembly for browser play - #1
Merged
Conversation
Agent-Logs-Url: https://github.com/lassault/SpaceWar/sessions/7ec71670-17d1-4ddd-a4e9-dbec51a0cf93 Co-authored-by: lassault <40122711+lassault@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor game code to Rust with WebAssembly
Rewrite SpaceWar in Rust + WebAssembly for browser play
Apr 7, 2026
lassault
approved these changes
Apr 8, 2026
lassault
marked this pull request as ready for review
April 8, 2026 08:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The original Java/Swing desktop game is inaccessible on the web. This adds a complete Rust + WebAssembly port, deployable as a static site (GitHub Pages), preserving all original gameplay mechanics.
What's new
spacewar-wasm/src/lib.rs— Rust game engineSpaceWarGamestruct exported viawasm-bindgen; three public entry points:tick(ts),on_key_down(key, code),on_mouse_move(x, y)Menu → Playing → GameOverweb-sys—draw_image/draw_image_scaled; all 100 sprites accessed via a flat indexed array matching the JS manifestspacewar-wasm/www/index.html— thin JS shellHTMLImageElement[]array to RustrequestAnimationFrameloop callsgame.tick(ts); keyboard/mouse/touch events forwarded to Rustspacewar-wasm/www/assets/— sprite treesrc/lassa/net/imagenes/and organized without path spaces (removes the"nave 1/"naming issue from the Java classpath).github/workflows/deploy-pages.yml— CI/CDwasm-packon every push tomastertouchingspacewar-wasm/**, uploadswww/as a Pages artifact, and deploysUpdated
README.mdwasm-pack build --target web --out-dir www/pkg)Why Rust + WASM over a JS framework
Rust compiles to a 54 KB WASM binary with direct Canvas 2D access via
web-sys— no framework overhead, no GC, and a stronger portfolio signal than a React/Next.js port.