Compare commits

...

2 Commits

2 changed files with 22 additions and 6 deletions

View File

@@ -1,5 +1,7 @@
module CyberarmEngine module CyberarmEngine
module Common module Common
ImageBlob = Data.define(:to_blob, :columns, :rows)
def push_state(klass, options = {}) def push_state(klass, options = {})
window.push_state(klass, options) window.push_state(klass, options)
end end
@@ -85,7 +87,8 @@ module CyberarmEngine
unless asset unless asset
instance = nil instance = nil
instance = if klass == Gosu::Image instance = if klass == Gosu::Image
klass.new(path, retro: retro, tileable: tileable) path_or_blob = path.is_a?(String) ? path : ImageBlob.new(path.to_blob, path.width, path.height)
klass.new(path_or_blob, retro: retro, tileable: tileable)
else else
klass.new(path) klass.new(path)
end end

View File

@@ -33,12 +33,23 @@ module Gosu
# #
# @return [void] # @return [void]
def self.draw_arc(x, y, radius, percentage = 1.0, segments = 128, thickness = 4, color = Gosu::Color::WHITE, z = 0, mode = :default) def self.draw_arc(x, y, radius, percentage = 1.0, segments = 128, thickness = 4, color = Gosu::Color::WHITE, z = 0, mode = :default)
segments = 360.0 / segments
return if percentage == 0.0 return if percentage == 0.0
0.step((359 * percentage), percentage > 0 ? segments : -segments) do |angle| angle_per_segment = 360.0 / segments
angle2 = angle + segments arc_completion = 360 * percentage
next_segment_angle = angle_per_segment
angle = 0
loop do
break if angle >= arc_completion
if angle + angle_per_segment > arc_completion
next_segment_angle = arc_completion - angle
else
next_segment_angle = angle_per_segment
end
angle2 = angle + next_segment_angle
point_a_left_x = x + Gosu.offset_x(angle, radius - thickness) point_a_left_x = x + Gosu.offset_x(angle, radius - thickness)
point_a_left_y = y + Gosu.offset_y(angle, radius - thickness) point_a_left_y = y + Gosu.offset_y(angle, radius - thickness)
@@ -93,6 +104,8 @@ module Gosu
z, mode z, mode
) )
end end
angle += next_segment_angle
end end
end end
end end