-- State local DILDO_COST = 199 local DILDOES = { } local LIFE = 100 local MONEY = 0 local WORK_WAIT = 0 local function resetGame () LIFE = 100 MONEY = 0 WORK_WAIT = 0 DILDOES = {} end -------------------------------------------------------------------------------- -- Colors local COLOR_BG = {26/255, 26/255, 26/255} -------------------------------------------------------------------------------- -- DILDO WORK local IMG = love.graphics.newImage('dildo.png') IMG:setFilter('nearest', 'nearest', 1) local QUADS = {} for i = 0, 15 do QUADS[#QUADS+1] = love.graphics.newQuad( (i % 4) * 8, math.floor(i / 4) * 8, 8, 8, IMG:getWidth(), IMG:getHeight() ) end local POSSIBLE_DILDOES = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 } local function get_new_dildo () local l = {} for _, dildo in ipairs(POSSIBLE_DILDOES) do l[dildo] = true end for dildo, _ in pairs(DILDOES) do l[dildo] = nil end return next(l, nil) end local function has_all_dildoes () return not get_new_dildo() end local function set_has_dildo (dildo_id) DILDOES[dildo_id] = true end -------------------------------------------------------------------------------- local function can_do_work () return WORK_WAIT <= 0 end local function do_work () MONEY = MONEY + 150 + math.floor( 0.3*(100-LIFE)) LIFE = LIFE - 17 WORK_WAIT = 5 end local function can_survive () return MONEY >= 100 and LIFE <= 70 end local function do_survive () MONEY = MONEY - 100 LIFE = 100 end local function can_buy_dildo () return MONEY >= DILDO_COST and not has_all_dildoes() end local function buy_dildo () MONEY = MONEY - DILDO_COST local dildo_id = get_new_dildo() set_has_dildo(dildo_id) end -------------------------------------------------------------------------------- local BUTTONS = { { x = 50, y = 020, width = 100, height = 20, text = 'Work', appear = can_do_work, func = do_work }, { x = 50, y = 120, width = 100, height = 20, text = 'Survive', appear = can_survive, func = do_survive }, { x = 50, y = 220, width = 100, height = 20, text = 'Buy Dildo', appear = can_buy_dildo, func = buy_dildo }, } -------------------------------------------------------------------------------- function love.load () resetGame() end function love.update (dt) WORK_WAIT = WORK_WAIT - dt LIFE = LIFE - dt * 5 if LIFE <= 0 then resetGame() end end function love.mousepressed (x, y) for _, button in ipairs(BUTTONS) do if button.x <= x and x <= button.x+button.width and button.y <= y and y <= button.y+button.height and button.appear() then button.func(button) break end end end function love.keypressed(key) if key == 'escape' then love.event.quit() end end function love.draw () love.graphics.setBackgroundColor(COLOR_BG) -- Draw buttons for _, button in ipairs(BUTTONS) do if button.appear() then love.graphics.rectangle('line', button.x - 0.5, button.y - 0.5, button.width + 1, button.height + 1) love.graphics.printf(button.text, button.x, button.y + 5, button.width, 'center') end end -- Draw survive bar love.graphics.rectangle('line', 200-0.5, 120-0.5, 101, 21) love.graphics.rectangle('fill', 200, 120, LIFE, 20) -- Draw dollarydooes love.graphics.print(MONEY..' $', 200, 20) -- Draw Didloes if next(DILDOES, nil) then --love.graphics.rectangle('line', 200 - 0.5, 220 - 0.5, 3*70+64, 3*70+64) end for dildo_id, _ in ipairs(DILDOES) do local x, y = 200 + 70 * ((dildo_id - 1) % 4), 220 + 70 * math.floor((dildo_id - 1) / 4) love.graphics.draw( IMG, QUADS[dildo_id], x, y, 0, 4, 4 ) --love.graphics.rectangle('fill', x, y, 64, 64) end end