Class: Smalruby::Stage
- 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, #volume
Instance Method Summary collapse
-
#clear ⇒ Object
clear with background color or image.
-
#initialize(options = {}) ⇒ Stage
constructor
A new instance of Stage.
Methods inherited from Canvas
#box, #box_fill, #circle, #circle_fill, #draw_font, #fill, #line
Methods inherited from Character
#alive?, #angle, #angle=, #await, #button, #change_pen_color_by, #click, #distance, #down_pen, #draw, #go_to, #hit, #hit?, #join, #key_down, #key_push, #led, #loop, #motor_driver, #move, #move_back, #neo_pixel, #next_costume, #on, #pen_shade=, #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, #servo, #smalrubot_s1, #smalrubot_v3, #start, #switch_costume, #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 21 22 |
# File 'lib/smalruby/stage.rb', line 6 def initialize( = {}) defaults = { color: 'white' } opts = Util.(, 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 |
Instance Method Details
#clear ⇒ Object
clear with background color or image
25 26 27 |
# File 'lib/smalruby/stage.rb', line 25 def clear fill(color: @background_color) end |