meat tables + factory creation
This commit is contained in:
parent
e52e10c0c8
commit
eb1a82d1f3
12 changed files with 161 additions and 16 deletions
41
main.lua
41
main.lua
|
|
@ -1,5 +1,7 @@
|
|||
-- imports
|
||||
local Cleaver = require("cleaver")
|
||||
local MeatFactory = require("meat_factory")
|
||||
local MeatTable = require("meat_tables")
|
||||
|
||||
-- main.lua
|
||||
local font
|
||||
|
|
@ -7,6 +9,7 @@ local cleaver
|
|||
local tileImage
|
||||
local bottomBar
|
||||
local profitLossBar
|
||||
local meatFactory
|
||||
|
||||
function love.load()
|
||||
font = love.graphics.newFont("assets/fonts/Born2bSportyFS.otf", 32)
|
||||
|
|
@ -17,27 +20,52 @@ function love.load()
|
|||
cleaver:loadImages()
|
||||
|
||||
-- Load tile image
|
||||
tileImage = love.graphics.newImage("assets/images/tiles/chop-floor-tile.png")
|
||||
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 = love.graphics.newImage("assets/images/ui/cursor.png")
|
||||
|
||||
-- Load MeatTable
|
||||
meatTable = MeatTable:new()
|
||||
|
||||
-- Create a MeatFactory instance
|
||||
meatFactory = MeatFactory:new(5, {"chicken", "cow", "pig"}, meatTable)
|
||||
|
||||
instances = {}
|
||||
instances.meats = {}
|
||||
instances.meat_tables = {}
|
||||
table.insert(instances.meat_tables, meatTable)
|
||||
|
||||
end
|
||||
|
||||
function love.update(dt)
|
||||
cleaver:update(dt)
|
||||
meatFactory: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
|
||||
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
|
||||
meatTable:draw()
|
||||
|
||||
-- Draw meat
|
||||
for _, meat in ipairs(instances.meats) do
|
||||
love.graphics.draw(meat.currentImage, meat.x, meat.y)
|
||||
end
|
||||
|
||||
|
||||
-- Draw bottom bar and score
|
||||
local bottomBarX = (love.graphics.getWidth() - bottomBar:getWidth()) / 2
|
||||
local bottomBarY = love.graphics.getHeight() - bottomBar:getHeight()
|
||||
|
|
@ -56,8 +84,13 @@ function love.draw()
|
|||
-- Draw profit/loss bar at top right
|
||||
love.graphics.draw(profitLossBar, love.graphics.getWidth() - profitLossBar:getWidth() - 10, 10)
|
||||
|
||||
local mouse_x, mouse_y = love.mouse.getPosition()
|
||||
love.graphics.draw(cursor, mouse_x - cursor:getWidth() / 2, mouse_y - cursor:getHeight() / 2)
|
||||
|
||||
-- Draw cleaver
|
||||
cleaver:draw()
|
||||
|
||||
|
||||
end
|
||||
|
||||
function love.mousepressed(x, y, button)
|
||||
|
|
@ -66,4 +99,4 @@ end
|
|||
|
||||
function love.mousereleased(x, y, button)
|
||||
cleaver:mousereleased(button)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue