SHOW:
|
|
- or go back to the newest paste.
| 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){
|
| 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 | } |