View gist:e12b70cec53df547de59
// This is how to manually set the frames per second in ImpactJS. | |
setTimeout(function() { | |
var fps = 60; | |
ig.system.stopRunLoop(); | |
window.setInterval( ig.system.run.bind(ig.system), 1000/fps ); | |
}, 0); |
View pixelated-circle-tilesheet-generator.js
// 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 |
View mixin-grid-movement.js
ig.module('plugins.mixin-grid-movement') | |
.requires() | |
.defines(function() { | |
MixinGridMovement = { | |
src_tile: null, | |
dst_tile: null, | |
grid_move: function(direction, seconds) { |
View gist:59856f30f351510a656b3ffbf5ec633f
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; | |
} |
View timestamp.php
<?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); |
View gist:bc7170c0767550eeeebcb77a97c0b362
var link = document.createElement('a'); | |
link.href = Main.backbuffer.g2canvas.canvas.canvas.toDataURL(); | |
link.download = 'coolimage.jpg'; | |
document.body.appendChild(link); | |
link.click(); |
View impact-edit-map-util.ts
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] = []; |
OlderNewer