summaryrefslogtreecommitdiff
path: root/src/gnu_and_bola_brawlers/keypressed/default.lua
blob: 07bb9bf91dcb67333f930fe622fcbb6a26b121b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
local keypressed = {}

keypressed.trigger = function(character, images, metaSprite, controller, key, scancode)
  if scancode == controller.quit then
    love.event.quit()
  end

  if scancode == controller.a  then
    character.actionA = true
    character.actionDown = false
    character.actionUp = false
    metaSprite = character.jump
  end

  if scancode == controller.left then
    character.actionLeft = true
  end

  if scancode == controller.right then
    character.actionRight = true
  end

  if scancode == controller.up and character.jump.isJumping == false then
    character.actionUp = true
  end

  if scancode == controller.down and character.jump.isJumping == false then
    character.actionDown = true
  end

  return metaSprite
end

return keypressed