Class: Smalruby::Stage

Inherits:
Canvas show all
Defined in:
lib/smalruby/stage.rb

Overview

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

Instance Attribute Summary

Attributes inherited from Character

#checking_hit_targets, #costume_index, #costumes, #enable_pen, #event_handlers, #pen_color, #rotation_style, #threads

Instance Method Summary collapse

Methods inherited from Canvas

#box, #box_fill, #circle, #circle_fill, #draw_font, #fill, #line

Methods inherited from Character

#alive?, #angle, #angle=, #await, #button, #button_down, #button_up, #click, #distance, #down_pen, #draw, #go_to, #hit, #hit?, #join, #key_down, #key_push, #led, #loop, #motor_driver, #move, #move_back, #next_costume, #on, #play, #point_towards, #position, #position=, #reach_left_or_right_wall?, #reach_top_or_bottom_wall?, #reach_wall?, #rgb_led_anode, #rgb_led_cathode, #rotate, #say, #sensor, #sensor_change, #servo, #start, #turn, #turn_if_reach_wall, #turn_x, #turn_y, #two_wheel_drive_car, #up_pen, #visible=, #x=, #y=

Constructor Details

#initialize(options = {}) ⇒ Stage

Returns a new instance of Stage.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/smalruby/stage.rb', line 6

def initialize(options = {})
  defaults = {
    color: 'white'
  }
  opts = Util.process_options(options, defaults)

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

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

  fill(color: opts[:color])
end