summaryrefslogtreecommitdiff
path: root/src/gnu_and_bola_brawlers/keypressed/trigger.lua
blob: abba1cc4d0cd3fc4fe46141f0d226a732d8319d7 (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
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 = require '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
end

return keypressed