mr_meat/main.lua
2025-07-30 00:15:28 -04:00

69 lines
No EOL
2.4 KiB
Lua

-- imports
local Cleaver = require("cleaver")
-- main.lua
local font
local cleaver
local tileImage
local bottomBar
local profitLossBar
function love.load()
font = love.graphics.newFont("assets/fonts/Born2bSportyFS.otf", 32)
love.graphics.setFont(font)
love.mouse.setVisible(false) -- Hide the default cursor
cleaver = Cleaver:new()
cleaver:loadImages()
-- Load tile image
tileImage = love.graphics.newImage("assets/images/tiles/chop-floor-tile.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")
end
function love.update(dt)
cleaver:update(dt)
end
function love.draw()
-- Draw tile background
local tileWidth = tileImage:getWidth()
local tileHeight = tileImage:getHeight()
local scale = 4 -- 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 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(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 cleaver
cleaver:draw()
end
function love.mousepressed(x, y, button)
cleaver:mousepressed(button)
end
function love.mousereleased(x, y, button)
cleaver:mousereleased(button)
end