Advertisement
acegiak

Untitled

Sep 11th, 2013
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  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.     && body.getPosition().add(((Actor)theOtherEntity).body.getPosition().sub(body.getPosition).dst(body.getPosition().add(body.getLinearVelocity()) < 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
Advertisement