samples/99_genre_rpg_topdown/topdown_starting_point/app/main.rb
def move_player args, *vector
  box = args.state.player.shift_rect(vector) # box is able to move at an angle

  # If the player's box hits a wall, it is not able to move further in that direction
  return if args.state.walls
                .any_intersect_rect?(box)

  # Player's box is able to move at angles (not just the four general directions) fast
  args.state.player =
    args.state.player
        .shift_rect(vector.x * args.state.player_speed, # if we don't multiply by speed, then
                    vector.y * args.state.player_speed) # the box will move extremely slow
end
# Allows the player to move their box around the screen
Allows the player to move their box around the screen
Allows the player to move their box around the screen
def move_player args, *vector
  box = args.state.player.shift_rect(vector) 
  return if args.state.walls
                .any_intersect_rect?(box)
  args.state.player =
    args.state.player
        .shift_rect(vector.x * args.state.player_speed, 
                    vector.y * args.state.player_speed) 
end
def move_player args , * vector box = args . state . player . shift_rect ( vector ) return if args . state . walls . any_intersect_rect? ( box ) args . state . player = args . state . player . shift_rect ( vector . x * args . state . player_speed , vector . y * args . state . player_speed ) end
Allows the player to move their box around the screen
Allows the player to move their box around the screen
# box is able to move at an angle # If the player's box hits a wall, it is not able to move further in that direction # Player's box is able to move at angles (not just the four general directions) fast # if we don't multiply by speed, then # the box will move extremely slow
args
vector