This file contains 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
class Cache { | |
constructor(props = {}) { | |
this.version = props.version || 1; | |
this.assets = {}; | |
this.db = null; | |
} | |
init() { | |
return new Promise(resolve => { | |
const request = indexedDB.open('tactics.cache', this.version); |
This file contains 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
bool inBounds(vec2 mouse, vec2 uv, float width, float height) { | |
float mx = mouse.x; | |
float my = 1.0 - mouse.y; | |
bool inX = mx >= uv.x - width && mx <= uv.x + width; | |
bool inY = my >= uv.y - height && my <= uv.y + height; | |
return inX && inY; | |
} |
Takes a value from range (x1, y1) and maps that value to a new range (x2, y2).
const map = (value, x1, y1, x2, y2) => (value - x1) * (y2 - x2) / (y1 - x1) + x2;
const value = 5; // range (1, 10)
console.log(map(value, 1, 10, 0, 1)); // 0.5
This file contains 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 TPS = 20; | |
const Queue = { | |
counter: 1, | |
items: {}, | |
/** | |
* Add an item to the queue, with the given func to call | |
* @param {Function} func | |
* @param {Boolean} repeating | |
* @return {Number} | |
*/ |
This file contains 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
{ | |
"private": true, | |
"name": "ReactValidation", | |
"version": "1.0.0", | |
"description": "Validates form elements.", | |
"repository": { | |
"type": "git", | |
"url": "git@bitbucket.org:Enijar/reactvalidation.git" | |
}, | |
"dependencies": { |
This file contains 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 Event = { | |
events: {}, | |
on(event, func) { | |
if (!this.events.hasOwnProperty(event)) { | |
this.events[event] = []; | |
} | |
this.events[event].push(func); | |
}, |
NewerOlder