diff options
author | Aki <nthirtyone@gmail.com> | 2017-04-07 21:05:41 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2017-04-07 21:05:41 +0200 |
commit | 1c3040de93f9d5a164ccb06194eacc28eead0234 (patch) | |
tree | 3d953fb9b7813a810613cd102e444033a9ddbf1d /iconsList.lua | |
parent | 612a14474c9d3c28b6512aef4845e52579d7d9c9 (diff) | |
download | roflnauts-1c3040de93f9d5a164ccb06194eacc28eead0234.zip roflnauts-1c3040de93f9d5a164ccb06194eacc28eead0234.tar.gz roflnauts-1c3040de93f9d5a164ccb06194eacc28eead0234.tar.bz2 |
Maps and nauts list moved to config
Implemented functions to create icons list for them
Changed so game uses these functions now
Diffstat (limited to 'iconsList.lua')
-rw-r--r-- | iconsList.lua | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/iconsList.lua b/iconsList.lua new file mode 100644 index 0000000..4a384dc --- /dev/null +++ b/iconsList.lua @@ -0,0 +1,37 @@ +-- TODO: These should be part of non-existent AssetsManager or something similar. +local function testAvoidList (i, avoidList) + for key,value in pairs(avoidList) do + if i == value then + table.remove(avoidList, key) + return false + end + end + return true +end + +function createIconsList (sheetWidth, sheetHeight, iconWidth, keysList, avoidList) + local avoidList = avoidList or {} + local iconsList, newKeysList = {}, {} + local iconsNumber = math.floor(sheetWidth / iconWidth) + local iconHeight = sheetHeight + for i=1,iconsNumber do + if testAvoidList(i, avoidList) then + iconsList[keysList[i]] = love.graphics.newQuad((i-1)*iconWidth, 0, iconWidth, iconHeight, sheetWidth, sheetHeight) + table.insert(newKeysList, keysList[i]) + end + end + return iconsList, newKeysList +end + +function getNautsIconsList (avoidList) + local avoidList = avoidList or {32,33,34,35,36} + local keysList = require "config.nauts" + local iconsList, newKeysList = createIconsList(1008, 27, 28, keysList, avoidList) + return iconsList, newKeysList +end + +function getMapsIconsList (avoidList) + local keysList = require "config.maps" + local iconsList, newKeysList = createIconsList(532, 37, 76, keysList, avoidList) + return iconsList, newKeysList +end |