Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by eruciform

I know that jQuery can't be used inside a canvas, but would it be possible to create something like the "inverse collision" detection that I put into this module: http://sourceforge.net/projects/jquerycollision/

I called it "protrusion" for lack of a better word. This allows one object to "trap" another, and you get a "collision" event only if the trapped entity either protrudes from or has entirely escaped the enclosing entity. It's not the same as "not collided", because both modes trigger on partial overlap. The difference is whether complete overlap or complete lack of overlap counts as a "collision".

Just a thought.

1 decade ago by quidmonkey

Nah. Protrusion is a fringe case. Most games don't need to know if one Entity contains another. This would make for a good plugin:

ig.module(
	'plugins.protrusion'
)
.requires(
	'impact.entity'
)
.defines(function(){ "use strict";

ig.Entity.inject({

	protrudes: false,
	
	touches: function( other ) {	
		if(
			this.pos.x >= other.pos.x + other.size.x ||
			this.pos.x + this.size.x <= other.pos.x ||
			this.pos.y >= other.pos.y + other.size.y ||
			this.pos.y + this.size.y <= other.pos.y
		){
			return false;
		}
		else {
			this.protrudes = !(
						this.pos.x > other.pos.x &&
						this.pos.x + this.size.x < other.pos.x + other.size.x &&
						this.pos.y > other.pos.y &&
						this.pos.y + this.size.y < other.pos.y + other.size.y
					);
			
			return true;
		}
	}

});

});
Page 1 of 1
« first « previous next › last »