samples/04_physics_and_collisions/05_box_collision_2/app/main.rb
def calc_player
    state.dy += state.gravity  # what goes up must come down because of gravity
    calc_box_collision
    calc_edge_collision
    state.y  += state.dy       # Since velocity is the change in position, the change in y increases by dy
    state.x  += state.dx       # Ditto line above but dx and x
    state.dx *= 0.8            # Scales dx down
  end
# Calculates movement of player and calls methods that perform collision calculations
Calculates movement of player and calls methods that perform collision calculations
Calculates movement of player and calls methods that perform collision calculations
def calc_player
    state.dy += state.gravity  
    calc_box_collision
    calc_edge_collision
    state.y  += state.dy       
    state.x  += state.dx       
    state.dx *= 0.8            
  end
def calc_player state . dy += state . gravity calc_box_collision calc_edge_collision state . y += state . dy state . x += state . dx state . dx *= 0.8 end
Calculates movement of player and calls methods that perform collision calculations
Calculates movement of player and calls methods that perform collision calculations
# what goes up must come down because of gravity # Since velocity is the change in position, the change in y increases by dy # Ditto line above but dx and x # Scales dx down