Update main.lua
This commit is contained in:
1 parent
473cbcb82f
commit
8fe5a482f3
1 file changed
+24
-3
@@ -4,9 +4,26 @@ local utility = require "lib.utility"
|
||||
|
||||
local window_width, window_height = love.graphics.getDimensions()
|
||||
|
||||
local tiles
|
||||
local tiles, tiles_json, tile_image
|
||||
local current_text = ""
|
||||
|
||||
local get_tile_usage = function(tiles_json, tile_image)
|
||||
local image_width, image_height = tile_image:getDimensions()
|
||||
local tile_usage = {}
|
||||
for x = 1, image_width / tiles_json.tile_size do
|
||||
tile_usage[x] = {}
|
||||
for y = 1, image_height / tiles_json.tile_size do
|
||||
tile_usage[x][y] = false
|
||||
end
|
||||
end
|
||||
|
||||
for name, tile_data in pairs(tiles_json.tiles) do
|
||||
tile_usage[tile_data.x][tile_data.y] = true
|
||||
end
|
||||
|
||||
return tile_usage
|
||||
end
|
||||
|
||||
function love.load()
|
||||
love.keyboard.setKeyRepeat(true)
|
||||
end
|
||||
@@ -35,8 +52,12 @@ end
|
||||
|
||||
function love.filedropped(file_path)
|
||||
if file_path:sub(-5) == ".json" then
|
||||
tiles = tilesheet(utility.load_data(file_path))
|
||||
tiles_json = utility.load_data(file_path)
|
||||
tiles, tile_image = tilesheet(tiles_json)
|
||||
else
|
||||
tiles = tilesheet(file_path)
|
||||
tiles_json = {
|
||||
image_path = file_path,
|
||||
}
|
||||
tiles, tile_image = tilesheet(file_path)
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user