class Smalruby::Stage

ステージを表現するクラス

Public Class Methods

new(options = {}) click to toggle source
Calls superclass method Smalruby::Canvas::new
# File lib/smalruby/stage.rb, line 5
def initialize(options = {})
  defaults = {
    color: 'white'
  }
  opts = Util.process_options(options, defaults)

  super(opts.reject { |k, _| defaults.keys.include?(k) })

  @background_color = opts[:color]

  # HACK: ステージを一番最初に描画する
  World.instance.objects.delete(self)
  World.instance.objects.unshift(self)
  World.instance.current_stage = self

  clear
end

Public Instance Methods

clear() click to toggle source

clear with background color or image

# File lib/smalruby/stage.rb, line 24
def clear
  fill(color: @background_color)
end