Skip to content

Instantly share code, notes, and snippets.

@Joncom
Joncom / entity-blinking.js
Created Aug 28, 2015
Plugin for ImpactJS that makes entities blink
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 },
@Joncom
Joncom / gist:32c95226c3d6a1c588cd
Created Mar 19, 2015
Dump Mitel MiCollab Web Client Messages
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));
@Joncom
Joncom / gist:44db1d01a83f995beb2d
Created Jul 20, 2015
ImpactJS + Box2D: Draw world body vertex positions
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());
@Joncom
Joncom / gist:e12b70cec53df547de59
Created Nov 30, 2015
Manually Set FPS in ImpactJS
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);
@Joncom
Joncom / gist:5279870
Last active Dec 15, 2015
Comparing two JavaScript methods to see which one is faster.
View gist:5279870
startTimer = function() {
var start = new Date().getTime();
return start;
};
stopTimer = function(start) {
var end = new Date().getTime();
var time = end - start;
return time;
};
@Joncom
Joncom / gist:5703442
Created Jun 4, 2013
ImpactJS Box2D - Get Body Count
View gist:5703442
getbodyCount = function() {
var count = 0;
for( var body = ig.world.GetBodyList(); body; body = body.m_next ) {
count++;
}
console.log(count);
}
@Joncom
Joncom / gist:5812191
Created Jun 19, 2013
Count entities player is touching
View gist:5812191
var count = 0;
for(var i=0; i<ig.game.entities.length; i++) {
if(ig.game.player.touches(ig.game.entities[i])) {
count++;
}
}
console.log(count);
@Joncom
Joncom / gist:6302577
Created Aug 22, 2013
Object.defineProperty Example
View gist:6302577
test = 1;
obj = { test: null };
Object.defineProperty(obj, 'test', {
get: function() { return test; },
set: function(value) { test = value }
});
@Joncom
Joncom / gist:6401880
Created Sep 1, 2013
Pokemon Ruby Map Tile Bits
View gist:6401880
Hex: 0130
Bin: 0000 0001 0011 00.00
Tile: 001
Attr: 0C
Hex: D405
Bin: 1101 0100 0000 01.01
Tile: 1D4
Attr: 01
@Joncom
Joncom / gist:7002036
Created Oct 16, 2013
Pokemon Ruby ROM Animation Research
View gist:7002036
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
You can’t perform that action at this time.