All pastes #2053928 Raw Edit

Something

public text v1 · immutable
#2053928 ·published 2011-05-04 18:57 UTC
rendered paste body
	var proj = projectiles.getItemAt(x);
	var futurex:uint = Math.round((proj.bullet.x + proj.bullet.velocity.x -2 ) / FlxG.width*40);
	var futurey:uint = Math.round((proj.bullet.y + proj.bullet.velocity.y - 4 ) / (240) * 30 );
	
	if (level.getTile(futurex, futurey) != 0) {
		//Collision !
		
		// Now to check if it hit vertically or horizontally
		var currentx:uint = Math.round((proj.bullet.x -2 ) / FlxG.width*40);
		var currenty:uint = Math.round((proj.bullet.y- 4 ) / (240) * 30 );
		if (level.getTile(futurex, currenty) != 0) proj.bullet.velocity.x = -proj.bullet.velocity.x; // Horizontal hit !
		if (level.getTile(currentx, futurey) != 0) proj.bullet.velocity.y = -proj.bullet.velocity.y; // Vertical hit !
	}