lib/fantasy/utils.rb in fantasy-0.1.1 vs lib/fantasy/utils.rb in fantasy-0.1.3

- old
+ new

@@ -1,13 +1,16 @@ module Utils # https://developer.mozilla.org/en-US/docs/Games/Techniques/2D_collision_detection def self.collision?(actor_1, actor_2) - ( - actor_1.position.x < (actor_2.position.x + actor_2.width) && - (actor_1.position.x + actor_1.width) > actor_2.position.x && - actor_1.position.y < (actor_2.position.y + actor_2.height) && - actor_1.position.y + actor_1.height > actor_2.position.y - ) + result = + ( + actor_1.position.x < (actor_2.position.x + actor_2.width) && + (actor_1.position.x + actor_1.width) > actor_2.position.x && + actor_1.position.y < (actor_2.position.y + actor_2.height) && + actor_1.position.y + actor_1.height > actor_2.position.y + ) + + result end def self.collision_at?(actor, x, y) ( actor.position.x < x &&