@particles.each do |particle|
(1..MOTION_BLUR).each do |i|
xoffset = i*MOTION_BLUR_OFFSET*0.4
yoffset = i*particle[:vy]*MOTION_DT
alpha = ((1.0 - i.to_f/MOTION_BLUR)*MOTION_BLUR_ALPHA).to_i
@particle.draw particle[:x]-@particle.width-xoffset, particle[:y]-@particle.height-yoffset, 0, 1, 1, Gosu::Color.new(alpha,255,255,255)
end
@particle.draw particle[:x]-@particle.width, particle[:y]-@particle.height, 0
end
Float
s are still an issue (they should be immediate objects on 64-bit Ruby 2.0, right?), but the Gosu::Color
is definitely causing trouble. Quick loop refactoring: (1..MOTION_BLUR).each do |i|
xoffset = i*MOTION_BLUR_OFFSET*0.4
alpha = ((1.0 - i.to_f/MOTION_BLUR)*MOTION_BLUR_ALPHA).to_i
color = Gosu::Color.new(alpha,255,255,255)
@particles.each do |particle|
yoffset = i*particle[:vy]*MOTION_DT
@particle.draw particle[:x]-@particle.width-xoffset, particle[:y]-@particle.height-yoffset, 0, 1, 1, color
end
end
@particles.each do |particle|
@particle.draw particle[:x]-@particle.width, particle[:y]-@particle.height, 0
end
Float
s in Ruby 2.0 on 64-bit are a big step forward. Now it's mostly Gosu::Color
that is dangerous, and you can often use 0xaarrggbb constants (only a little bit horrid).
self.caption = Gosu::fps.to_s
is your friend ;)
Gosu::fps
function? I wrote a code just to do that ;_;
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill