Skip to content

Instantly share code, notes, and snippets.

View SupremeTechnopriest's full-sized avatar

Randy Lebeau SupremeTechnopriest

View GitHub Profile
@SupremeTechnopriest
SupremeTechnopriest / overlap.js
Last active August 8, 2019 06:28
Flyweighted SAT.js Collision System
import SAT from 'sat'
// Size of each memory pool
const POOL_SIZE = 100
// Setting this to true will draw a client side
// representation of the collider shapes
const DRAW_COLLIDERS = false
// Generators
@SupremeTechnopriest
SupremeTechnopriest / overlap.js
Last active August 5, 2019 02:51
Simple overlap system
import intersects from 'intersects'
import { polygonRotate } from 'geometric'
const categoryCheck = (c1, c2) => c1.collidesWith.some(category => c2.categories.includes(category))
const reducePoints = points => points.reduce((resultArray, item, index) => {
const chunkIndex = Math.floor(index / 2)
if (!resultArray[chunkIndex]) resultArray[chunkIndex] = [] // start a new chunk
resultArray[chunkIndex].push(item)
return resultArray
@SupremeTechnopriest
SupremeTechnopriest / arena.gamemode
Last active July 24, 2019 02:31
Finite State Game Mode Script
properties:
scripts:
- /game-modes/sandbox/fsm.js
- /game-modes/sandbox/start.js