Skip to content

Instantly share code, notes, and snippets.

@samme
samme / ∞.js
Created May 31, 2014 20:59
Infinity arithmetic
1 / 0
//-> Infinity
-1 / 0
//-> -Infinity
0 / 0
//-> NaN
Infinity === Infinity
/* jQuery Quantum Pub/Sub
* -- from --
* jQuery Tiny Pub/Sub v0.7 (http://benalman.com)
* Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */
(function( $ ) {
var o = $( {} ),
fn = $.fn,
proxy = $.proxy;
@samme
samme / Object.assign.coffee
Created January 26, 2016 04:15
Object.assign
Object.assign ?= (target, sources...) ->
unless target?
throw new TypeError "Cannot convert undefined or null to object"
output = Object target
for source in sources when source?
for own key of source
output[key] = source[key]
@samme
samme / phaser-sprite-lifecycle.md
Last active September 2, 2017 10:30
Phaser Sprite Lifecycle
alive exists fresh health renderable visible
sprite.exists = false
sprite.exists = true ✔️ ✔️
sprite.kill()
sprite.revive(…) ✔️ ✔️ 1* ✔️
sprite.reset(…) ✔️ ✔️ ✔️ 1* ✔️ ✔️
group.create(…) ✔️* ✔️* ✔️*
group.createMultiple(…) ❌* ❌* ❌*
group.resetChild(…, x, y) ✔️ ✔️ ✔️ 1 ✔️ ✔️
@samme
samme / html-attributes.md
Last active April 6, 2019 18:50
Boolean and boolean-like attributes in HTML

Boolean attributes

The presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value. If the attribute is present, its value must either be the empty string or a value that is an ASCII case-insensitive match for the attribute's canonical name, with no leading or trailing whitespace. The values "true" and "false" are not allowed on boolean attributes. To represent a false value, the attribute has to be omitted altogether.

  • allowfullscreen
  • async
  • autofocus
  • autoplay
  • checked
@samme
samme / phaser-sprite-vs-sprite-collision.md
Last active August 31, 2017 20:26
Phaser sprite vs. sprite collision

Results of collide(sprite1, sprite2) or overlap(sprite1, sprite2).

Body 1 Body 2 collide overlap embedded touching.none overlapX/Y separation¹ acceleration¹
sprite.exists=false false false
enable=false false false
checkCollision.none=true false false
immovable=true true true false ≠ 0 no no
moves=false true true false ≠ 0 yes no²
bounce³ is 0
/**
* Renders the content and empties the current batch.
*
* Modified for {@link https://github.com/photonstorm/phaser-ce/issues/194 WebGL: INVALID_VALUE: vertexAttribPointer: index out of range (Ubuntu)}.
*
* @method PIXI.WebGLSpriteBatch#flush
*/
PIXI.WebGLSpriteBatch.prototype.flush = function () {
// If the batch is length 0 then return as there is nothing to draw
if (this.currentBatchSize === 0) {
@samme
samme / phaser.d.ts
Created May 17, 2018 02:26
Phaser v3.8.0 TypeScript definitions, corrected
This file has been truncated, but you can view the full file.
declare type CallCallback = (item: Phaser.GameObjects.GameObject)=>void;
declare type GridAlignConfig = {
/**
* The width of the grid in items (not pixels). -1 means lay all items out horizontally, regardless of quantity.
* If both this value and height are set to -1 then this value overrides it and the `height` value is ignored.
*/
width?: integer;
/**
* The height of the grid in items (not pixels). -1 means lay all items out vertically, regardless of quantity.
@samme
samme / app.js
Last active June 27, 2019 08:17
Minimal Phaser 3 setup
new Phaser.Game(/* ... */);
@samme
samme / phaser-scenes-summary.md
Last active August 2, 2023 16:26
Phaser 3 Scenes Summary

Scene control

Calls without a key argument

These affect the calling scene only.

Example:

this.scene.start()