initial upgrade tabled for mr meat (wip)

This commit is contained in:
Juan 2025-09-11 23:41:26 -04:00
parent 5077f3390f
commit 868e7ef8f7
4 changed files with 224 additions and 3 deletions

View file

@ -1,6 +1,7 @@
-- imports
local MeatFactory = require("src/meat_factory")
local Cursor = require("src/cursor")
local UpgradeTable = require("src/upgrade_table")
-- main.lua
local font
@ -8,6 +9,7 @@ local tileImage
local bottomBar
local profitLossBar
local meatFactory
local upgradeTable
function love.load()
font = love.graphics.newFont("assets/fonts/Born2bSportyFS.otf", 32)
@ -24,6 +26,9 @@ function love.load()
-- Load basic cursor
cursor = Cursor:new()
-- Create upgrade table
upgradeTable = UpgradeTable:new()
-- Create a MeatFactory instance
meatFactory = MeatFactory:new(5, {"chicken"})
@ -36,6 +41,7 @@ end
function love.update(dt)
cursor:update(dt)
upgradeTable:update(dt)
meatFactory:update(dt)
for _, meat in ipairs(instances.meats) do
meat:update(dt)
@ -80,6 +86,9 @@ function love.draw()
-- Draw profit/loss bar at top right
love.graphics.draw(profitLossBar, love.graphics.getWidth() - profitLossBar:getWidth() - 10, 10)
-- Draw upgrade table (drawn after cursor so it appears on top)
upgradeTable:draw()
-- Draw cursor
cursor:draw()
@ -87,9 +96,33 @@ function love.draw()
end
function love.mousepressed(x, y, button)
-- Check if upgrade table handled the click first
if upgradeTable:mousepressed(x, y, button) then
return -- Upgrade table consumed the click
end
-- Check if clicking on bottom bar to open upgrade table
local bottomBarX = (love.graphics.getWidth() - bottomBar:getWidth()) / 2
local bottomBarY = love.graphics.getHeight() - bottomBar:getHeight()
if button == 1 and x >= bottomBarX and x <= bottomBarX + bottomBar:getWidth() and
y >= bottomBarY and y <= bottomBarY + bottomBar:getHeight() then
upgradeTable:toggle()
return
end
-- If upgrade table is open, don't allow other interactions
if upgradeTable:isOpen() then
return
end
cursor:mousepressed(button)
end
function love.mousereleased(x, y, button)
-- If upgrade table is open, don't allow other interactions
if upgradeTable:isOpen() then
return
end
cursor:mousereleased(button)
end