samples/99_genre_fighting/01_special_move_inputs/app/main.rb
# Performs calculations to move objects on the screen
Performs calculations to move objects on the screen
Performs calculations to move objects on the screen
def calc args
  args.state.player.x  += args.state.player.dx
  args.state.player.y  += args.state.player.dy
  args.state.player.dy += args.state.gravity
  args.state.player.y  = args.state.player.y.greater(args.state.bridge_top)
  args.state.player.x  = args.state.player.x.greater(0)
  args.state.player.falling = false if args.state.player.y == args.state.bridge_top
end
def calc args args . state . player . x += args . state . player . dx args . state . player . y += args . state . player . dy args . state . player . dy += args . state . gravity args . state . player . y = args . state . player . y . greater ( args . state . bridge_top ) args . state . player . x = args . state . player . x . greater ( 0 ) args . state . player . falling = false if args . state . player . y == args . state . bridge_top end
Performs calculations to move objects on the screen
Performs calculations to move objects on the screen
# Since velocity is the change in position, the change in x increases by dx. Same with y and dy. # Since acceleration is the change in velocity, the change in y (dy) increases every frame # player's y position is either current y position or y position of top of # bridge, whichever has a greater value # ensures that the player never goes below the bridge # player's x position is either the current x position or 0, whichever has a greater value # ensures that the player doesn't go too far left (out of the screen's scope) # player is not falling if it is located on the top of the bridge #args.state.player.rect = [args.state.player.x, args.state.player.y, args.state.player.h, args.state.player.w] # sets definition for player
args