Last active
December 17, 2015 06:39
-
-
Save bucketh3ad/5566850 to your computer and use it in GitHub Desktop.
A small part of the inventory refactor for journey to hawkthorne -bucketh3ad
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEFORE: | |
function Inventory:keypressed( button ) | |
if self:isOpen() then | |
if button == 'SELECT' then | |
self:close() | |
end | |
if button == 'RIGHT' then | |
self:right() | |
end | |
if button == 'LEFT' then | |
self:left() | |
end | |
if button == 'UP' then | |
self:up() | |
end | |
if button == 'DOWN' then | |
self:down() | |
end | |
if button == 'ATTACK' then | |
self:select() | |
end | |
end | |
end | |
AFTER: | |
--- | |
-- Handles player input while in the inventory | |
-- @return nil | |
function Inventory:keypressed( button ) | |
local keys = { | |
RIGHT = self.right, | |
LEFT = self.left, | |
UP = self.up, | |
DOWN = self.down, | |
ATTACK = self.select, | |
SELECT = self.close | |
} | |
if self:isOpen() and keys[button] ~= nil then keys[button]() end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment