Coder Social home page Coder Social logo

zero-jetpack's Introduction

zero-jetpack

Toby Jaffey https://mastodon.me.uk/@tobyjaffey

Play at: https://ringtailsoftware.github.io/zero-jetpack

A game built on https://github.com/ringtailsoftware/zig-wasm-audio-framebuffer

Fly Zero the Ziguana through space, collect the eggs and deposit them carefully in the basket.

Build and test (assumes you have zig installed)

zig build
cd zig-out && python3 -m http.server 8000

Build and test via docker

make

Browse to http://localhost:8000

Notes

This project is a mess, I've been working on for fun and education. I'm sharing the code because it might help others who are trying to figure out similar things.

Definitely bad stuff

  • Error/allocation handling is almost non-existent. It's a game, if something fails then the whole thing fails
  • Physics. All of the physics is hand-rolled. Some of it isn't very realistic. Other bits aren't even framerate independent
  • Graphics. Everything is drawn all of the time. Primitives are clipped to the framebuffer to stop them writing to bad memory locations, but that's it. It's a testament to zig and wasm that it's so fast at all
  • The collision detection is known to be bad. It works when the frame time delta is kept small, it would fail if larger movements were allowed

Not so bad stuff

  • It's probably quite portable. Apart from getTimeUs(), it doesn't call out to anything in the host. The host polls the code for sound and pixel buffers
  • The levels are pairs of levelX.png and levelX.txt files in assets/. Each png is a bitmap with a colour for each thing in the game. White is empty, black is rock, red is an egg (redness dictates egg size). Blue is the player start position and green is the basket location
  • The sprite tilesheets and animations are all defined in assets/sprites.json

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.