funny tab space
This commit is contained in:
parent
c5cb06b38c
commit
219ab00a36
4 changed files with 264 additions and 264 deletions
130
def.lua
130
def.lua
|
@ -1,79 +1,79 @@
|
||||||
tiles = {
|
tiles = {
|
||||||
{
|
{
|
||||||
name = 'axe_clicker',
|
name = 'axe_clicker',
|
||||||
displayname = 'Axe Clicker',
|
displayname = 'Axe Clicker',
|
||||||
type = 'clicker',
|
type = 'clicker',
|
||||||
obtains = {
|
obtains = {
|
||||||
id = 1,
|
id = 1,
|
||||||
count = 1,
|
count = 1,
|
||||||
},
|
},
|
||||||
cost = 10,
|
cost = 10,
|
||||||
|
|
||||||
desc = 'An axe clicker. Used to obtain wood.',
|
desc = 'An axe clicker. Used to obtain wood.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = 'basic_chainsaw',
|
name = 'basic_chainsaw',
|
||||||
displayname = 'Basic Chainsaw',
|
displayname = 'Basic Chainsaw',
|
||||||
type = 'mine',
|
type = 'mine',
|
||||||
obtains = {
|
obtains = {
|
||||||
id = 1,
|
id = 1,
|
||||||
count = 0.25,
|
count = 0.25,
|
||||||
},
|
},
|
||||||
cost = 100,
|
cost = 100,
|
||||||
|
|
||||||
desc = 'A primitive chainsaw. Automatically collects wood.'
|
desc = 'A primitive chainsaw. Automatically collects wood.'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = 'conveyor_belt',
|
name = 'conveyor_belt',
|
||||||
displayname = 'Conveyor Belt',
|
displayname = 'Conveyor Belt',
|
||||||
type = 'conveyor',
|
type = 'conveyor',
|
||||||
cost = 5,
|
cost = 5,
|
||||||
speed = 1,
|
speed = 1,
|
||||||
desc = 'Moves a resource from point a to point b'
|
desc = 'Moves a resource from point a to point b'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = 'basic_seller',
|
name = 'basic_seller',
|
||||||
displayname = 'Basic Seller',
|
displayname = 'Basic Seller',
|
||||||
type = 'seller',
|
type = 'seller',
|
||||||
cost = 1500,
|
cost = 1500,
|
||||||
rate = 1,
|
rate = 1,
|
||||||
desc = 'A basic seller. Automatically sells all items coming from the forward tile',
|
desc = 'A basic seller. Automatically sells all items coming from the forward tile',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
objectTypes = {
|
objectTypes = {
|
||||||
{
|
{
|
||||||
name = 'wood',
|
name = 'wood',
|
||||||
cost = 1,
|
cost = 1,
|
||||||
desc = 'A log of wood.',
|
desc = 'A log of wood.',
|
||||||
color = {1, 0.5, 0}
|
color = {1, 0.5, 0}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
-- Things that have exchange-values:
|
-- Things that have exchange-values:
|
||||||
wood -> planks -> ...
|
wood -> planks -> ...
|
||||||
cobblestone -> stone -> flat stone -> ...
|
cobblestone -> stone -> flat stone -> ...
|
||||||
sand -> glass -> ...
|
sand -> glass -> ...
|
||||||
clay -> bricks
|
clay -> bricks
|
||||||
oil -> plastic -> ...
|
oil -> plastic -> ...
|
||||||
copper -> copper ingot
|
copper -> copper ingot
|
||||||
lead -> lead ingot
|
lead -> lead ingot
|
||||||
silver -> silver ingot
|
silver -> silver ingot
|
||||||
gold -> gold ingot -> ...
|
gold -> gold ingot -> ...
|
||||||
platinum -> platinum ingot
|
platinum -> platinum ingot
|
||||||
titanium -> titanium ingot
|
titanium -> titanium ingot
|
||||||
diamond -> refined diamond -> ...
|
diamond -> refined diamond -> ...
|
||||||
u r a n i u m
|
u r a n i u m
|
||||||
|
|
||||||
nonobtanium
|
nonobtanium
|
||||||
|
|
||||||
latex -> pappa moomin latex suit
|
latex -> pappa moomin latex suit
|
||||||
|
|
||||||
-- Things that have use-values:
|
-- Things that have use-values:
|
||||||
water
|
water
|
||||||
coal
|
coal
|
||||||
|
|
||||||
-- Concepts:
|
-- Concepts:
|
||||||
|
|
||||||
]]
|
]]
|
24
drawutil.lua
24
drawutil.lua
|
@ -1,14 +1,14 @@
|
||||||
function arrow(x, y, w, h, a)
|
function arrow(x, y, w, h, a)
|
||||||
love.graphics.line(
|
love.graphics.line(
|
||||||
x + w/2 + math.sin(math.rad(a + 180)) * w/2 * 0.8, y + h/2 + math.cos(math.rad(a + 180)) * h/2,
|
x + w/2 + math.sin(math.rad(a + 180)) * w/2 * 0.8, y + h/2 + math.cos(math.rad(a + 180)) * h/2,
|
||||||
x + w/2 + math.sin(math.rad(a)) * w/2 * 0.8, y + h/2 + math.cos(math.rad(a)) * w/2
|
x + w/2 + math.sin(math.rad(a)) * w/2 * 0.8, y + h/2 + math.cos(math.rad(a)) * w/2
|
||||||
)
|
)
|
||||||
love.graphics.line(
|
love.graphics.line(
|
||||||
x + w/2 + math.sin(math.rad(a + 180)) * w/2 * 0.8, y + h/2 + math.cos(math.rad(a + 180)) * h/2,
|
x + w/2 + math.sin(math.rad(a + 180)) * w/2 * 0.8, y + h/2 + math.cos(math.rad(a + 180)) * h/2,
|
||||||
x + w/2 + math.sin(math.rad(a + 100)) * w/2 * 0.8, y + h/2 + math.cos(math.rad(a + 100)) * h/2
|
x + w/2 + math.sin(math.rad(a + 100)) * w/2 * 0.8, y + h/2 + math.cos(math.rad(a + 100)) * h/2
|
||||||
)
|
)
|
||||||
love.graphics.line(
|
love.graphics.line(
|
||||||
x + w/2 + math.sin(math.rad(a + 180)) * w/2 * 0.8, y + h/2 + math.cos(math.rad(a + 180)) * h/2,
|
x + w/2 + math.sin(math.rad(a + 180)) * w/2 * 0.8, y + h/2 + math.cos(math.rad(a + 180)) * h/2,
|
||||||
x + w/2 + math.sin(math.rad(a - 100)) * w/2 * 0.8, y + h/2 + math.cos(math.rad(a - 100)) * h/2
|
x + w/2 + math.sin(math.rad(a - 100)) * w/2 * 0.8, y + h/2 + math.cos(math.rad(a - 100)) * h/2
|
||||||
)
|
)
|
||||||
end
|
end
|
360
main.lua
360
main.lua
|
@ -43,223 +43,223 @@ function love.load()
|
||||||
|
|
||||||
getSprites()
|
getSprites()
|
||||||
|
|
||||||
for x = 1, width do
|
for x = 1, width do
|
||||||
world[x] = {}
|
world[x] = {}
|
||||||
for y = 1, height do
|
for y = 1, height do
|
||||||
world[x][y] = {0}
|
world[x][y] = {0}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
love.graphics.setDefaultFilter('nearest', 'nearest')
|
love.graphics.setDefaultFilter('nearest', 'nearest')
|
||||||
|
|
||||||
world[1][1] = {2, rotation = 2}
|
world[1][1] = {2, rotation = 2}
|
||||||
world[2][1] = {2, rotation = 2}
|
world[2][1] = {2, rotation = 2}
|
||||||
world[3][1] = {2, rotation = 2}
|
world[3][1] = {2, rotation = 2}
|
||||||
world[4][1] = {2, rotation = 2}
|
world[4][1] = {2, rotation = 2}
|
||||||
world[5][1] = {2, rotation = 2}
|
world[5][1] = {2, rotation = 2}
|
||||||
|
|
||||||
world[1][3] = {2, rotation = 0}
|
world[1][3] = {2, rotation = 0}
|
||||||
world[2][3] = {2, rotation = 0}
|
world[2][3] = {2, rotation = 0}
|
||||||
world[3][3] = {2, rotation = 0}
|
world[3][3] = {2, rotation = 0}
|
||||||
world[4][3] = {2, rotation = 1}
|
world[4][3] = {2, rotation = 1}
|
||||||
|
|
||||||
world[1][2] = {3, rotation = 1}
|
world[1][2] = {3, rotation = 1}
|
||||||
world[2][2] = {3, rotation = 1}
|
world[2][2] = {3, rotation = 1}
|
||||||
world[3][2] = {3, rotation = 1}
|
world[3][2] = {3, rotation = 1}
|
||||||
world[4][2] = {3, rotation = 1}
|
world[4][2] = {3, rotation = 1}
|
||||||
world[5][2] = {3, rotation = 2}
|
world[5][2] = {3, rotation = 2}
|
||||||
world[5][3] = {3, rotation = 2}
|
world[5][3] = {3, rotation = 2}
|
||||||
|
|
||||||
world[5][4] = {4, rotation = 0}
|
world[5][4] = {4, rotation = 0}
|
||||||
end
|
end
|
||||||
|
|
||||||
local timer = 0
|
local timer = 0
|
||||||
function love.update(dt)
|
function love.update(dt)
|
||||||
for x = 1, width do
|
for x = 1, width do
|
||||||
for y = 1, height do
|
for y = 1, height do
|
||||||
local tileid = getTile(x, y)
|
local tileid = getTile(x, y)
|
||||||
if tileid[1] ~= 0 then
|
if tileid[1] ~= 0 then
|
||||||
local tile = tiles[tileid[1]]
|
local tile = tiles[tileid[1]]
|
||||||
|
|
||||||
if tile.type == 'mine' then
|
if tile.type == 'mine' then
|
||||||
if ((timer + dt + x * 0.25 + y * 0.5) % (1/tile.obtains.count)) < ((timer + x * 0.25 + y * 0.5) % (1/tile.obtains.count)) then
|
if ((timer + dt + x * 0.25 + y * 0.5) % (1/tile.obtains.count)) < ((timer + x * 0.25 + y * 0.5) % (1/tile.obtains.count)) then
|
||||||
local a = -(tileid.rotation or 0) * 90
|
local a = -(tileid.rotation or 0) * 90
|
||||||
local x = x + 0.5 - math.sin(math.rad(a)) * 0.7
|
local x = x + 0.5 - math.sin(math.rad(a)) * 0.7
|
||||||
local y = y + 0.5 - math.cos(math.rad(a)) * 0.7
|
local y = y + 0.5 - math.cos(math.rad(a)) * 0.7
|
||||||
|
|
||||||
table.insert(objects, {
|
table.insert(objects, {
|
||||||
x = x,
|
x = x,
|
||||||
y = y,
|
y = y,
|
||||||
size = 0.3,
|
size = 0.3,
|
||||||
type = tile.obtains.id,
|
type = tile.obtains.id,
|
||||||
color = {0.5, 0.4, 0.4},
|
color = {0.5, 0.4, 0.4},
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
timer = timer + dt
|
timer = timer + dt
|
||||||
|
|
||||||
for i,o in ipairs(objects) do
|
for i,o in ipairs(objects) do
|
||||||
o.x = o.x or 0
|
o.x = o.x or 0
|
||||||
o.y = o.y or 0
|
o.y = o.y or 0
|
||||||
o.velx = o.velx or 0
|
o.velx = o.velx or 0
|
||||||
o.vely = o.vely or 0
|
o.vely = o.vely or 0
|
||||||
o.size = o.size or 0.5
|
o.size = o.size or 0.5
|
||||||
o.color = o.color or {1, 1, 1}
|
o.color = o.color or {1, 1, 1}
|
||||||
|
|
||||||
local pass = true
|
local pass = true
|
||||||
local object = objectTypes[o.type]
|
local object = objectTypes[o.type]
|
||||||
|
|
||||||
local onTileId = getTile(math.floor(o.x), math.floor(o.y))
|
local onTileId = getTile(math.floor(o.x), math.floor(o.y))
|
||||||
if onTileId[1] ~= 0 then
|
if onTileId[1] ~= 0 then
|
||||||
local onTile = tiles[onTileId[1]]
|
local onTile = tiles[onTileId[1]]
|
||||||
local a = -(onTileId.rotation or 0) * 90
|
local a = -(onTileId.rotation or 0) * 90
|
||||||
|
|
||||||
if onTile.type == 'conveyor' then
|
if onTile.type == 'conveyor' then
|
||||||
o.velx = o.velx - math.sin(math.rad(a)) * onTile.speed
|
o.velx = o.velx - math.sin(math.rad(a)) * onTile.speed
|
||||||
o.vely = o.vely - math.cos(math.rad(a)) * onTile.speed
|
o.vely = o.vely - math.cos(math.rad(a)) * onTile.speed
|
||||||
elseif onTile.type == 'seller' then
|
elseif onTile.type == 'seller' then
|
||||||
local movementAngle = math.deg(math.atan2(o.vely, o.velx)) - 90
|
local movementAngle = math.deg(math.atan2(o.vely, o.velx)) - 90
|
||||||
if onTileId.rotation then
|
if onTileId.rotation then
|
||||||
local sellerAngle = onTileId.rotation * 90
|
local sellerAngle = onTileId.rotation * 90
|
||||||
if math.abs(movementAngle - sellerAngle) < 45 then
|
if math.abs(movementAngle - sellerAngle) < 45 then
|
||||||
table.remove(objects, i)
|
table.remove(objects, i)
|
||||||
money = money + object.cost
|
money = money + object.cost
|
||||||
else
|
else
|
||||||
pass = false
|
pass = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
pass = false
|
pass = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for i2,o2 in ipairs(objects) do
|
for i2,o2 in ipairs(objects) do
|
||||||
if i ~= i2 and rectangleTouchingRectangle(o.x - o.size, o.y - o.size, o.size, o.size, o2.x - o2.size, o2.y - o2.size, o2.size, o2.size) then
|
if i ~= i2 and rectangleTouchingRectangle(o.x - o.size, o.y - o.size, o.size, o.size, o2.x - o2.size, o2.y - o2.size, o2.size, o2.size) then
|
||||||
pass = false
|
pass = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if not pass then
|
if not pass then
|
||||||
o.velx = -o.velx
|
o.velx = -o.velx
|
||||||
o.vely = -o.vely
|
o.vely = -o.vely
|
||||||
end
|
end
|
||||||
|
|
||||||
o.x = o.x + o.velx * dt
|
o.x = o.x + o.velx * dt
|
||||||
o.y = o.y + o.vely * dt
|
o.y = o.y + o.vely * dt
|
||||||
o.velx = o.velx * 0.8
|
o.velx = o.velx * 0.8
|
||||||
o.vely = o.vely * 0.8
|
o.vely = o.vely * 0.8
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.draw()
|
function love.draw()
|
||||||
love.graphics.setBackgroundColor(0.8, 0.7, 0.7)
|
love.graphics.setBackgroundColor(0.8, 0.7, 0.7)
|
||||||
|
|
||||||
-- layer 1
|
-- layer 1
|
||||||
for x = 1, width do
|
for x = 1, width do
|
||||||
for y =1, height do
|
for y =1, height do
|
||||||
local drawx = x * tilesize
|
local drawx = x * tilesize
|
||||||
local drawy = y * tilesize
|
local drawy = y * tilesize
|
||||||
|
|
||||||
love.graphics.setColor(0.4, 0.3, 0.3)
|
love.graphics.setColor(0.4, 0.3, 0.3)
|
||||||
love.graphics.rectangle('line', drawx, drawy, tilesize, tilesize)
|
love.graphics.rectangle('line', drawx, drawy, tilesize, tilesize)
|
||||||
|
|
||||||
local tileid = getTile(x, y)
|
local tileid = getTile(x, y)
|
||||||
|
|
||||||
if tileid[1] ~= 0 then
|
if tileid[1] ~= 0 then
|
||||||
local tile = tiles[tileid[1]]
|
local tile = tiles[tileid[1]]
|
||||||
|
|
||||||
local sprite = s('tiles/' .. tile.name)
|
local sprite = s('tiles/' .. tile.name)
|
||||||
|
|
||||||
if sprite then
|
if sprite then
|
||||||
love.graphics.setColor(1, 1, 1)
|
love.graphics.setColor(1, 1, 1)
|
||||||
love.graphics.draw(sprite, drawx + tilesize/2, drawy + tilesize/2, math.rad((tileid.rotation or 0) * 90), 1, 1, tilesize/2, tilesize/2)
|
love.graphics.draw(sprite, drawx + tilesize/2, drawy + tilesize/2, math.rad((tileid.rotation or 0) * 90), 1, 1, tilesize/2, tilesize/2)
|
||||||
else
|
else
|
||||||
love.graphics.setColor(0, 0, 0)
|
love.graphics.setColor(0, 0, 0)
|
||||||
love.graphics.rectangle('fill', drawx, drawy, tilesize, tilesize)
|
love.graphics.rectangle('fill', drawx, drawy, tilesize, tilesize)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- layer 2
|
-- layer 2
|
||||||
for x = 0, width do
|
for x = 0, width do
|
||||||
for y = 0, height do
|
for y = 0, height do
|
||||||
local drawx = x * tilesize
|
local drawx = x * tilesize
|
||||||
local drawy = y * tilesize
|
local drawy = y * tilesize
|
||||||
|
|
||||||
local hovered = mouseInsideRectangle(drawx, drawy, tilesize + 1, tilesize + 1)
|
local hovered = mouseInsideRectangle(drawx, drawy, tilesize + 1, tilesize + 1)
|
||||||
|
|
||||||
if hovered then
|
if hovered then
|
||||||
love.graphics.setColor(0.8, 0.7, 0.7)
|
love.graphics.setColor(0.8, 0.7, 0.7)
|
||||||
love.graphics.rectangle('line', drawx, drawy, tilesize, tilesize)
|
love.graphics.rectangle('line', drawx, drawy, tilesize, tilesize)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, o in ipairs(objects) do
|
for _, o in ipairs(objects) do
|
||||||
love.graphics.setColor(o.color)
|
love.graphics.setColor(o.color)
|
||||||
love.graphics.rectangle('fill', o.x * tilesize - o.size * tilesize / 2, o.y * tilesize - o.size * tilesize / 2, o.size * tilesize, o.size * tilesize)
|
love.graphics.rectangle('fill', o.x * tilesize - o.size * tilesize / 2, o.y * tilesize - o.size * tilesize / 2, o.size * tilesize, o.size * tilesize)
|
||||||
love.graphics.setColor(0, 0, 0)
|
love.graphics.setColor(0, 0, 0)
|
||||||
love.graphics.rectangle('line', o.x * tilesize - o.size * tilesize / 2, o.y * tilesize - o.size * tilesize / 2, o.size * tilesize, o.size * tilesize)
|
love.graphics.rectangle('line', o.x * tilesize - o.size * tilesize / 2, o.y * tilesize - o.size * tilesize / 2, o.size * tilesize, o.size * tilesize)
|
||||||
end
|
end
|
||||||
|
|
||||||
local hoveredTileId = getCameraTile(love.mouse.getX(), love.mouse.getY())
|
local hoveredTileId = getCameraTile(love.mouse.getX(), love.mouse.getY())
|
||||||
if hoveredTileId[1] ~= 0 then
|
if hoveredTileId[1] ~= 0 then
|
||||||
local tmaxwidth = 256
|
local tmaxwidth = 256
|
||||||
local padding = 4
|
local padding = 4
|
||||||
local offset = 16
|
local offset = 16
|
||||||
|
|
||||||
local hoveredTile = tiles[hoveredTileId[1]]
|
local hoveredTile = tiles[hoveredTileId[1]]
|
||||||
|
|
||||||
local text = hoveredTile.displayname .. '\n' .. hoveredTile.desc
|
local text = hoveredTile.displayname .. '\n' .. hoveredTile.desc
|
||||||
local textObj = love.graphics.newText(love.graphics.getFont(), text)
|
local textObj = love.graphics.newText(love.graphics.getFont(), text)
|
||||||
textObj:setf(text, tmaxwidth, 'left')
|
textObj:setf(text, tmaxwidth, 'left')
|
||||||
|
|
||||||
local twidth, theight = textObj:getDimensions()
|
local twidth, theight = textObj:getDimensions()
|
||||||
local mx, my = love.mouse.getPosition()
|
local mx, my = love.mouse.getPosition()
|
||||||
local tilex = math.floor(love.mouse.getX() / tilesize) * tilesize
|
local tilex = math.floor(love.mouse.getX() / tilesize) * tilesize
|
||||||
local tiley = math.floor(love.mouse.getY() / tilesize) * tilesize
|
local tiley = math.floor(love.mouse.getY() / tilesize) * tilesize
|
||||||
|
|
||||||
love.graphics.setColor(0.9, 0.9, 0.9, 0.7)
|
love.graphics.setColor(0.9, 0.9, 0.9, 0.7)
|
||||||
love.graphics.rectangle('fill', mx + offset, my + offset, twidth + padding * 2, theight + padding * 2)
|
love.graphics.rectangle('fill', mx + offset, my + offset, twidth + padding * 2, theight + padding * 2)
|
||||||
love.graphics.setColor(0, 0, 0, 0.7)
|
love.graphics.setColor(0, 0, 0, 0.7)
|
||||||
love.graphics.draw(textObj, mx + padding + offset, my + padding + offset)
|
love.graphics.draw(textObj, mx + padding + offset, my + padding + offset)
|
||||||
|
|
||||||
if hoveredTileId.rotation then
|
if hoveredTileId.rotation then
|
||||||
love.graphics.setColor(1, 1, 1, 0.7)
|
love.graphics.setColor(1, 1, 1, 0.7)
|
||||||
local a = -hoveredTileId.rotation * 90
|
local a = -hoveredTileId.rotation * 90
|
||||||
arrow(tilex, tiley, tilesize, tilesize, a)
|
arrow(tilex, tiley, tilesize, tilesize, a)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
love.graphics.setColor(1, 1, 1)
|
love.graphics.setColor(1, 1, 1)
|
||||||
love.graphics.print(love.timer.getFPS() .. 'fps\n' .. money .. '$')
|
love.graphics.print(love.timer.getFPS() .. 'fps\n' .. money .. '$')
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.mousepressed(x, y, button)
|
function love.mousepressed(x, y, button)
|
||||||
if button == 1 then
|
if button == 1 then
|
||||||
local tileid = getCameraTile(x, y)
|
local tileid = getCameraTile(x, y)
|
||||||
if tileid[1] ~= 0 then
|
if tileid[1] ~= 0 then
|
||||||
local tile = tiles[tileid[1]]
|
local tile = tiles[tileid[1]]
|
||||||
if tile.type == 'clicker' then
|
if tile.type == 'clicker' then
|
||||||
local a = -tileid.rotation * 90
|
local a = -tileid.rotation * 90
|
||||||
local x = math.floor(x/tilesize) + 0.5 - math.sin(math.rad(a)) * 0.7
|
local x = math.floor(x/tilesize) + 0.5 - math.sin(math.rad(a)) * 0.7
|
||||||
local y = math.floor(y/tilesize) + 0.5 - math.cos(math.rad(a)) * 0.7
|
local y = math.floor(y/tilesize) + 0.5 - math.cos(math.rad(a)) * 0.7
|
||||||
|
|
||||||
for i = 1, tile.obtains.count do
|
for i = 1, tile.obtains.count do
|
||||||
table.insert(objects, {
|
table.insert(objects, {
|
||||||
x = x,
|
x = x,
|
||||||
y = y,
|
y = y,
|
||||||
size = 0.3,
|
size = 0.3,
|
||||||
type = tile.obtains.id,
|
type = tile.obtains.id,
|
||||||
color = {0.5, 0.4, 0.4},
|
color = {0.5, 0.4, 0.4},
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
14
util.lua
14
util.lua
|
@ -1,24 +1,24 @@
|
||||||
function pointInsideRectangle(x1, y1, x2, y2, w, h)
|
function pointInsideRectangle(x1, y1, x2, y2, w, h)
|
||||||
return x1 > x2 and x1 < (x2 + w) and y1 > y2 and y1 < (y2 + w) -- An Awesome Project
|
return x1 > x2 and x1 < (x2 + w) and y1 > y2 and y1 < (y2 + w) -- An Awesome Project
|
||||||
end
|
end
|
||||||
|
|
||||||
function mouseInsideRectangle(x, y, w, h)
|
function mouseInsideRectangle(x, y, w, h)
|
||||||
local x1, y1 = love.mouse.getPosition()
|
local x1, y1 = love.mouse.getPosition()
|
||||||
return pointInsideRectangle(x1, y1, x, y, w, h)
|
return pointInsideRectangle(x1, y1, x, y, w, h)
|
||||||
end
|
end
|
||||||
|
|
||||||
function rectangleTouchingRectangle(x1, y1, w1, h1, x2, y2, w2, h2)
|
function rectangleTouchingRectangle(x1, y1, w1, h1, x2, y2, w2, h2)
|
||||||
return (x1 + w1 > x2 and x1 < x2 + w2) and (y1 + h1 > y2 and y1 < y2 + h2)
|
return (x1 + w1 > x2 and x1 < x2 + w2) and (y1 + h1 > y2 and y1 < y2 + h2)
|
||||||
end
|
end
|
||||||
|
|
||||||
function getTile(x, y)
|
function getTile(x, y)
|
||||||
return (world[x] or {})[y] or {0}
|
return (world[x] or {})[y] or {0}
|
||||||
end
|
end
|
||||||
|
|
||||||
function getCameraTile(cx, cy)
|
function getCameraTile(cx, cy)
|
||||||
return getTile(math.floor(cx / tilesize), math.floor(cy / tilesize))
|
return getTile(math.floor(cx / tilesize), math.floor(cy / tilesize))
|
||||||
end
|
end
|
||||||
|
|
||||||
function s(name) -- sprite
|
function s(name) -- sprite
|
||||||
return sprites[name]
|
return sprites[name]
|
||||||
end
|
end
|
Loading…
Reference in a new issue