Skip to main content

Setup Your Project

Before you can begin, you need a project to work with. The CLI-Tool of WASM-4 includes templates for several programming languages like AssemblyScript, C, Go and Rust. More languages are sure to come in the future.

The Terminal#

Work is often easier on a terminal. For this step, open your terminal/powershell and navigate to your projects folder.

For the sake of having the same base, I assume the projects-folder is here: ~/Projects/.
On Linux and macOS this is usually /home/[YOUR USERNAME]/Projects.
On Windows this is usually C:\Users\[YOUR USERNAME]\Projects\.

Below you'll find instructions for your language.

To compile AssemblyScript projects you will need npm installed.

w4 new --assemblyscript snakecd snake

First we'll setup AssemblyScript (this only needs to be done once):

npm install

Compile the .wasm cartridge:

npm run build

Run it in WASM-4 with:

w4 watch
Prevent Browser from opening

If you don't want the browser to open a new tab for you, you can prevent this by using the -n or --no-open option. You can also set an environment variable called W4_NO_OPEN.


w4 watch --no-open


W4_NO_OPEN=1 w4 watch
Setting a default language

You can set a default language by setting the environment variable W4_LANG to one of the supported languages. It's possible to override it with the CLI parameter later on.

Current State#

For now, your game should look this:

Hello World

The color changes if you press Button 1 (X or Space).