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
startTimer = function() { | |
var start = new Date().getTime(); | |
return start; | |
}; | |
stopTimer = function(start) { | |
var end = new Date().getTime(); | |
var time = end - start; | |
return time; | |
}; |
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
getbodyCount = function() { | |
var count = 0; | |
for( var body = ig.world.GetBodyList(); body; body = body.m_next ) { | |
count++; | |
} | |
console.log(count); | |
} |
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 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); |
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 } | |
}); |
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
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
// 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
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)); |
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
/* | |
Usage: | |
ig.module('game.entities.example') | |
.requires('impact.entity', 'plugins.entity-blinking') | |
.defines(function() { | |
EntityExample = ig.Entity.extend({ | |
size: { x: 32, y: 32 }, |
OlderNewer