Coder Social home page Coder Social logo

opensourcegamedeveloper / love.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from davidobot/love.js

0.0 1.0 0.0 52.49 MB

LÖVE ported to the web using Emscripten, updated to the latest Emscripten and LÖVE (v11.3)

License: MIT License

HTML 22.40% JavaScript 37.56% Lua 33.26% CSS 3.80% Shell 1.37% Batchfile 1.60%

love.js's Introduction

Love.js for LÖVE v11.3

Basically trying to adapt love.js to the latest and greatest versions of LÖVE and Emscripten.

Demos

Quickstart

love.js game.love game -c

Build a game with the compatibility version.

Installation

Install the package from npm; no need to download this repo:

npm i love.js

or globally:

npm -g i love.js

Usage

npx love.js [options] <input> <output>

or

love.js [options] <input> <output>

<input> can either be a folder or a .love file. <output> is a folder that will hold debug and release web pages.

You can also replace love-js in the above command with index.js (or node index.js on Windows) directly if the numpy install is giving you problems.

Options:

-h, --help            output usage information
-V, --version         output the version number
-t, --title <string>  specify game name
-m, --memory [bytes]  how much memory your game will require [16777216]
-c, --compatibility   specify flag to use compatibility version

Test it

  1. Run a web server (while cd-ed into the <output> folder):
  • eg: python -m http.server 8000
  1. Open localhost:8000 in the browser of your choice.

Notes

  1. Compatibility version (-c) should work with most browsers. The difference is that pthreads aren't used. This results in dodgy audio.
  2. The normal version works in the latest Chrome and should work with the latest Firefox version.

In Firefox, the normal version can throw Uncaught ReferenceError: SharedArrayBuffer is not defined. Fix is discussed here. TL;DR Enable the following HTML reponse headers on the website you're hosting your project on:

Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp
  1. Memory is now dynamically resized even with pthreads thanks to this. Still needs a large-enough initial memory until I figure out how to properly wait for the memory to be sized-up before initialising all the file-system stuff (pointers here).
  2. Shaders work (check out 3D demo), but require stricter type-checking. The OpenGL ES Shading Language is type safe. There are no implicit conversions between types (source). So something like
vec4 effect(vec4 color, Image tex, vec2 texture_coords, vec2 screen_coords)
{
    vec4 texturecolor = Texel(tex, texture_coords);
    return texturecolor * color / 2;
}

won't work, but changing line 4 to the code below will make everything run just fine:

return texturecolor * color / 2.0;
  1. If you use love.mouse.setGrabbed or love.mouse.setRelative, the user needs to click on the canvas to "lock" the mouse.

  2. Use love.filesystem.getInfo(file_name) before trying to read a potentially non-existent file.

  3. If you use a depth buffer, add the following line: t.window.depth = 16 to your config.lua file to make sure normals aren't inverted in Firefox.

Building

MacOS

Clone the megasource and love and then run build_lovejs.sh (with minor changes for file paths).

That should just work™. Make sure you have CMake installed, clone emsdk and edit build_lovejs.sh to point to the right paths.

Windows

Clone the megasource and love and then run build_lovejs.bat (with minor changes for file paths) in PowerShell.

Make sure you have CMake and Make (e.g. through chocolatey), and that you have the latest Visual Studio build bundles installed. Clone emsdk and edit build_lovejs.bat to point to the right paths.

love.js's People

Contributors

tannerrogalsky avatar davidobot avatar janwerder avatar jiaaro avatar npinochet avatar rm-code avatar sheepolution avatar

Watchers

James Cloos 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.