samples/04_physics_and_collisions/05_box_collision_2/app/main.rb
def process_inputs_player_movement
    # Sets dx to 0 if the player lets go of arrow keys (player won't move left or right)
    if inputs.keyboard.key_up.right
      state.dx = 0
    elsif inputs.keyboard.key_up.left
      state.dx = 0
    end

    # Sets dx to 3 in whatever direction the player chooses when they hold down (or press) the left or right keys
    if inputs.keyboard.key_held.right
      state.dx =  3
    elsif inputs.keyboard.key_held.left
      state.dx = -3
    end

    # Sets dy to 5 to make the player ~fly~ when they press the space bar on their keyboard
    if inputs.keyboard.key_held.space
      state.dy = 5
    end
  end
# Moves the player based on the keys they press on their keyboard
Moves the player based on the keys they press on their keyboard
Moves the player based on the keys they press on their keyboard
def process_inputs_player_movement
    if inputs.keyboard.key_up.right
      state.dx = 0
    elsif inputs.keyboard.key_up.left
      state.dx = 0
    end
    if inputs.keyboard.key_held.right
      state.dx =  3
    elsif inputs.keyboard.key_held.left
      state.dx = -3
    end
    if inputs.keyboard.key_held.space
      state.dy = 5
    end
  end
def process_inputs_player_movement if inputs . keyboard . key_up . right state . dx = 0 elsif inputs . keyboard . key_up . left state . dx = 0 end if inputs . keyboard . key_held . right state . dx = 3 elsif inputs . keyboard . key_held . left state . dx = - 3 end if inputs . keyboard . key_held . space state . dy = 5 end end
Moves the player based on the keys they press on their keyboard
Moves the player based on the keys they press on their keyboard
# Sets dx to 0 if the player lets go of arrow keys (player won't move left or right) # Sets dx to 3 in whatever direction the player chooses when they hold down (or press) the left or right keys # Sets dy to 5 to make the player ~fly~ when they press the space bar on their keyboard