Fun is a javascript entity-component-system game framework.
Entities is represented by a plain javascript object.
// The player entity
const player = {
}
/** | |
* Use Proxy to implement observable | |
*/ | |
function observable (obj, onchange) { | |
return new Proxy(obj, { | |
set (target, key, value) { | |
Reflect.set(target, key, value) | |
onchange(key, value) | |
}, | |
delete (target, key) { |
/** | |
* Implements all the behaviors of moment.fromNow(). Pass a | |
* valid JavaScript Date object and the method will return the | |
* time that has passed since that date in a human-readable | |
* format. Passes the moment test suite for `fromNow()`. | |
* See: https://momentjs.com/docs/#/displaying/fromnow/ | |
* | |
* @example | |
* | |
* var pastDate = new Date('2017-10-01T02:30'); |
/* | |
A Javascript port of the RDBMS-inspired Entity Component System found here: | |
https://github.com/adamgit/Entity-System-RDBMS-Inspired-Java/blob/master/EntitySystemJava/ | |
src/com/wikidot/entitysystems/rdbmswithcodeinsystems/EntityManager.java | |
*/ | |
export default class EntityManager { | |
constructor(){ | |
this.lowestUnassignedID = 1; |
const waitFor = (ms) => new Promise(r => setTimeout(r, ms)) | |
const asyncForEach = async (array, callback) => { | |
for (let index = 0; index < array.length; index++) { | |
await callback(array[index], index, array) | |
} | |
} | |
const start = async () => { | |
await asyncForEach([1, 2, 3], async (num) => { | |
await waitFor(50) |
import React from "react"; | |
import { render } from "react-dom"; | |
const App = () => ( | |
<Tabs> | |
<TabList> | |
<Tab>Tab 1</Tab> | |
<Tab>Tab 2</Tab> | |
<Tab>Tab 3</Tab> | |
</TabList> |
function createLoggedProxy(obj) { | |
var traps = {}; | |
for (let trap of Object.getOwnPropertyNames(Reflect)) { | |
traps[trap] = (...args) => { | |
console.log(trap, ...args.slice(0, -1)); // Last arg is always the proxy, no need to log it | |
return Reflect[trap](...args); | |
} | |
} | |
var data = [ | |
{ | |
title: "Одежда", | |
left: 1, | |
right: 22 | |
}, | |
{ | |
title: "Мужская", | |
left: 2, | |
right: 9 |
export let AStar = (_grid, start, end, units, currentSelectionID) => { | |
// Reset score of cells | |
_grid.resetCells() | |
// pass tanks to grid and make them obstacles | |
_grid.makeObstaclesOfUnitsWithHigherMass(units[currentSelectionID], units, currentSelectionID) | |
// Add possible cell neighbors, pass unit A* style | |
let aStarStyle = units[currentSelectionID].aStarStyle | |
_grid.addCellNeighbors(aStarStyle) | |
let openSet = [] | |
let closedSet = [] |
A non-exhaustive list of WebGL and WebGPU frameworks and libraries. It is mostly for learning purposes as some of the libraries listed are wip/outdated/not maintained anymore.
Name | Stars | Last Commit | Description |
---|---|---|---|
three.js | ![GitHub |