jamesmoriarty/scorched-earth-rb

View on GitHub
lib/scorched_earth/renders/explosion.rb

Summary

Maintainability
A
0 mins
Test Coverage
module ScorchedEarth
  module Renders
    class Explosion
      attr_reader :explosion

      def initialize(explosion)
        @explosion = explosion
      end

      def call(graphics, *_args)
        height = graphics.destination.height
        y      = height - explosion.y - radius / 2

        graphics.set_color color
        graphics.fill_oval x, y, radius, radius
      end

      private

      def color
        Color::WHITE
      end

      def radius
        explosion.radius
      end

      def x
        explosion.x - radius / 2
      end
    end
  end
end