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] = []; |
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 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: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 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 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 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 entity-blinking.js
/* | |
Usage: | |
ig.module('game.entities.example') | |
.requires('impact.entity', 'plugins.entity-blinking') | |
.defines(function() { | |
EntityExample = ig.Entity.extend({ | |
size: { x: 32, y: 32 }, |
View gist:44db1d01a83f995beb2d
ig.system.context.save(); | |
ig.system.context.fillStyle = '#A6E22E'; | |
var radius = 3 * ig.system.scale; | |
for (var body = ig.world.GetBodyList(); body; body = body.GetNext()) { | |
for (var fixture = body.GetFixtureList(); fixture; fixture = fixture.GetNext()) { | |
var shape = fixture.GetShape(); | |
if (shape.GetType() == Box2D.Collision.Shapes.b2Shape.e_polygonShape) { | |
var poly = shape; | |
poly.GetVertices().forEach(function(vertex) { | |
var pos = body.GetWorldPoint(vertex.Copy()); |
View gist:32c95226c3d6a1c588cd
jQuery('.chat-session').each(function() { | |
var session = jQuery($(this)); | |
var other_name = session.find('.name').text(); | |
session.find('.chat-messages').each(function() { | |
var list = jQuery($(this)); | |
list.find('li').each(function() { | |
var list_item = jQuery($(this)); |
NewerOlder