samples/02_input_basics/05_controller/app/main.rb
def render
    state.buttons.each do |b|
      rect = { x: b.x, y: b.y, w: 75, h: 75 }

      if b.active # if button is pressed
        outputs.solids << rect # rect is output as solid (filled in)
      else
        outputs.borders << rect # otherwise, output as border
      end

      # Outputs the text of each button using labels.
      outputs.labels << { x: b.x, y: b.y + 95, text: b.text } # add 95 to place label above button
    end

    outputs.labels << { x:  10, y: 60, text: "Left Analog x: #{inputs.controller_one.left_analog_x_raw} (#{inputs.controller_one.left_analog_x_perc * 100}%)" }
    outputs.labels << { x:  10, y: 30, text: "Left Analog y: #{inputs.controller_one.left_analog_y_raw} (#{inputs.controller_one.left_analog_y_perc * 100}%)" }
    outputs.labels << { x: 900, y: 60, text: "Right Analog x: #{inputs.controller_one.right_analog_x_raw} (#{inputs.controller_one.right_analog_x_perc * 100}%)" }
    outputs.labels << { x: 900, y: 30, text: "Right Analog y: #{inputs.controller_one.right_analog_y_raw} (#{inputs.controller_one.right_analog_y_perc * 100}%)" }
  end
# Gives each button a square shape.
# If the button is being pressed or held (which means it is considered active),
# the square is filled in. Otherwise, the button simply has a border.
Gives each button a square shape.
If the button is being pressed or held (which means it is considered active),
the square is filled in. Otherwise, the button simply has a border.
Gives each button a square shape . If the button is being pressed or held ( which means it is considered active ) the square is filled in . Otherwise the button simply has a border .
def render
    state.buttons.each do |b|
      rect = { x: b.x, y: b.y, w: 75, h: 75 }
      if b.active 
        outputs.solids << rect 
      else
        outputs.borders << rect 
      end
      outputs.labels << { x: b.x, y: b.y + 95, text: b.text } 
    end
    outputs.labels << { x:  10, y: 60, text: "Left Analog x: #{inputs.controller_one.left_analog_x_raw} (#{inputs.controller_one.left_analog_x_perc * 100}%)" }
    outputs.labels << { x:  10, y: 30, text: "Left Analog y: #{inputs.controller_one.left_analog_y_raw} (#{inputs.controller_one.left_analog_y_perc * 100}%)" }
    outputs.labels << { x: 900, y: 60, text: "Right Analog x: #{inputs.controller_one.right_analog_x_raw} (#{inputs.controller_one.right_analog_x_perc * 100}%)" }
    outputs.labels << { x: 900, y: 30, text: "Right Analog y: #{inputs.controller_one.right_analog_y_raw} (#{inputs.controller_one.right_analog_y_perc * 100}%)" }
  end
def render state . buttons . each do | b | rect = { x : b . x , y : b . y , w : 75 , h : 75 } if b . active outputs . solids << rect else outputs . borders << rect end outputs . labels << { x : b . x , y : b . y + 95 , text : b . text } end outputs . labels << { x : 10 , y : 60 , text : "Left Analog x: #{inputs.controller_one.left_analog_x_raw} (#{inputs.controller_one.left_analog_x_perc * 100}%)" } outputs . labels << { x : 10 , y : 30 , text : "Left Analog y: #{inputs.controller_one.left_analog_y_raw} (#{inputs.controller_one.left_analog_y_perc * 100}%)" } outputs . labels << { x : 900 , y : 60 , text : "Right Analog x: #{inputs.controller_one.right_analog_x_raw} (#{inputs.controller_one.right_analog_x_perc * 100}%)" } outputs . labels << { x : 900 , y : 30 , text : "Right Analog y: #{inputs.controller_one.right_analog_y_raw} (#{inputs.controller_one.right_analog_y_perc * 100}%)" } end
Gives each button a square shape.
Gives each button a square shape .
# if button is pressed # rect is output as solid (filled in) # otherwise, output as border # Outputs the text of each button using labels. # add 95 to place label above button