Code Monkey home page Code Monkey logo

innerwilds's Introduction

Inner Wilds

A game written in Nim for the WASM-4 fantasy console.

Try it now on your browser! https://msakuta.github.io/InnerWilds/out.html

video

What is unique about this project?

Wasm-4 is an interesting project that imitates 4-bit consoles with WebAssembly, but obviously it isn't true 4-bit console. In particular, WebAssembly is equipped fully capable IEEE 754 floating point processor instructions. Also an interesting thing to note about hardware specs is that it does not mention about CPU specification. This is because WebAssembly is designed to be architecture agnostic and it should run on any modern CPUs. It means we can leverage modern CPU architecture and speed in supposedly 4-bit-ish platform.

That said, RAM and ROM capacity is very limited (64kb for each), so we want something that can run with little memory. And what is a good example of that? Ray tracing!

Why Nim?

Nim is a systems programming language suitable for low-end CPUs. Or I should say one of many of this kind.

At first, as Rust lover, I wanted to write in Rust. However, Rust compiles to a big Wasm binary as soon as I link trigonometric functions which are required by 3D graphics, and it exceeds ROM size specification pretty quickly. Apparently Wasm doesn't have mathematical functions as part of intrinsics, so the language has to implement them as library functions. Also, a lot of library codes seem to come from runtime, e.g. panic handlers.

Zig was another candidate, but for some reason it didn't compile in my environment.

Nim was the last candidate that can compile fairly small binary (~10kb). I could write in C or C++ since Nim compiles to C, but I took this opportunity to write something with a new language.

Building

Build the cart by running:

nimble rel

Then run it with:

w4 run build/cart.wasm

For more info about setting up WASM-4, see the quickstart guide.

Links

  • Documentation: Learn more about WASM-4.
  • Snake Tutorial: Learn how to build a complete game with a step-by-step tutorial.
  • GitHub: Submit an issue or PR. Contributions are welcome!

innerwilds's People

Contributors

msakuta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.