GithubHelp home page GithubHelp logo

turbo_jam_0001's Introduction

Turbo Web Template

Getting Started

In the "Steps" section, replace my-game with the path to wherever your actual project dir is in the following commands.

Steps

ℹī¸ You should run all these commands from the project root directory.

1. Build your game

From the my-game dir run:

cd my-game && cargo build -r --target wasm32-unknown-unknown

2. Copy the wasm file to the root of the www dir

cp my-game/target/wasm32-unknown-unknown/release/my_game.wasm www/my_game.wasm

Note that the wasm binary will replace dashes in the package name with underscores.

3. Copy the sprites from my-game to www

Be extra careful not to delete the sprites in your project dir!

rm -rf www/sprites && cp -r my-game/sprites www/sprites

4. Edit your game configuration in www/main.js and www/solana.js

The most important parts are the wasm source, resolution, and the sprites in www/main.js.

If you are using solana features, be sure to update the rpc urls in www/solana.js.

5. Update www/manifest.json, www/favicon.ico, www/logo_192x192.png, the meta tags in www/index.html, etc

This is how you can customize your game's appearance as a PWA.

Shipping

You just copy the content of the www to whatever hosting service you are using :)

If you want to see a preview beforehand, just start a local server and host that dir.

Debugging

I see an error on the console: JsValue(CompileError: WebAssembly.instantiate(): expected magic word ....)

Double check the WASM_SRC in www/main.js;

I don't see my sprites

Make sure the files are in www/sprites and make sure you add their paths in www/main.js

I don't see my wasm file in target/wasm32-unknown-unknown/release

If you did a non-release build, it may be in target/wasm32-unknown-unknown/debug. Turbo defaults to release builds. But if you compile the game manually just be careful. Either build will work on the web. The release build will be smaller / download faster.

The ServiceWorker is throwing some console errors

www/sw.js is copy-pasta boilerplate, yeah that thing needs to get updated sorry. I should get around to it soon. But feel free to make a PR in the meantime if you want!

I don't like the way the virtual gamepad buttons look on mobile

Feel free to mess with the css in www/style.css

turbo_jam_0001's People

Contributors

woody4618 avatar

Watchers

 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.