wolf3d

command module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 14, 2023 License: MIT Imports: 19 Imported by: 0

README

Wolf3D - Simple Raycaster

Live Demo

https://creack.github.io/wolf3d

Window mode

go run go.creack.net/wolf3d@latest

WASM

One liner
env -i HOME=${HOME} PATH=${PATH} go run github.com/hajimehoshi/wasmserve@latest go.creack.net/wolf3d@latest
Details

Install wasmer:

go install github.com/hajimehoshi/wasmserve@latest

Clone this repo:

git clone https://github.com/creack/wolf3d
cd wolf3d

Run:

env -i HOME=${HOME} PATH=${PATH} wasmserve .

For development, wasmer exposes an endpoint to do live reload.

I recommend reflex.

Install:

go install github.com/cespare/reflex@latest

Then, with wasmer running:

reflex curl -v http://localhost:8080/_notify

Controls

  • up/down w/s: Move up/down.
  • right/left: Turn right/left.
  • a/d: Strife right/left.

Docker

A Dockerfile is provided to build and run the WASM version.

Build
docker build -t wolf3d .
Regular run

To run the image, make sure to have:

  • --rm to avoid pollution
  • -it so the app receives signals
  • -p to expose the port 8080

Any changes to the code will require to re-build the image.

docker run --rm -p 8080:8080 -it wolf3d wasmserve .

You can then access the WASM page at the Docker ip on port 8080. If in doubt about the IP, it is likely localhost.

Development run

For development, you can add -v $(pwd):/app to mount the local directory in the Docker container, the server will hot-reload when file changes.

docker run --rm -p 8080:8080 -it -v $(pwd):/app wolf3d

Ack

Largely based on:

Documentation

Overview

Package main is the entrypoint.

Ref: https://lodev.org/cgtutor/raycasting.html

Directories

Path Synopsis
Package math2 provides 2D math helpers.
Package math2 provides 2D math helpers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL