This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Adapted from: http://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect/1968345#1968345 | |
function line_intersects(p0_x, p0_y, p1_x, p1_y, p2_x, p2_y, p3_x, p3_y) { | |
var s1_x, s1_y, s2_x, s2_y; | |
s1_x = p1_x - p0_x; | |
s1_y = p1_y - p0_y; | |
s2_x = p3_x - p2_x; | |
s2_y = p3_y - p2_y; | |
var s, t; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function halveTilesize( layer: Layer, tileset: Image ) { | |
if( layer.tilesize % 2 !== 0 || (layer.name !== 'collision' && !tileset.loaded) ) { | |
return false; | |
} | |
const oldTileWidth = tileset.width / layer.tilesize; | |
const newTileWidth = (tileset.width / layer.tilesize) * 2; | |
const newData = []; | |
for( let y = 0; y < layer.height; y++ ) { | |
newData[y * 2] = []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var link = document.createElement('a'); | |
link.href = Main.backbuffer.g2canvas.canvas.canvas.toDataURL(); | |
link.download = 'coolimage.jpg'; | |
document.body.appendChild(link); | |
link.click(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Convert UTC time string to Unix time interger. | |
$timestamp = strtotime ( '2014-12-29 12:30:21+0000' ); | |
// Convert Unix time integer back to UTC time string. | |
echo gmdate(DateTime::ISO8601, $timestamp); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ig.game.backgroundMaps.sort(function(a,b) { | |
var o1 = (a.repeat ? 0 : 1); | |
var o2 = (b.repeat ? 0 : 1); | |
var p1 = (a.foreground ? 1 : 0); | |
var p2 = (b.foreground ? 1 : 0); | |
if(o1 === o2) { | |
return (p1 < p2) ? -1 : (p1 > p2) ? 1 : 0; | |
} else { | |
return (o1 < o2) ? -1 : 1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ig.module('plugins.mixin-grid-movement') | |
.requires() | |
.defines(function() { | |
MixinGridMovement = { | |
src_tile: null, | |
dst_tile: null, | |
grid_move: function(direction, seconds) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The purpose of this program is to "pre-render" pixel | |
// perfect circles, so that they can be drawn from an image | |
// instead of using something like an arc function. The | |
// output image is a tilesheet that can be used in 2D pixel | |
// art style games. | |
// Originally I ran into an issue with common algorthithms | |
// (such as the midpoint circle algorithm) only supporting | |
// an increase in diameter of 2 pixels at a time. I wanted | |
// to capture single pixel size increases (thus doubling |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
P = ASM Pointer | |
S = Steps | |
F = Speed Factor | |
B = Speed Bitmask? | |
Q = Animation Slot | |
T = Start Tile | |
A = Tile Amount | |
I = Is Special Part Flag | |
H = Has Special Part Flag | |
R = Rotation Shifted Flag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hex: 0130 | |
Bin: 0000 0001 0011 00.00 | |
Tile: 001 | |
Attr: 0C | |
Hex: D405 | |
Bin: 1101 0100 0000 01.01 | |
Tile: 1D4 | |
Attr: 01 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test = 1; | |
obj = { test: null }; | |
Object.defineProperty(obj, 'test', { | |
get: function() { return test; }, | |
set: function(value) { test = value } | |
}); |
NewerOlder