插入Main前即可 需要别的特技自己加
class Object def tap yield self return self end end class << Color def white new 255, 255, 255 end def empty new 0, 0, 0, 0 end end class Bitmap def clear_rect *a fill_rect case a.size when 1 then a[0] when 4 then a end, Color.empty end end def sign i, b = true i > 0 ? 1 : b ? i < 0 ? -1 : 0 : i == 0 ? 1 : -1 end def dbfd a, b, c (a - b).abs < c ? sign(a - b) : (a - b) / c end def center obj obj.x = 320 - obj.src_rect.width / 2 obj.y = 240 - obj.src_rect.height / 2 obj end def sprite_with bitmap, x, y, w, h Sprite.new.tap { |s| s.bitmap = bitmap s.src_rect = Rect.new x, y, w, h } end def white_block w, h sprite_with Bitmap.new(w, h).tap { |b| b.fill_rect b.rect, Color.white }, 0, 0, w, h end 雪碧条 = center white_block 320, 24 雪碧条.src_rect.width = 0 loop do Graphics.update Input.update break if 雪碧条.src_rect.width == 320 雪碧条.src_rect.width += dbfd 320, 雪碧条.src_rect.width, 9 end 雪碧条.bitmap.dispose 雪碧条.dispose
class Object
def tap
yield self
return self
end
end
class << Color
def white
new 255, 255, 255
end
def empty
new 0, 0, 0, 0
end
end
class Bitmap
def clear_rect *a
fill_rect case a.size
when 1 then a[0]
when 4 then a
end, Color.empty
end
end
def sign i, b = true
i > 0 ? 1 : b ? i < 0 ? -1 : 0 : i == 0 ? 1 : -1
end
def dbfd a, b, c
(a - b).abs < c ? sign(a - b) : (a - b) / c
end
def center obj
obj.x = 320 - obj.src_rect.width / 2
obj.y = 240 - obj.src_rect.height / 2
obj
end
def sprite_with bitmap, x, y, w, h
Sprite.new.tap { |s|
s.bitmap = bitmap
s.src_rect = Rect.new x, y, w, h
}
end
def white_block w, h
sprite_with Bitmap.new(w, h).tap { |b|
b.fill_rect b.rect, Color.white
}, 0, 0, w, h
end
雪碧条 = center white_block 320, 24
雪碧条.src_rect.width = 0
loop do
Graphics.update
Input.update
break if 雪碧条.src_rect.width == 320
雪碧条.src_rect.width += dbfd 320, 雪碧条.src_rect.width, 9
end
雪碧条.bitmap.dispose
雪碧条.dispose
|