samples/99_genre_rpg_topdown/topdown_starting_point/app/main.rb
# Sets values of tile size and player's movement speed
# Also creates tile or box for player and generates map
Sets values of tile size and player's movement speed
Also creates tile or box for player and generates map
Sets values of tile size and player ' s movement speed Also creates tile or box for player and generates map
def tick args
  args.state.tile_size     = 80
  args.state.player_speed  = 4
  args.state.player      ||= tile(args, 7, 3, 0, 128, 180)
  generate_map args
  args.outputs.solids << args.state.walls
  args.outputs.solids << args.state.goal
  args.outputs.solids << args.state.player
  if args.state.player.intersect_rect? args.state.goal
    args.outputs.labels << [30, 720 - 30, "You're a wizard Harry!!"] 
  end
  move_player args, -1,  0 if args.inputs.keyboard.left 
  move_player args,  1,  0 if args.inputs.keyboard.right 
  move_player args,  0,  1 if args.inputs.keyboard.up 
  move_player args,  0, -1 if args.inputs.keyboard.down 
end
def tick args args . state . tile_size = 80 args . state . player_speed = 4 args . state . player ||= tile ( args , 7 , 3 , 0 , 128 , 180 ) generate_map args args . outputs . solids << args . state . walls args . outputs . solids << args . state . goal args . outputs . solids << args . state . player if args . state . player . intersect_rect? args . state . goal args . outputs . labels << [ 30 , 720 - 30 , "You're a wizard Harry!!" ] end move_player args , - 1 , 0 if args . inputs . keyboard . left move_player args , 1 , 0 if args . inputs . keyboard . right move_player args , 0 , 1 if args . inputs . keyboard . up move_player args , 0 , - 1 if args . inputs . keyboard . down end
Sets values of tile size and player's movement speed
Also creates tile or box for player and generates map
Sets values of tile size and player ' s movement speed Also creates tile or box for player and generates map
# Adds walls, goal, and player to args.outputs.solids so they appear on screen # If player's box intersects with goal, a label is output onto the screen # 30 pixels lower than top of screen # x position decreases by 1 if left key is pressed # x position increases by 1 if right key is pressed # y position increases by 1 if up is pressed # y position decreases by 1 if down is pressed
args