samples/99_genre_rpg_narrative/choose_your_own_adventure/app/main.rb
def tick args
  if !args.state.loaded && !respond_to?(:game) # if game is not loaded and not responding to game symbol's method
    args.labels << [640, 370, 'Hey there! Welcome to Four Decisions.', 0, 1] # a welcome label is shown
    args.labels << [640, 340, 'Go to the file called decision.rb and tell me your story.', 0, 1]
  elsif respond_to?(:game) # otherwise, if responds to game
    args.state.loaded = true
    tick_game args # calls tick_game method, runs game
  end

  if args.state.tick_count.mod_zero? 60 # update every 60 frames
    t = args.gtk.ffi_file.mtime GAME_FILE # mtime returns modification time for named file
    if t != args.state.mtime
      args.state.mtime = t
      require GAME_FILE # require used to load file
      args.state.game_definition = nil # game definition and decision are empty
      args.state.decision_id = nil
    end
  end
end
# Instructions are given using labels to users if they have not yet set up their story in the decision.rb file.
# Otherwise, the game is run.
Instructions are given using labels to users if they have not yet set up their story in the decision.rb file.
Otherwise, the game is run.
Instructions are given using labels to users if they have not yet set up their story in the decision . rb file . Otherwise the game is run .
def tick args
  if !args.state.loaded && !respond_to?(:game) 
    args.labels << [640, 370, 'Hey there! Welcome to Four Decisions.', 0, 1] 
    args.labels << [640, 340, 'Go to the file called decision.rb and tell me your story.', 0, 1]
  elsif respond_to?(:game) 
    args.state.loaded = true
    tick_game args 
  end
  if args.state.tick_count.mod_zero? 60 
    t = args.gtk.ffi_file.mtime GAME_FILE 
    if t != args.state.mtime
      args.state.mtime = t
      require GAME_FILE 
      args.state.game_definition = nil 
      args.state.decision_id = nil
    end
  end
end
def tick args if ! args . state . loaded && ! respond_to? ( :game ) args . labels << [ 640 , 370 , 'Hey there! Welcome to Four Decisions.' , 0 , 1 ] args . labels << [ 640 , 340 , 'Go to the file called decision.rb and tell me your story.' , 0 , 1 ] elsif respond_to? ( :game ) args . state . loaded = true tick_game args end if args . state . tick_count . mod_zero? 60 t = args . gtk . ffi_file . mtime GAME_FILE if t != args . state . mtime args . state . mtime = t require GAME_FILE args . state . game_definition = nil args . state . decision_id = nil end end end
Instructions are given using labels to users if they have not yet set up their story in the decision.rb file.
Instructions are given using labels to users if they have not yet set up their story in the decision . rb file .
# if game is not loaded and not responding to game symbol's method # a welcome label is shown # otherwise, if responds to game # calls tick_game method, runs game # update every 60 frames # mtime returns modification time for named file # require used to load file # game definition and decision are empty
args