samples/99_genre_arcade/sound_golf/app/main.rb
# Uses a label to display current level, and shows the score
# Creates a button to play the sample note, and displays the available notes that could be a potential match
Uses a label to display current level, and shows the score
Creates a button to play the sample note, and displays the available notes that could be a potential match
Uses a label to display current level and shows the score Creates a button to play the sample note and displays the available notes that could be a potential match
def render args
  args.outputs.labels << [args.grid.w_half, args.grid.top.shift_down(40), "Hole #{args.state.current_level} of 9", 0, 1, 0, 0, 0]
  render_score args 
  args.state.play_again_button ||= { x: 560, y: args.grid.h * 3 / 4 - 40, w: 160, h: 60, label: 'again' } 
  args.state.play_note_button ||= { x: 560, y: args.grid.h * 3 / 4 - 40, w: 160, h: 60, label: 'play' }
  if args.state.game_over 
    args.outputs.labels <<  [args.grid.w_half, args.grid.h * 3 / 4, "Play Again", 0, 1, 0, 0, 0] 
    args.outputs.borders << args.state.play_again_button 
  else 
    args.outputs.labels <<  [args.grid.w_half, args.grid.h * 3 / 4, "Play Note ##{args.state.current_level}", 0, 1, 0, 0, 0] 
    args.outputs.borders << args.state.play_note_button 
  end
  return if args.state.game_over 
  args.outputs.labels <<   [args.grid.w_half, 400, "I think the note is a(n)...",  0, 1, 0, 0, 0] 
  available_notes.each_with_index do |note, i|
    args.state.notes[i] ||= piano_button(args, note, i + 1) 
    args.outputs.labels <<   args.state.notes[i].label 
    args.outputs.borders <<  args.state.notes[i].border
  end
  args.outputs.solids << args.state.click_feedbacks.map { |c| c.solid }
end
def render args args . outputs . labels << [ args . grid . w_half , args . grid . top . shift_down ( 40 ) , "Hole #{args.state.current_level} of 9" , 0 , 1 , 0 , 0 , 0 ] render_score args args . state . play_again_button ||= { x : 560 , y : args . grid . h * 3 / 4 - 40 , w : 160 , h : 60 , label : 'again' } args . state . play_note_button ||= { x : 560 , y : args . grid . h * 3 / 4 - 40 , w : 160 , h : 60 , label : 'play' } if args . state . game_over args . outputs . labels << [ args . grid . w_half , args . grid . h * 3 / 4 , "Play Again" , 0 , 1 , 0 , 0 , 0 ] args . outputs . borders << args . state . play_again_button else args . outputs . labels << [ args . grid . w_half , args . grid . h * 3 / 4 , "Play Note ##{args.state.current_level}" , 0 , 1 , 0 , 0 , 0 ] args . outputs . borders << args . state . play_note_button end return if args . state . game_over args . outputs . labels << [ args . grid . w_half , 400 , "I think the note is a(n)..." , 0 , 1 , 0 , 0 , 0 ] available_notes . each_with_index do | note , i | args . state . notes [ i ] ||= piano_button ( args , note , i + 1 ) args . outputs . labels << args . state . notes [ i ] . label args . outputs . borders << args . state . notes [ i ] . border end args . outputs . solids << args . state . click_feedbacks . map { | c | c . solid } end
Uses a label to display current level, and shows the score
Creates a button to play the sample note, and displays the available notes that could be a potential match
Uses a label to display current level and shows the score Creates a button to play the sample note and displays the available notes that could be a potential match
# grid.w_half positions the label in the horizontal center of the screen. # shows score on screen # array definition, text/title # if game is over, a "play again" button is shown # Calculations ensure that Play Again label is displayed in center of border # Remove calculations from y parameters and see what happens to border and label placement # outputs label # outputs border # otherwise, if game is not over # Calculations ensure that label appears in center of border # outputs label # outputs border # return if game is over # outputs label # Shows all of the available notes that can be potential matches. # calls piano_button method on each note (creates label and border) # outputs note on screen with a label and a border # Shows whether or not the user is correct by filling the screen with either red or green
args