Skip to content

Instantly share code, notes, and snippets.

View systemsoverload's full-sized avatar

TJ Kells systemsoverload

View GitHub Profile
function workIt(inputArray) {
putThingDown(inputArray);
var workedArray = reverseIt(flipIt(inputArray));
alert("Worked array contains:" + workedArray);
}
var xxx = {
name: 'reptar'
}
var yyy = {
name: 'godzilla'
}
xxx.getBaz = function(){
return this.name;
@systemsoverload
systemsoverload / gist:3107864
Created July 13, 2012 22:08
Polygon Collision Resolution
1. Calculate the minimum translation vector for all coliding objects
2. Sum the x and y directions ( sum(x(n)) > 0 = right, sum(y(n)) > 0 = down, etc)
3. With the direction(s) from 3, select the directions that has the minimum displacement along one axis. For instance Down and Left. If you have one block that wants to correct you to the left and one that wants to correct you to the right, there will be no horizontal correction.This works great if you have more than one object to collide with. If you only have one object, the axis with the least displacement will be chosen and tried.
Scenario one object: Falling, high velocity on Y-axis, lower on X. Two pixel width in X-collision, 10 pixels at Y. X would be displaced.
4. Apply the minimum displacement to that axis, check for collisions. Modify the axis speed accordingly. If you hit make a top collision, the Y-Velocity should be set to zero if it is point upwards, otherwise leave it.
5. If there still are collision, apply the minimum displacement for the o
@systemsoverload
systemsoverload / gist:3077048
Created July 9, 2012 15:04
Odd shaped polygon collision
HC = require 'lib.hardoncollider'
-- array to hold collision messages
local text = {}
-- this is called when two shapes collide
function on_collision(dt, shape_a, shape_b, mtv_x, mtv_y)
local player, floor
if shape_a == mouse then
player = shape_a
@systemsoverload
systemsoverload / Session.js
Created February 14, 2012 21:56
EXT Sample
Blackjack.QC.RuleReview.Session = Ext.extend(
/**
* The Constructor!
* @constructor
*/
function( config ){
this.addEvents({
rulesParsed:true
Blackjack.QC.RuleReview.Session = Ext.extend(
/**
* The Constructor!
* @constructor
*/
function( config ){
this.addEvents({
rulesParsed:true