samples/07_advanced_rendering/03_render_target_viewports/app/main.rb
def keyboards_tech_demo
    outputs.labels << [460, row_to_px(0), "Current game time: #{state.tick_count}", small_font]
    outputs.labels << [460, row_to_px(2), "Keyboard input: inputs.keyboard.key_up.h", small_font]
    outputs.labels << [460, row_to_px(3), "Press \"h\" on the keyboard.", small_font]

    if inputs.keyboard.key_up.h # if "h" key_up event occurs
      state.h_pressed_at = state.tick_count # frame it occurred is stored
    end

    # h_pressed_at is initially set to false, and changes once the user presses the "h" key.
    state.h_pressed_at ||= false

    if state.h_pressed_at # if h is pressed (pressed_at has a frame number and is no longer false)
      outputs.labels << [460, row_to_px(4), "\"h\" was pressed at time: #{state.h_pressed_at}", small_font]
    else # otherwise, label says "h" was never pressed
      outputs.labels << [460, row_to_px(4), "\"h\" has never been pressed.", small_font]
    end

    # border around keyboard input demo section
    outputs.borders << [455, row_to_px(5), 360, row_to_px(2).shift_up(5) - row_to_px(5)]
  end
# Uses labels to output current game time (passage of time), and whether or not "h" was pressed
# If "h" is pressed, the frame is output when the key_up event occurred
Uses labels to output current game time (passage of time), and whether or not "h" was pressed
If "h" is pressed, the frame is output when the key_up event occurred
Uses labels to output current game time ( passage of time ) and whether or not " h " was pressed If " h " is pressed the frame is output when the key_up event occurred
def keyboards_tech_demo
    outputs.labels << [460, row_to_px(0), "Current game time: #{state.tick_count}", small_font]
    outputs.labels << [460, row_to_px(2), "Keyboard input: inputs.keyboard.key_up.h", small_font]
    outputs.labels << [460, row_to_px(3), "Press \"h\" on the keyboard.", small_font]
    if inputs.keyboard.key_up.h 
      state.h_pressed_at = state.tick_count 
    end
    state.h_pressed_at ||= false
    if state.h_pressed_at 
      outputs.labels << [460, row_to_px(4), "\"h\" was pressed at time: #{state.h_pressed_at}", small_font]
    else 
      outputs.labels << [460, row_to_px(4), "\"h\" has never been pressed.", small_font]
    end
    outputs.borders << [455, row_to_px(5), 360, row_to_px(2).shift_up(5) - row_to_px(5)]
  end
def keyboards_tech_demo outputs . labels << [ 460 , row_to_px ( 0 ) , "Current game time: #{state.tick_count}" , small_font ] outputs . labels << [ 460 , row_to_px ( 2 ) , "Keyboard input: inputs.keyboard.key_up.h" , small_font ] outputs . labels << [ 460 , row_to_px ( 3 ) , "Press \"h\" on the keyboard." , small_font ] if inputs . keyboard . key_up . h state . h_pressed_at = state . tick_count end state . h_pressed_at ||= false if state . h_pressed_at outputs . labels << [ 460 , row_to_px ( 4 ) , "\"h\" was pressed at time: #{state.h_pressed_at}" , small_font ] else outputs . labels << [ 460 , row_to_px ( 4 ) , "\"h\" has never been pressed." , small_font ] end outputs . borders << [ 455 , row_to_px ( 5 ) , 360 , row_to_px ( 2 ) . shift_up ( 5 ) - row_to_px ( 5 ) ] end
Uses labels to output current game time (passage of time), and whether or not "h" was pressed
If "h" is pressed, the frame is output when the key_up event occurred
Uses labels to output current game time ( passage of time ) and whether or not " h " was pressed If " h " is pressed the frame is output when the key_up event occurred
# if "h" key_up event occurs # frame it occurred is stored # h_pressed_at is initially set to false, and changes once the user presses the "h" key. # if h is pressed (pressed_at has a frame number and is no longer false) # otherwise, label says "h" was never pressed # border around keyboard input demo section