| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- -- zzzzzzzzzzzzzzzzzzzzzzzz
- -- zzzzzzzzzzzzzzzzzzzzzzzz
- Dtotal = 0
- DtotalFloor = 0
- DebugMessage1 = "none"
- DebugMessage2 = "none"
- print("Haloa!")
- -- ==================================================================================
- -- ==================================================================================
- function love.load()
- success = love.window.setMode(800, 600, {resizable=false})
- Lume = require("lume")
- loadGame()
- require("ui")
- require("progress")
- require("data")
- local stoneShow = Stones
- end
- -- ==================================================================================
- -- ==================================================================================
- function love.update(dt)
- Dtotal = Dtotal + dt
- if math.floor(Dtotal*10) > DtotalFloor*10 then
- updateCraft(dt)
- DtotalFloor = math.floor(Dtotal)
- end
-
- Stones = Stones + StonesSec * dt
- stoneShow = math.floor(Stones*100 + StonesSec*100) / 100
- end
- -- ==================================================================================
- -- ==================================================================================
- function love.draw()
- love.graphics.setColor(colorWhite)
- love.graphics.print("Hello World! Since "..DtotalFloor.."sec", 400, 300)
- love.graphics.print(stoneShow, 400, 340)
- love.graphics.print("Stones", 450, 340)
- -- DRAW CRAFTERS
- -- ===========================
- for i,crft in ipairs(crafter) do
- if crft.active then
- love.graphics.setColor(colorOrange)
- love.graphics.rectangle(
- "fill", crft.ui.x, crft.ui.y, crft.ui.w, crft.ui.h, 5, 5)
- love.graphics.setColor(colorWhite)
- love.graphics.print(crft.amount .. crft.title, crft.ui.x+5, crft.ui.y+5, 0, 1, 1)
- love.graphics.print(crft.cost, crft.ui.x+5, crft.ui.y+20, 0, 1, 1)
-
- elseif crft.own then
- if crft.own and not crft.active then
- local curpos = progressbar(crft.ready, crft.readyTime, crft.ui.h)
- end
-
- love.graphics.setColor(colorBlue)
- love.graphics.rectangle(
- "fill", crft.ui.x, crft.ui.y, crft.ui.w, crft.ui.h, 5, 5)
-
- love.graphics.setColor(colorOrange)
- love.graphics.rectangle(
- "fill", crft.uiready.x, crft.uiready.y-curpos, crft.uiready.w, curpos, 5, 5)
-
- else
- if currentTier >= crft.tier then
- love.graphics.setColor(colorGrey)
- love.graphics.rectangle("line", crft.ui.x, crft.ui.y, crft.ui.w, crft.ui.h, 5, 5)
- end
- end
- end
- -- DRAW DEBUG
- -- ===========================
- love.graphics.setColor(colorWhite)
- love.graphics.print(DebugMessage1, 400, 260)
- love.graphics.print(DebugMessage2, 400, 280)
- end
- -- ==================================================================================
- -- ==================================================================================
- function checkRect(rect)
- local x, y = love.mouse.getPosition()
- local r_left = rect.x
- local r_right = rect.x + rect.w
- local r_top = rect.y
- local r_bottom = rect.y + rect.h
- return x > r_left
- and x < r_right
- and y > r_top
- and y < r_bottom
- end
- function love.mousereleased(x, y, button)
- if button == 1 then
- for i,crft in ipairs(crafter) do
- if checkRect(crft.ui) then
- upgradeCrafter(crft)
- end
- end
- end
- end
- function progressbar(cursec, maxsec, difpos)
- curpos = difpos / maxsec * cursec
-
- return curpos
- end
- function saveGame()
- -- savedata = dig
- -- serialized = lume.serialize(savedata)
- -- love.filesystem.write("savedata.txt", serialized)
- end
- function loadGame()
- -- if love.filesystem.getInfo("savedata.txt") then
- -- file = love.filesystem.read("savedata.txt")
- -- dig = lume.deserialize(file)
- -- end
- end
- function love.quit()
- saveGame()
- return false
- end
|