samples/99_genre_arcade/twinstick/app/main.rb
def shoot_directional_vector args
  dx = 0
  dx += 1 if args.inputs.keyboard.key_down.right || args.inputs.keyboard.key_held.right
  dx -= 1 if args.inputs.keyboard.key_down.left || args.inputs.keyboard.key_held.left
  dy = 0
  dy += 1 if args.inputs.keyboard.key_down.up || args.inputs.keyboard.key_held.up
  dy -= 1 if args.inputs.keyboard.key_down.down || args.inputs.keyboard.key_held.down
  if dx != 0 && dy != 0
    dx *= 0.7071
    dy *= 0.7071
  end
  [dx, dy]
end
# Custom function for getting a directional vector just for shooting using the arrow keys
Custom function for getting a directional vector just for shooting using the arrow keys
Custom function for getting a directional vector just for shooting using the arrow keys
def shoot_directional_vector args
  dx = 0
  dx += 1 if args.inputs.keyboard.key_down.right || args.inputs.keyboard.key_held.right
  dx -= 1 if args.inputs.keyboard.key_down.left || args.inputs.keyboard.key_held.left
  dy = 0
  dy += 1 if args.inputs.keyboard.key_down.up || args.inputs.keyboard.key_held.up
  dy -= 1 if args.inputs.keyboard.key_down.down || args.inputs.keyboard.key_held.down
  if dx != 0 && dy != 0
    dx *= 0.7071
    dy *= 0.7071
  end
  [dx, dy]
end
def shoot_directional_vector args dx = 0 dx += 1 if args . inputs . keyboard . key_down . right || args . inputs . keyboard . key_held . right dx -= 1 if args . inputs . keyboard . key_down . left || args . inputs . keyboard . key_held . left dy = 0 dy += 1 if args . inputs . keyboard . key_down . up || args . inputs . keyboard . key_held . up dy -= 1 if args . inputs . keyboard . key_down . down || args . inputs . keyboard . key_held . down if dx != 0 && dy != 0 dx *= 0.7071 dy *= 0.7071 end [ dx , dy ] end
Custom function for getting a directional vector just for shooting using the arrow keys
Custom function for getting a directional vector just for shooting using the arrow keys
args