Sha256: d34bc4578aa154da8e13cf543a46562bccf3dcc61617862bdb2323421d9f7fba

Contents?: true

Size: 630 Bytes

Versions: 8

Compression:

Stored size: 630 Bytes

Contents

# -*- coding: utf-8 -*-

DESCRIPTION = <<EOS
ハードウェアのボタンを操作します
EOS

# デジタルの3番ピンにボタンを接続してください。

require 'smalruby'

init_hardware

stage1 = Stage.new(color: 'white')
frog1 = Character.new(costume: 'frog1.png', x: 300, y: 200, visible: false)

stage1.on(:start) do
  draw_font(string: DESCRIPTION, color: 'black')

  button('D3').not_use_pullup

  if button('D3').up?
    frog1.visible = false
  else
    frog1.visible = true
  end
end

stage1.on(:button_down, 'D3') do
  frog1.visible = true
end

stage1.on(:button_up, 'D3') do
  frog1.visible = false
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
smalruby-0.1.0-x86-mingw32 samples/hardware_button.rb
smalruby-0.1.0 samples/hardware_button.rb
smalruby-0.0.32-x86-mingw32 samples/hardware_button.rb
smalruby-0.0.32 samples/hardware_button.rb
smalruby-0.0.31-x86-mingw32 samples/hardware_button.rb
smalruby-0.0.31 samples/hardware_button.rb
smalruby-0.0.30-x86-mingw32 samples/hardware_button.rb
smalruby-0.0.30 samples/hardware_button.rb