Sha256: b13ddf8151b6fa93239c28999f6ca5ebc568185022f4420b69b7573c6b0ad16a
Contents?: true
Size: 961 Bytes
Versions: 3
Compression:
Stored size: 961 Bytes
Contents
module Utils # https://developer.mozilla.org/en-US/docs/Games/Techniques/2D_collision_detection def self.collision?(actor_1, actor_2) 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 && (actor.position.x + actor.width) > x && actor.position.y < y && actor.position.y + actor.height > y ) end def self.draw_frame(x, y, width, height, stroke, color) Gosu.draw_rect(x, y, width, stroke, color) Gosu.draw_rect(x + (width - stroke), y, stroke, height, color) Gosu.draw_rect(x, y + (height - stroke), width, stroke, color) Gosu.draw_rect(x, y, stroke, height, color) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
fantasy-0.1.5.1 | lib/fantasy/utils.rb |
fantasy-0.1.5 | lib/fantasy/utils.rb |
fantasy-0.1.3 | lib/fantasy/utils.rb |