Skip to content

olimungo/asteroids

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Asteroids

This is a reboot of the famous video game from 1979. The goal of this project is to learn programming in different languages and having fun.

There are 3 implementations:

The Typescript and the Rust implementations can be tested at: https://olimungo.github.io/asteroids/

Obviously, the Java implementation must be executed locally on your computer.

TypeScript

Requirements

  • node and npm

Setup

Clone this project, move the the typescript folder and do:

npm i

Run locally

npm start

Java

Requirements

On macOS, you can install Processing with brew:

brew install --cask processing

Run locally

You can either start Processing and open the sketch Asteroids.pde located into the java/Asteroids folder or install the processing-java command-line.

In order to install the processing-java command, select the item "Install processing-java" in the Tools menu from the Processing IDE.

To execute the sketch using the Processing IDE, just click on the big "Play" button.

To start it at the command-line, use the following command at the root of this project:

processing-java --force --sketch=`pwd`/java/Asteroids --output=`pwd`/java/Asteroids/out --run

To start it in VS Code, use the keyboard shortcut CMD-SHIFT-b on macOS or CTRL-SHIFT-b on Windows and Linux.

Rust

Required tools

  • Rust toolchain, including rustup, rustc, and cargo.
  • wasm-pack building, testing, and publishing Rust-generated WebAssembly.
  • node and npm: version 18 or above
  • cargo-generate helps you get up and running quickly with a new Rust project by leveraging a pre-existing git repository as a template.

Use this command to install cargo-generate:

cargo install cargo-generate

The Rust code can be found into the src folder (file: lib.rs). Use wasm-pack to transpile the Rust code to WebAssembly. This command has to be executed when the lib.rs file is modified and right after cloning the repository.

This command has to be executed in the root folder of the project:

wasm-pack build

For being able to see the Rust functions name executed in the JavaScript profiler of your browser, do a build with the --dev option and debug symbols will be added:

wasm-pack build --dev

Run locally

Move the rust folder and do:

wasm-pack build

Then move to the rust/www folder and do:

npm i

In the same subfolder launch the DEV server:

npm start

Have fun!