Skip to content

Instantly share code, notes, and snippets.

View gyopiazza's full-sized avatar

Giordano Piazza gyopiazza

View GitHub Profile
import { app, h } from "hyperapp";
import { Stateful } from './helpers'
/* Working example, https://codepen.io/sergey-shpak/pen/maMopd */
// --- STATEFUL COMPONENT ---
// Don't use arrow functions for stateful components/actions
// Since context is linked to it's definition context
@gyopiazza
gyopiazza / util-elastic-collision.js
Last active November 8, 2019 20:48 — forked from christopher4lis/util-elastic-collision.js
A set of utility functions used to reproduce the effect of elastic collision within HTML5 canvas. Used in the Chris Courses tutorial video on collision detection: https://www.youtube.com/watch?v=789weryntzM
/**
* Check if 2 circles collide
*
* Takes velocities and alters them as if the coordinate system they're on was rotated
*
* @param Number | p1x | x coordinate of the first particle
* @param Number | p1y | y coordinate of the first particle
* @param Number | r1 | radius of the first particle
* @param Number | p2x | x coordinate of the second particle
* @param Number | p2y | y coordinate of the second particle