Skip to content

Instantly share code, notes, and snippets.

View worldoptimizer's full-sized avatar
💭
Homeoffice

Max Ziebell worldoptimizer

💭
Homeoffice
View GitHub Profile
@worldoptimizer
worldoptimizer / hype stable symbol example.js
Last active March 12, 2020 22:31
A simple example for an extended symbol
function symbolInit (hypeDocument, element, event){
console.log('HypeSymbolInit');
var symbolInstance = hypeDocument.getSymbolInstanceForElement(element);
var symbolElement = symbolInstance.element();
switch (symbolInstance.symbolName()){
case 'counter':
Object.assign( symbolInstance, {
_counter: 0,
increase: function(){
@worldoptimizer
worldoptimizer / initGame.js
Last active February 6, 2020 08:59
Function initGame (preparation)
// fetch scene element and then the lander element in it by classname
var sceneElm = document.getElementById(hypeDocument.currentSceneId());
var lander = sceneElm.querySelector('.lander');
var landerBody = hypeDocument.getElementProperty(lander, 'physics-body');
@worldoptimizer
worldoptimizer / initGame.js
Last active February 6, 2020 08:59
Function initGame (Keyboard Input, Lander Game))
var keyPressLookup = {};
document.addEventListener('keydown', function(e){
keyPressLookup[e.code] = true;
});
document.addEventListener('keyup', function(e){
delete keyPressLookup[e.code];
});

Keybase proof

I hereby claim:

  • I am worldoptimizer on github.
  • I am maxziebell (https://keybase.io/maxziebell) on keybase.
  • I have a public key whose fingerprint is 3CAD 5CF1 89E1 A8C3 A5EF 23E6 B1B4 6EC2 9362 2709

To claim this, I am signing this object:

// Lower value increases trail duration.
const CANVAS_CLEANUP_ALPHA = 0.3;
// Cleans up the canvas by removing older trails.
// ...
function cleanCanvas() {
// Set 'destination-out' composite mode, so additional fill doesn't remove non-overlapping content.
context.globalCompositeOperation = 'destination-out';
// Set alpha level of content to remove.
// Lower value means trails remain on screen longer.