smalruby 0.0.22-x86-mingw32 → 0.0.23-x86-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of smalruby might be problematic. Click here for more details.
- checksums.yaml +4 -4
 - data/lib/smalruby/canvas.rb +1 -1
 - data/lib/smalruby/character.rb +91 -18
 - data/lib/smalruby/color.rb +2 -2
 - data/lib/smalruby/hardware/led.rb +4 -0
 - data/lib/smalruby/hardware/rgb_led_anode.rb +4 -0
 - data/lib/smalruby/hardware/rgb_led_cathode.rb +4 -0
 - data/lib/smalruby/hardware/sensor.rb +4 -0
 - data/lib/smalruby/hardware.rb +10 -0
 - data/lib/smalruby/stage.rb +5 -0
 - data/lib/smalruby/version.rb +1 -1
 - data/lib/smalruby/world.rb +1 -0
 - data/lib/smalruby.rb +8 -1
 - data/samples/canvas.rb +1 -1
 - data/samples/finding_cars.rb +5 -5
 - data/samples/pen.rb +38 -0
 - data/samples/pen2.rb +54 -0
 - data/samples/tree.rb +1 -1
 - metadata +4 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 78d19450dfa546889002c205ad81b0228d8e35d5
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 993ec64f69bed187fdd26ed33fcc04523bdcd2d3
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: aee92328282d3605d4a7e5c027472c65bfa50fd67faea81021cba381d2346fc0c82327ce43cfc70f83dd7d76eb07620e1e675362569d2da83bdf24896d3cc5f7
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 5d789d7a22c4b0c1242f1b800c16d8aa0b28c9e2767ee72acf3c7db32c79fadb3f909d4f515a34213f276502a1f34bd6904acfc2fe813c441f152f865f8a4f4e
         
     | 
    
        data/lib/smalruby/canvas.rb
    CHANGED
    
    
    
        data/lib/smalruby/character.rb
    CHANGED
    
    | 
         @@ -25,6 +25,8 @@ module Smalruby 
     | 
|
| 
       25 
25 
     | 
    
         
             
                attr_accessor :costumes
         
     | 
| 
       26 
26 
     | 
    
         
             
                attr_accessor :costume_index
         
     | 
| 
       27 
27 
     | 
    
         
             
                attr_reader :rotation_style
         
     | 
| 
      
 28 
     | 
    
         
            +
                attr_reader :enable_pen
         
     | 
| 
      
 29 
     | 
    
         
            +
                attr_accessor :pen_color
         
     | 
| 
       28 
30 
     | 
    
         | 
| 
       29 
31 
     | 
    
         
             
                def initialize(option = {})
         
     | 
| 
       30 
32 
     | 
    
         
             
                  defaults = {
         
     | 
| 
         @@ -47,6 +49,8 @@ module Smalruby 
     | 
|
| 
       47 
49 
     | 
    
         
             
                  @threads = []
         
     | 
| 
       48 
50 
     | 
    
         
             
                  @checking_hit_targets = []
         
     | 
| 
       49 
51 
     | 
    
         
             
                  @angle = 0 unless Util.windows?
         
     | 
| 
      
 52 
     | 
    
         
            +
                  @enable_pen = false
         
     | 
| 
      
 53 
     | 
    
         
            +
                  @pen_color = 'black'
         
     | 
| 
       50 
54 
     | 
    
         | 
| 
       51 
55 
     | 
    
         
             
                  self.scale_x = 1.0
         
     | 
| 
       52 
56 
     | 
    
         
             
                  self.scale_y = 1.0
         
     | 
| 
         @@ -75,8 +79,7 @@ module Smalruby 
     | 
|
| 
       75 
79 
     | 
    
         | 
| 
       76 
80 
     | 
    
         
             
                # (  )歩動かす
         
     | 
| 
       77 
81 
     | 
    
         
             
                def move(val = 1)
         
     | 
| 
       78 
     | 
    
         
            -
                  self.x  
     | 
| 
       79 
     | 
    
         
            -
                  self.y += @vector[:y] * val
         
     | 
| 
      
 82 
     | 
    
         
            +
                  self.position = [x + @vector[:x] * val, y + @vector[:y] * val]
         
     | 
| 
       80 
83 
     | 
    
         
             
                end
         
     | 
| 
       81 
84 
     | 
    
         | 
| 
       82 
85 
     | 
    
         
             
                # (  )歩後ろに動かす
         
     | 
| 
         @@ -84,6 +87,58 @@ module Smalruby 
     | 
|
| 
       84 
87 
     | 
    
         
             
                  move(-val)
         
     | 
| 
       85 
88 
     | 
    
         
             
                end
         
     | 
| 
       86 
89 
     | 
    
         | 
| 
      
 90 
     | 
    
         
            +
                # X座標を(  )にする
         
     | 
| 
      
 91 
     | 
    
         
            +
                def x=(val)
         
     | 
| 
      
 92 
     | 
    
         
            +
                  left = x + center_x
         
     | 
| 
      
 93 
     | 
    
         
            +
                  top = y + center_y
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
                  if val < 0
         
     | 
| 
      
 96 
     | 
    
         
            +
                    val = 0
         
     | 
| 
      
 97 
     | 
    
         
            +
                  elsif val + image.width >= Window.width
         
     | 
| 
      
 98 
     | 
    
         
            +
                    val = Window.width - image.width
         
     | 
| 
      
 99 
     | 
    
         
            +
                  end
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
                  super(val)
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
                  draw_pen(left, top, x + center_x, y + center_y) if @enable_pen
         
     | 
| 
      
 104 
     | 
    
         
            +
                end
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
                # Y座標を(  )にする
         
     | 
| 
      
 107 
     | 
    
         
            +
                def y=(val)
         
     | 
| 
      
 108 
     | 
    
         
            +
                  left = x + center_x
         
     | 
| 
      
 109 
     | 
    
         
            +
                  top = y + center_y
         
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
      
 111 
     | 
    
         
            +
                  if val < 0
         
     | 
| 
      
 112 
     | 
    
         
            +
                    val = 0
         
     | 
| 
      
 113 
     | 
    
         
            +
                  elsif val + image.height >= Window.height
         
     | 
| 
      
 114 
     | 
    
         
            +
                    val = Window.height - image.height
         
     | 
| 
      
 115 
     | 
    
         
            +
                  end
         
     | 
| 
      
 116 
     | 
    
         
            +
                  super(val)
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
                  draw_pen(left, top, x + center_x, y + center_y) if @enable_pen
         
     | 
| 
      
 119 
     | 
    
         
            +
                end
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
                # X座標を(  )、Y座標を(  )にする
         
     | 
| 
      
 122 
     | 
    
         
            +
                def position=(val)
         
     | 
| 
      
 123 
     | 
    
         
            +
                  if @enable_pen
         
     | 
| 
      
 124 
     | 
    
         
            +
                    @enable_pen = false
         
     | 
| 
      
 125 
     | 
    
         
            +
                    left = x + center_x
         
     | 
| 
      
 126 
     | 
    
         
            +
                    top = y + center_y
         
     | 
| 
      
 127 
     | 
    
         
            +
                    self.x = val[0]
         
     | 
| 
      
 128 
     | 
    
         
            +
                    self.y = val[1]
         
     | 
| 
      
 129 
     | 
    
         
            +
                    draw_pen(left, top, x + center_x, y + center_y)
         
     | 
| 
      
 130 
     | 
    
         
            +
                    @enable_pen = true
         
     | 
| 
      
 131 
     | 
    
         
            +
                  else
         
     | 
| 
      
 132 
     | 
    
         
            +
                    self.x = val[0]
         
     | 
| 
      
 133 
     | 
    
         
            +
                    self.y = val[1]
         
     | 
| 
      
 134 
     | 
    
         
            +
                  end
         
     | 
| 
      
 135 
     | 
    
         
            +
                end
         
     | 
| 
      
 136 
     | 
    
         
            +
             
     | 
| 
      
 137 
     | 
    
         
            +
                # X座標、Y座標
         
     | 
| 
      
 138 
     | 
    
         
            +
                def position
         
     | 
| 
      
 139 
     | 
    
         
            +
                  [x, y]
         
     | 
| 
      
 140 
     | 
    
         
            +
                end
         
     | 
| 
      
 141 
     | 
    
         
            +
             
     | 
| 
       87 
142 
     | 
    
         
             
                # くるっと振り返る
         
     | 
| 
       88 
143 
     | 
    
         
             
                def turn
         
     | 
| 
       89 
144 
     | 
    
         
             
                  sync_angle(@vector[:x] * -1, @vector[:y] * -1)
         
     | 
| 
         @@ -191,12 +246,16 @@ module Smalruby 
     | 
|
| 
       191 
246 
     | 
    
         
             
                  }
         
     | 
| 
       192 
247 
     | 
    
         
             
                  opts = process_optional_arguments(options, defaults)
         
     | 
| 
       193 
248 
     | 
    
         | 
| 
      
 249 
     | 
    
         
            +
                  message = opts[:message].to_s
         
     | 
| 
      
 250 
     | 
    
         
            +
                  return if message == @current_message
         
     | 
| 
      
 251 
     | 
    
         
            +
             
     | 
| 
      
 252 
     | 
    
         
            +
                  @current_message = message
         
     | 
| 
      
 253 
     | 
    
         
            +
             
     | 
| 
       194 
254 
     | 
    
         
             
                  if @balloon
         
     | 
| 
       195 
255 
     | 
    
         
             
                    @balloon.vanish
         
     | 
| 
       196 
256 
     | 
    
         
             
                    @balloon = nil
         
     | 
| 
       197 
257 
     | 
    
         
             
                  end
         
     | 
| 
       198 
258 
     | 
    
         | 
| 
       199 
     | 
    
         
            -
                  message = opts[:message].to_s
         
     | 
| 
       200 
259 
     | 
    
         
             
                  return if message.empty?
         
     | 
| 
       201 
260 
     | 
    
         | 
| 
       202 
261 
     | 
    
         
             
                  lines = message.to_s.lines.map { |l| l.scan(/.{1,10}/) }.flatten
         
     | 
| 
         @@ -222,7 +281,7 @@ module Smalruby 
     | 
|
| 
       222 
281 
     | 
    
         
             
                                    frame_size + margin_size + (font.size + 1) * row,
         
     | 
| 
       223 
282 
     | 
    
         
             
                                    line, font, [0, 0, 0])
         
     | 
| 
       224 
283 
     | 
    
         
             
                  end
         
     | 
| 
       225 
     | 
    
         
            -
                  @balloon = Sprite.new( 
     | 
| 
      
 284 
     | 
    
         
            +
                  @balloon = Sprite.new(x, y, image)
         
     | 
| 
       226 
285 
     | 
    
         
             
                end
         
     | 
| 
       227 
286 
     | 
    
         | 
| 
       228 
287 
     | 
    
         
             
                # 次のコスチュームにする
         
     | 
| 
         @@ -249,12 +308,12 @@ module Smalruby 
     | 
|
| 
       249 
308 
     | 
    
         | 
| 
       250 
309 
     | 
    
         
             
                # 左右の端に着いた?
         
     | 
| 
       251 
310 
     | 
    
         
             
                def reach_left_or_right_wall?
         
     | 
| 
       252 
     | 
    
         
            -
                   
     | 
| 
      
 311 
     | 
    
         
            +
                  x <= 0 || x >= (Window.width - image.width)
         
     | 
| 
       253 
312 
     | 
    
         
             
                end
         
     | 
| 
       254 
313 
     | 
    
         | 
| 
       255 
314 
     | 
    
         
             
                # 上下の端に着いた?
         
     | 
| 
       256 
315 
     | 
    
         
             
                def reach_top_or_bottom_wall?
         
     | 
| 
       257 
     | 
    
         
            -
                   
     | 
| 
      
 316 
     | 
    
         
            +
                  y <= 0 || y >= (Window.height - image.height)
         
     | 
| 
       258 
317 
     | 
    
         
             
                end
         
     | 
| 
       259 
318 
     | 
    
         | 
| 
       260 
319 
     | 
    
         
             
                def hit?(other)
         
     | 
| 
         @@ -265,6 +324,7 @@ module Smalruby 
     | 
|
| 
       265 
324 
     | 
    
         | 
| 
       266 
325 
     | 
    
         
             
                # @!group 音
         
     | 
| 
       267 
326 
     | 
    
         | 
| 
      
 327 
     | 
    
         
            +
                # (  )の音を鳴らす
         
     | 
| 
       268 
328 
     | 
    
         
             
                def play(option = {})
         
     | 
| 
       269 
329 
     | 
    
         
             
                  defaults = {
         
     | 
| 
       270 
330 
     | 
    
         
             
                    name: 'piano_do.wav'
         
     | 
| 
         @@ -276,6 +336,23 @@ module Smalruby 
     | 
|
| 
       276 
336 
     | 
    
         | 
| 
       277 
337 
     | 
    
         
             
                # @!endgroup
         
     | 
| 
       278 
338 
     | 
    
         | 
| 
      
 339 
     | 
    
         
            +
                # @!group ペン
         
     | 
| 
      
 340 
     | 
    
         
            +
             
     | 
| 
      
 341 
     | 
    
         
            +
                # ペンを下ろす
         
     | 
| 
      
 342 
     | 
    
         
            +
                def down_pen
         
     | 
| 
      
 343 
     | 
    
         
            +
                  @enable_pen = true
         
     | 
| 
      
 344 
     | 
    
         
            +
                end
         
     | 
| 
      
 345 
     | 
    
         
            +
             
     | 
| 
      
 346 
     | 
    
         
            +
                # ペンを上げる
         
     | 
| 
      
 347 
     | 
    
         
            +
                def up_pen
         
     | 
| 
      
 348 
     | 
    
         
            +
                  @enable_pen = false
         
     | 
| 
      
 349 
     | 
    
         
            +
                end
         
     | 
| 
      
 350 
     | 
    
         
            +
             
     | 
| 
      
 351 
     | 
    
         
            +
                # @!method pen_color=(val)
         
     | 
| 
      
 352 
     | 
    
         
            +
                # ペンの色を(  )にする
         
     | 
| 
      
 353 
     | 
    
         
            +
             
     | 
| 
      
 354 
     | 
    
         
            +
                # @!endgroup
         
     | 
| 
      
 355 
     | 
    
         
            +
             
     | 
| 
       279 
356 
     | 
    
         
             
                # @!group ハードウェア
         
     | 
| 
       280 
357 
     | 
    
         | 
| 
       281 
358 
     | 
    
         
             
                # LED
         
     | 
| 
         @@ -318,16 +395,6 @@ module Smalruby 
     | 
|
| 
       318 
395 
     | 
    
         
             
                def draw
         
     | 
| 
       319 
396 
     | 
    
         
             
                  draw_balloon
         
     | 
| 
       320 
397 
     | 
    
         | 
| 
       321 
     | 
    
         
            -
                  if self.x < 0
         
     | 
| 
       322 
     | 
    
         
            -
                    self.x = 0
         
     | 
| 
       323 
     | 
    
         
            -
                  elsif self.x + image.width >= Window.width
         
     | 
| 
       324 
     | 
    
         
            -
                    self.x = Window.width - image.width
         
     | 
| 
       325 
     | 
    
         
            -
                  end
         
     | 
| 
       326 
     | 
    
         
            -
                  if self.y < 0
         
     | 
| 
       327 
     | 
    
         
            -
                    self.y = 0
         
     | 
| 
       328 
     | 
    
         
            -
                  elsif self.y + image.height >= Window.height
         
     | 
| 
       329 
     | 
    
         
            -
                    self.y = Window.height - image.height
         
     | 
| 
       330 
     | 
    
         
            -
                  end
         
     | 
| 
       331 
398 
     | 
    
         
             
                  super
         
     | 
| 
       332 
399 
     | 
    
         
             
                end
         
     | 
| 
       333 
400 
     | 
    
         | 
| 
         @@ -453,6 +520,12 @@ module Smalruby 
     | 
|
| 
       453 
520 
     | 
    
         | 
| 
       454 
521 
     | 
    
         
             
                private
         
     | 
| 
       455 
522 
     | 
    
         | 
| 
      
 523 
     | 
    
         
            +
                def draw_pen(left, top, right, bottom)
         
     | 
| 
      
 524 
     | 
    
         
            +
                  world.current_stage.line(left: left, top: top,
         
     | 
| 
      
 525 
     | 
    
         
            +
                                           right: right, bottom: bottom,
         
     | 
| 
      
 526 
     | 
    
         
            +
                                           color: @pen_color)
         
     | 
| 
      
 527 
     | 
    
         
            +
                end
         
     | 
| 
      
 528 
     | 
    
         
            +
             
     | 
| 
       456 
529 
     | 
    
         
             
                def sync_angle(x, y)
         
     | 
| 
       457 
530 
     | 
    
         
             
                  a = Math.acos(x / Math.sqrt(x**2 + y**2)) * 180 / Math::PI
         
     | 
| 
       458 
531 
     | 
    
         
             
                  a = 360 - a if y < 0
         
     | 
| 
         @@ -482,13 +555,13 @@ module Smalruby 
     | 
|
| 
       482 
555 
     | 
    
         | 
| 
       483 
556 
     | 
    
         
             
                def draw_balloon
         
     | 
| 
       484 
557 
     | 
    
         
             
                  if @balloon
         
     | 
| 
       485 
     | 
    
         
            -
                    @balloon.x =  
     | 
| 
      
 558 
     | 
    
         
            +
                    @balloon.x = x + image.width / 2
         
     | 
| 
       486 
559 
     | 
    
         
             
                    if @balloon.x < 0
         
     | 
| 
       487 
560 
     | 
    
         
             
                      @balloon.x = 0
         
     | 
| 
       488 
561 
     | 
    
         
             
                    elsif @balloon.x + @balloon.image.width >= Window.width
         
     | 
| 
       489 
562 
     | 
    
         
             
                      @balloon.x = Window.width - @balloon.image.width
         
     | 
| 
       490 
563 
     | 
    
         
             
                    end
         
     | 
| 
       491 
     | 
    
         
            -
                    @balloon.y =  
     | 
| 
      
 564 
     | 
    
         
            +
                    @balloon.y = y - @balloon.image.height
         
     | 
| 
       492 
565 
     | 
    
         
             
                    if @balloon.y < 0
         
     | 
| 
       493 
566 
     | 
    
         
             
                      @balloon.y = 0
         
     | 
| 
       494 
567 
     | 
    
         
             
                    elsif @balloon.y + @balloon.image.height >= Window.height
         
     | 
    
        data/lib/smalruby/color.rb
    CHANGED
    
    | 
         @@ -155,8 +155,8 @@ module Smalruby 
     | 
|
| 
       155 
155 
     | 
    
         | 
| 
       156 
156 
     | 
    
         
             
                # Smalrubyの色名からDXRubyの色コードに変換する
         
     | 
| 
       157 
157 
     | 
    
         
             
                def smalruby_to_dxruby(color)
         
     | 
| 
       158 
     | 
    
         
            -
                  if color.is_a?(String)
         
     | 
| 
       159 
     | 
    
         
            -
                    color = color.downcase
         
     | 
| 
      
 158 
     | 
    
         
            +
                  if color.is_a?(String) || color.is_a?(Symbol)
         
     | 
| 
      
 159 
     | 
    
         
            +
                    color = color.to_s.downcase
         
     | 
| 
       160 
160 
     | 
    
         
             
                    if color == 'random'
         
     | 
| 
       161 
161 
     | 
    
         
             
                      [rand(0..0xff), rand(0..0xff), rand(0..0xff)]
         
     | 
| 
       162 
162 
     | 
    
         
             
                    elsif NAME_TO_CODE.key?(color)
         
     | 
    
        data/lib/smalruby/hardware.rb
    CHANGED
    
    | 
         @@ -46,6 +46,16 @@ module Smalruby 
     | 
|
| 
       46 
46 
     | 
    
         
             
                  @initialized_hardware = true
         
     | 
| 
       47 
47 
     | 
    
         
             
                end
         
     | 
| 
       48 
48 
     | 
    
         | 
| 
      
 49 
     | 
    
         
            +
                # ハードウェアを停止させる
         
     | 
| 
      
 50 
     | 
    
         
            +
                def stop
         
     | 
| 
      
 51 
     | 
    
         
            +
                  @hardware_cache.synchronize do
         
     | 
| 
      
 52 
     | 
    
         
            +
                    @hardware_cache.values.each do |h|
         
     | 
| 
      
 53 
     | 
    
         
            +
                      h.stop if h.respond_to?(:stop)
         
     | 
| 
      
 54 
     | 
    
         
            +
                    end
         
     | 
| 
      
 55 
     | 
    
         
            +
                    @hardware_cache.clear
         
     | 
| 
      
 56 
     | 
    
         
            +
                  end
         
     | 
| 
      
 57 
     | 
    
         
            +
                end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
       49 
59 
     | 
    
         
             
                # ハードウェアのインスタンスを生成する
         
     | 
| 
       50 
60 
     | 
    
         
             
                #
         
     | 
| 
       51 
61 
     | 
    
         
             
                # 作成したハードウェアのインスタンスはキャッシュする
         
     | 
    
        data/lib/smalruby/stage.rb
    CHANGED
    
    | 
         @@ -11,6 +11,11 @@ module Smalruby 
     | 
|
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
                  super(opts.reject { |k, _| defaults.keys.include?(k) })
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
      
 14 
     | 
    
         
            +
                  # HACK: ステージを一番最初に描画する
         
     | 
| 
      
 15 
     | 
    
         
            +
                  World.instance.objects.delete(self)
         
     | 
| 
      
 16 
     | 
    
         
            +
                  World.instance.objects.unshift(self)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  World.instance.current_stage = self
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
       14 
19 
     | 
    
         
             
                  fill(color: opts[:color])
         
     | 
| 
       15 
20 
     | 
    
         
             
                end
         
     | 
| 
       16 
21 
     | 
    
         
             
              end
         
     | 
    
        data/lib/smalruby/version.rb
    CHANGED
    
    
    
        data/lib/smalruby/world.rb
    CHANGED
    
    
    
        data/lib/smalruby.rb
    CHANGED
    
    | 
         @@ -25,7 +25,11 @@ module Smalruby 
     | 
|
| 
       25 
25 
     | 
    
         
             
                @started = true
         
     | 
| 
       26 
26 
     | 
    
         
             
                begin
         
     | 
| 
       27 
27 
     | 
    
         
             
                  if world.objects.any? { |o| /console/i !~ o.class.name }
         
     | 
| 
       28 
     | 
    
         
            -
                     
     | 
| 
      
 28 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 29 
     | 
    
         
            +
                      start_window_application
         
     | 
| 
      
 30 
     | 
    
         
            +
                    ensure
         
     | 
| 
      
 31 
     | 
    
         
            +
                      Hardware.stop
         
     | 
| 
      
 32 
     | 
    
         
            +
                    end
         
     | 
| 
       29 
33 
     | 
    
         
             
                  else
         
     | 
| 
       30 
34 
     | 
    
         
             
                    start_console_application
         
     | 
| 
       31 
35 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -114,6 +118,9 @@ module Smalruby 
     | 
|
| 
       114 
118 
     | 
    
         
             
                      end
         
     | 
| 
       115 
119 
     | 
    
         | 
| 
       116 
120 
     | 
    
         
             
                      if first
         
     | 
| 
      
 121 
     | 
    
         
            +
                        unless world.objects.any? { |o| o.is_a?(Stage) }
         
     | 
| 
      
 122 
     | 
    
         
            +
                          Stage.new(color: 'white')
         
     | 
| 
      
 123 
     | 
    
         
            +
                        end
         
     | 
| 
       117 
124 
     | 
    
         
             
                        world.objects.each do |object|
         
     | 
| 
       118 
125 
     | 
    
         
             
                          object.start
         
     | 
| 
       119 
126 
     | 
    
         
             
                        end
         
     | 
    
        data/samples/canvas.rb
    CHANGED
    
    | 
         @@ -4,6 +4,6 @@ require 'smalruby' 
     | 
|
| 
       4 
4 
     | 
    
         
             
            canvas1 = Canvas.new
         
     | 
| 
       5 
5 
     | 
    
         
             
            canvas1.on(:start) do
         
     | 
| 
       6 
6 
     | 
    
         
             
              draw_font(x: 0, y: 0, string: 'こんにちは', size: 32)
         
     | 
| 
       7 
     | 
    
         
            -
              line(x1: 0, y1: 100, x2: 100, y2: 200, color: " 
     | 
| 
      
 7 
     | 
    
         
            +
              line(x1: 0, y1: 100, x2: 100, y2: 200, color: "red")
         
     | 
| 
       8 
8 
     | 
    
         
             
              box_fill(left: 0, top: 300, right: 100, bottom: 400, color: "green")
         
     | 
| 
       9 
9 
     | 
    
         
             
            end
         
     | 
    
        data/samples/finding_cars.rb
    CHANGED
    
    | 
         @@ -1,12 +1,12 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # -*- coding: utf-8 -*-
         
     | 
| 
       2 
2 
     | 
    
         
             
            require "smalruby"
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
            canvas1 =  
     | 
| 
      
 4 
     | 
    
         
            +
            canvas1 = Stage.new(color: 'black')
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
            car1 = Character.new(x: 0, y: 148, costume: "car1.png", visible: false)
         
     | 
| 
       7 
     | 
    
         
            -
            car2 = Character.new(x: 639, y: 148, costume: "car2.png", visible: false)
         
     | 
| 
       8 
     | 
    
         
            -
            car3 = Character.new(x: 0, y: 348, costume: "car3.png", visible: false)
         
     | 
| 
       9 
     | 
    
         
            -
            car4 = Character.new(x: 639, y: 348, costume: "car4.png", visible: false)
         
     | 
| 
      
 6 
     | 
    
         
            +
            car1 = Character.new(x: 0, y: 148, costume: "car1.png", visible: false, rotation_style: :left_right)
         
     | 
| 
      
 7 
     | 
    
         
            +
            car2 = Character.new(x: 639, y: 148, costume: "car2.png", visible: false, rotation_style: :left_right)
         
     | 
| 
      
 8 
     | 
    
         
            +
            car3 = Character.new(x: 0, y: 348, costume: "car3.png", visible: false, rotation_style: :left_right)
         
     | 
| 
      
 9 
     | 
    
         
            +
            car4 = Character.new(x: 639, y: 348, costume: "car4.png", visible: false, rotation_style: :left_right)
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
11 
     | 
    
         
             
            canvas1.on(:start) do
         
     | 
| 
       12 
12 
     | 
    
         
             
              draw_font(x: 0, y: 0, string: "画面をクリックして隠れている車を4つ探してね", size: 32)
         
     | 
    
        data/samples/pen.rb
    ADDED
    
    | 
         @@ -0,0 +1,38 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'smalruby'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            car1 = Character.new(x: 0, y: 0, costume: 'car1.png', rotation_style: :left_right)
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            car1.on(:start) do
         
     | 
| 
      
 7 
     | 
    
         
            +
              loop do
         
     | 
| 
      
 8 
     | 
    
         
            +
                if enable_pen
         
     | 
| 
      
 9 
     | 
    
         
            +
                  say(message: 'ペンを下げる')
         
     | 
| 
      
 10 
     | 
    
         
            +
                else
         
     | 
| 
      
 11 
     | 
    
         
            +
                  say(message: 'ペンを上げる')
         
     | 
| 
      
 12 
     | 
    
         
            +
                end
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
            end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            car1.on(:click) do
         
     | 
| 
      
 17 
     | 
    
         
            +
              if enable_pen
         
     | 
| 
      
 18 
     | 
    
         
            +
                up_pen
         
     | 
| 
      
 19 
     | 
    
         
            +
              else
         
     | 
| 
      
 20 
     | 
    
         
            +
                down_pen
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
            end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            car1.on(:key_down, K_LEFT) do
         
     | 
| 
      
 25 
     | 
    
         
            +
              self.x -= 10
         
     | 
| 
      
 26 
     | 
    
         
            +
            end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            car1.on(:key_down, K_RIGHT) do
         
     | 
| 
      
 29 
     | 
    
         
            +
              self.x += 10
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            car1.on(:key_down, K_UP) do
         
     | 
| 
      
 33 
     | 
    
         
            +
              self.y -= 10
         
     | 
| 
      
 34 
     | 
    
         
            +
            end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
            car1.on(:key_down, K_DOWN) do
         
     | 
| 
      
 37 
     | 
    
         
            +
              self.y += 10
         
     | 
| 
      
 38 
     | 
    
         
            +
            end
         
     | 
    
        data/samples/pen2.rb
    ADDED
    
    | 
         @@ -0,0 +1,54 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'smalruby'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            car1 = Character.new(x: 0, y: 0, costume: 'car1.png', rotation_style: :free)
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            car1.on(:start) do
         
     | 
| 
      
 7 
     | 
    
         
            +
              loop do
         
     | 
| 
      
 8 
     | 
    
         
            +
                if enable_pen
         
     | 
| 
      
 9 
     | 
    
         
            +
                  say(message: 'ペンを下げる')
         
     | 
| 
      
 10 
     | 
    
         
            +
                else
         
     | 
| 
      
 11 
     | 
    
         
            +
                  say(message: 'ペンを上げる')
         
     | 
| 
      
 12 
     | 
    
         
            +
                end
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
            end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            car1.on(:click) do
         
     | 
| 
      
 17 
     | 
    
         
            +
              if enable_pen
         
     | 
| 
      
 18 
     | 
    
         
            +
                up_pen
         
     | 
| 
      
 19 
     | 
    
         
            +
              else
         
     | 
| 
      
 20 
     | 
    
         
            +
                down_pen
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
            end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            car1.on(:key_push, K_1) do
         
     | 
| 
      
 25 
     | 
    
         
            +
              self.pen_color = 'red'
         
     | 
| 
      
 26 
     | 
    
         
            +
            end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            car1.on(:key_push, K_2) do
         
     | 
| 
      
 29 
     | 
    
         
            +
              self.pen_color = 'blue'
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            car1.on(:key_push, K_3) do
         
     | 
| 
      
 33 
     | 
    
         
            +
              self.pen_color = 'green'
         
     | 
| 
      
 34 
     | 
    
         
            +
            end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
            car1.on(:key_push, K_4) do
         
     | 
| 
      
 37 
     | 
    
         
            +
              self.pen_color = 'black'
         
     | 
| 
      
 38 
     | 
    
         
            +
            end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
            car1.on(:key_down, K_LEFT) do
         
     | 
| 
      
 41 
     | 
    
         
            +
              rotate(-15)
         
     | 
| 
      
 42 
     | 
    
         
            +
            end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
            car1.on(:key_down, K_RIGHT) do
         
     | 
| 
      
 45 
     | 
    
         
            +
              rotate(15)
         
     | 
| 
      
 46 
     | 
    
         
            +
            end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
            car1.on(:key_down, K_UP) do
         
     | 
| 
      
 49 
     | 
    
         
            +
              move(30)
         
     | 
| 
      
 50 
     | 
    
         
            +
            end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            car1.on(:key_down, K_DOWN) do
         
     | 
| 
      
 53 
     | 
    
         
            +
              move(-30)
         
     | 
| 
      
 54 
     | 
    
         
            +
            end
         
     | 
    
        data/samples/tree.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: smalruby
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.23
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: x86-mingw32
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Kouji Takao
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2014- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2014-06-01 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -286,6 +286,8 @@ files: 
     | 
|
| 
       286 
286 
     | 
    
         
             
            - samples/hardware_servo.rb
         
     | 
| 
       287 
287 
     | 
    
         
             
            - samples/hardware_two_wheel_drive_car.rb
         
     | 
| 
       288 
288 
     | 
    
         
             
            - samples/hit_car.rb
         
     | 
| 
      
 289 
     | 
    
         
            +
            - samples/pen.rb
         
     | 
| 
      
 290 
     | 
    
         
            +
            - samples/pen2.rb
         
     | 
| 
       289 
291 
     | 
    
         
             
            - samples/piano.rb
         
     | 
| 
       290 
292 
     | 
    
         
             
            - samples/tree.rb
         
     | 
| 
       291 
293 
     | 
    
         
             
            - smalruby.gemspec
         
     |