Skip to content

Instantly share code, notes, and snippets.


Gabe Rogan krabbypattified

Block or report user

Report or block krabbypattified

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
krabbypattified / cloudSettings
Created Mar 28, 2019
Visual Studio Code Settings Sync Gist
View cloudSettings
krabbypattified / imagerepeat.js
Last active Feb 20, 2019
Repeated background image for canvas game engine
View imagerepeat.js
const cameraXobject = new DOMMatrix().rotate(PI/8)
const inverse = cameraXobject.inverse()
const transformPoint = p => inverse.transformPoint(p)
const pat = ctx.createPattern(img, 'repeat')
ctx.fillStyle = pat
ctx.path = [
krabbypattified /
Last active Jan 18, 2019
Broad-phase Collision Detection O(n)


This describes a 2D broad-phase collision detection algorithm that runs in O(n) time where n is the number of entities. It easily extends to 3D. It holds no state except entity bounding box calculated during the previous frame in order to prevent phasing. The algorithm performs 4 steps every frame: Rectangle Creation, Rectangle Sorting, Chunk Creation, and Collision Detection.


  • point = a point in 2D space
  • path = an open set of linearly connected points
  • polygon = a closed set of linearly connected points
  • entity = a point or path or polygon
  • space = the 2D space formed by two spatial dimensions
  • spacetime = the 3D space formed by two spatial dimensions and a time dimension
View Assets.js
// Assets
const assets = {
sword: {
short: import('./Sword/short.png'),
long: 'anythingSyncOrAsync',
// Renderable component
const Blade = new Renderable([
You can’t perform that action at this time.