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
// 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); |
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
/* | |
Usage: | |
ig.module('game.entities.example') | |
.requires('impact.entity', 'plugins.entity-blinking') | |
.defines(function() { | |
EntityExample = ig.Entity.extend({ | |
size: { x: 32, y: 32 }, |
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.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()); |
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
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