creating cursor class pt 1
This commit is contained in:
parent
409800a54f
commit
620caa0ec7
6 changed files with 83 additions and 26 deletions
26
main.lua
26
main.lua
|
|
@ -1,11 +1,10 @@
|
|||
-- imports
|
||||
local Cleaver = require("cleaver")
|
||||
local MeatFactory = require("meat_factory")
|
||||
local MeatTable = require("meat_tables")
|
||||
local MeatFactory = require("src/meat_factory")
|
||||
local MeatTable = require("src/meat_tables")
|
||||
local Cursor = require("src/cursor")
|
||||
|
||||
-- main.lua
|
||||
local font
|
||||
local cleaver
|
||||
local tileImage
|
||||
local bottomBar
|
||||
local profitLossBar
|
||||
|
|
@ -16,8 +15,6 @@ function love.load()
|
|||
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/tiles_bigger_new.png")
|
||||
|
|
@ -26,7 +23,7 @@ function love.load()
|
|||
profitLossBar = love.graphics.newImage("assets/images/ui/chopping-profitloss-bar.png")
|
||||
|
||||
-- Load basic cursor
|
||||
cursor = love.graphics.newImage("assets/images/ui/cursor.png")
|
||||
cursor = Cursor:new()
|
||||
|
||||
-- Load MeatTable
|
||||
meatTable = MeatTable:new()
|
||||
|
|
@ -42,7 +39,7 @@ function love.load()
|
|||
end
|
||||
|
||||
function love.update(dt)
|
||||
cleaver:update(dt)
|
||||
cursor:update(dt)
|
||||
meatFactory:update(dt)
|
||||
end
|
||||
|
||||
|
|
@ -72,7 +69,7 @@ function love.draw()
|
|||
love.graphics.draw(bottomBar, bottomBarX, bottomBarY)
|
||||
-- Draw score on bottom bar
|
||||
local scoreText = "Net Worth: "
|
||||
local scoreValue = "$" .. tostring(cleaver:getScore())
|
||||
local scoreValue = "$" .. tostring(cursor.cleaver:getScore())
|
||||
local scoreTextWidth = font:getWidth(scoreText)
|
||||
local scoreValueWidth = font:getWidth(scoreValue)
|
||||
love.graphics.setColor(0, 0, 0) -- Black
|
||||
|
|
@ -83,20 +80,17 @@ 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()
|
||||
-- Draw cursor
|
||||
cursor:draw()
|
||||
|
||||
|
||||
end
|
||||
|
||||
function love.mousepressed(x, y, button)
|
||||
cleaver:mousepressed(button)
|
||||
cursor:mousepressed(button)
|
||||
end
|
||||
|
||||
function love.mousereleased(x, y, button)
|
||||
cleaver:mousereleased(button)
|
||||
cursor:mousereleased(button)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue