-- imports local MeatFactory = require("src/meat_factory") local Cursor = require("src/cursor") local UpgradeTable = require("src/upgrade_table") -- main.lua local font local tileImage local bottomBar local profitLossBar local meatFactory local upgradeTable function love.load() font = love.graphics.newFont("assets/fonts/Born2bSportyFS.otf", 32) love.graphics.setFont(font) love.mouse.setVisible(false) -- Hide the default cursor -- Load tile image tileImage = love.graphics.newImage("assets/images/tiles/tiles_bigger_new.png") -- Load UI images for bottom bar and profit/loss bar bottomBar = love.graphics.newImage("assets/images/ui/chopping-bottom-bar.png") profitLossBar = love.graphics.newImage("assets/images/ui/chopping-profitloss-bar.png") -- Load basic cursor cursor = Cursor:new() -- Create upgrade table upgradeTable = UpgradeTable:new() -- Create a MeatFactory instance meatFactory = MeatFactory:new(5, {"chicken"}) instances = {} instances.meats = {} instances.meat_factories = {} table.insert(instances.meat_factories, meatFactory) end function love.update(dt) cursor:update(dt) upgradeTable:update(dt) meatFactory:update(dt) for _, meat in ipairs(instances.meats) do meat:update(dt) end end function love.draw() -- Draw tile background local tileWidth = tileImage:getWidth() local tileHeight = tileImage:getHeight() local scale = 1 -- Adjust this value to change the tile size for x = 0, love.graphics.getWidth(), tileWidth * scale do for y = 0, love.graphics.getHeight(), tileHeight * scale do love.graphics.draw(tileImage, x, y, 0, scale, scale) end end -- Draw butcher table meatFactory:draw() -- Draw meat for _, meat in ipairs(instances.meats) do meat:draw() end -- Draw bottom bar and score local bottomBarX = (love.graphics.getWidth() - bottomBar:getWidth()) / 2 local bottomBarY = love.graphics.getHeight() - bottomBar:getHeight() love.graphics.draw(bottomBar, bottomBarX, bottomBarY) -- Draw score on bottom bar local scoreText = "Net Worth: " local scoreValue = "$" .. tostring(cursor.cleaver:getScore()) local scoreTextWidth = font:getWidth(scoreText) local scoreValueWidth = font:getWidth(scoreValue) love.graphics.setColor(0, 0, 0) -- Black love.graphics.print(scoreText, bottomBarX + 20, bottomBarY + (bottomBar:getHeight() - font:getHeight()) / 2 + 15) love.graphics.setColor(0, 0.5, 0) love.graphics.print(scoreValue, bottomBarX + 20 + scoreTextWidth, bottomBarY + (bottomBar:getHeight() - font:getHeight()) / 2 + 15) love.graphics.setColor(1, 1, 1) -- Reset to white -- 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() 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