acegiak

Untitled

Sep 11th, 2013
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //method to work out damage from blocks?
  2. CollidedWith(Entity theOtherEntity){
  3.     float towardsAccuracy = 0.5f;
  4.     float damage = 0f;
  5.     if(theOtherEntity instanceof Actor
  6.     && ((Actor)theOtherEntity).body.getPosition().sub(body.getPosition).nor().dst(body.getLinearVelocity().nor()) < towardsAccuracy){
  7.         damage = body.getLinearVelocity().length() * body.getMass();
  8.         damage = Math.sqrt(damage); //not sure if this is needed to scale down the damage from being stupidly high?
  9.         ((Actor)theOtherEntity).takeDamage(damage,this);
  10.     }
  11. }
Advertisement
Add Comment
Please, Sign In to add comment