Sha256: f36fd4f81cf532aa6cbb2147d15637f6886eb9417701a4ac53ff68fe9aae6238

Contents?: true

Size: 622 Bytes

Versions: 8

Compression:

Stored size: 622 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')

  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_with_pullup.rb
smalruby-0.1.0 samples/hardware_button_with_pullup.rb
smalruby-0.0.32-x86-mingw32 samples/hardware_button_with_pullup.rb
smalruby-0.0.32 samples/hardware_button_with_pullup.rb
smalruby-0.0.31-x86-mingw32 samples/hardware_button_with_pullup.rb
smalruby-0.0.31 samples/hardware_button_with_pullup.rb
smalruby-0.0.30-x86-mingw32 samples/hardware_button_with_pullup.rb
smalruby-0.0.30 samples/hardware_button_with_pullup.rb