node compile-html.cjs in.html out.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // WebGL 1.0 | |
| export const GL_ACTIVE_ATTRIBUTES = 0x8b89; | |
| export const GL_ACTIVE_TEXTURE = 0x84e0; | |
| export const GL_ACTIVE_UNIFORMS = 0x8b86; | |
| export const GL_ALIASED_LINE_WIDTH_RANGE = 0x846e; | |
| export const GL_ALIASED_POINT_SIZE_RANGE = 0x846d; | |
| export const GL_ALPHA = 0x1906; | |
| export const GL_ALPHA_BITS = 0x0d55; | |
| export const GL_ALWAYS = 0x0207; | |
| export const GL_ARRAY_BUFFER = 0x8892; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function hashSet(arr) { | |
| let h = 0; | |
| for (let x of arr) { | |
| h = Math.imul((h << 5) ^ x, 0x9e3779b9); | |
| } | |
| return h; | |
| } | |
| function rand(n) { | |
| return (Math.random() * n) | 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let assets = {}; | |
| let getAsset = (id, callback) => | |
| assets[id] || (assets[id] = callback(document.querySelector("#" + id))); | |
| let getImage = id => getAsset(id, img => img); | |
| let getSource = id => getAsset(id, node => node.innerHTML.trim()); | |
| onload = () => { | |
| let texture1 = getImage("tex1") | |
| let texture2 = getImage("tex2") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -e | |
| # Clean previous build | |
| rm -rf dist | |
| mkdir dist | |
| # Compile the game | |
| $(yarn bin)/rollup -c \ | |
| -i src/index.js \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let rng = createNumberGenerator( | |
| createSeedFromString("Hello friends!") // 2053374269 | |
| ); | |
| // Generate a boolean with 30% success | |
| console.log(generateBoolean(rng, 0.3)); // false | |
| console.log(generateBoolean(rng, 0.3)); // true | |
| // Generate a D6 | |
| console.log(generateNumber(rng, 1, 6)); // 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @param {number} width | |
| * @param {number} height | |
| * @param {!CanvasPattern} pattern | |
| * @constructor | |
| */ | |
| function Texture(width, height, pattern) { | |
| this.width = width | |
| this.height = height | |
| this.pattern = pattern |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const eventBus = new EventEmitter() | |
| function someSystem() { | |
| for (const entity of em.query(Timer)) { | |
| const {delay} = entity.get(Timer) | |
| if (delay <= 0) { | |
| // Remove `Timer` component… | |
| entity.remove(Timer) | |
| // …then dispatch an event | |
| eventBus.emit("componentRemoved", {entity}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { applyMiddleware, compose, createStore } from "redux" | |
| import { reduxReactIntl } from "redux-react-intl" | |
| import thunk from "redux-thunk" | |
| import rootReducer from "./reducers" | |
| const createStoreFactory = compose( | |
| applyMiddleware(thunk), | |
| reduxReactRouter({ routes, createHistory }) | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const actions = { | |
| doSomeStuff() { | |
| return fetch('/api/stuff').then( | |
| (res) => (stores.stuffList = res), | |
| (err) => Promise.reject(err) | |
| ) | |
| } | |
| } | |
| export const stores = { |
NewerOlder