From dcf61eedc3f19af5a98ffd78439306ffe205ad77 Mon Sep 17 00:00:00 2001 From: 1029chris <1029chris@gmail.com> Date: Tue, 14 Feb 2017 15:55:44 -0800 Subject: Added save game/load game system game auto saves when fight ends --- assets.lua | 1 + conf.lua | 3 ++- loading.lua | 13 +++++++++++++ settings.lua | 27 +++++++++++++++++++++++++-- var.lua | 7 +++++++ virus1.lua | 1 + virus2.lua | 2 ++ 7 files changed, 51 insertions(+), 3 deletions(-) diff --git a/assets.lua b/assets.lua index 5b99c9a..c7b7f7d 100644 --- a/assets.lua +++ b/assets.lua @@ -304,6 +304,7 @@ function loadAssets(id) ]] end if id == 17 then + loadSave() loadDia() end if id == 18 then diff --git a/conf.lua b/conf.lua index c693fa6..de0dbcf 100644 --- a/conf.lua +++ b/conf.lua @@ -1,5 +1,6 @@ function love.conf(t) - t.version = "0.10.0" + t.version = "0.10.2" + t.identity = "DontGetAVirus" t.modules.joystick = false t.window.title = "Don't Get a Virus" t.window.fullscreentype = "desktop" diff --git a/loading.lua b/loading.lua index db36706..49af6bd 100644 --- a/loading.lua +++ b/loading.lua @@ -47,3 +47,16 @@ function drawPause() love.graphics.setBackgroundColor(0, 128, 128) end end +function loadSave() + if love.filesystem.exists("savegame.txt") == false then + love.filesystem.write("savegame.txt", "") + else + loadGame = love.filesystem.load("savegame.txt") + loadGame() + end + if love.filesystem.exists("profile.txt") == true then + loadProfile = love.filesystem.load("profile.txt") + loadProfile() + profile.setup = true + end +end diff --git a/settings.lua b/settings.lua index 5d5a603..cdb0484 100644 --- a/settings.lua +++ b/settings.lua @@ -49,9 +49,9 @@ function drawSettings() drawDownBox(8, 305, 384/2-4, 25, 2) love.graphics.setColor(colors.font.dark) love.graphics.print("Difficulty", 14, 313) - drawDownBox(8, 340, 384/2-4, 198, 2) + drawDownBox(8, 340, 384/2-4, 122, 2) love.graphics.setColor(255,255,255) - love.graphics.rectangle("fill", 9, 341, 384/2-6, 196) + love.graphics.rectangle("fill", 9, 341, 384/2-6, 120) for i=1,6 do drawDiSel(i) end @@ -64,6 +64,13 @@ function drawSettings() for i=1,#stre do drawReSel(i) end + drawUpBox(8, 467, 384/2-4, 23, 2) + drawUpBox(8, 492, 384/2-4, 23, 2) + drawUpBox(8, 517, 384/2-4, 23, 2) + love.graphics.setColor(colors.font.dark) + love.graphics.print("Erase Save File", 14, 475) + love.graphics.print("Erase Profile", 14, 500) + love.graphics.print("Erase Both", 14, 525) end function stencilBg() love.graphics.rectangle("fill", 88-64, 44+32, 152, 120) @@ -102,6 +109,22 @@ function drawReSel(i) end end function updateSettings() + if mouseClick(win[6].x+8, win[6].y+467, 384/2-4, 23) == true and layer[1] == 6 then + love.audio.stop() + love.filesystem.remove("savefile.txt") + loadRe() + end + if mouseClick(win[6].x+8, win[6].y+492, 384/2-4, 23) == true and layer[1] == 6 then + love.audio.stop() + love.filesystem.remove("profile.txt") + loadRe() + end + if mouseClick(win[6].x+8, win[6].y+517, 384/2-4, 23) == true and layer[1] == 6 then + love.audio.stop() + love.filesystem.remove("savefile.txt") + love.filesystem.remove("profile.txt") + loadRe() + end for i=1,6 do if (layer[1] == 6 and win[6].hover == true and sys.mouse.p.p == true and sys.mouse.drag == false and sys.mouse.p.x >= win[6].x+263 and sys.mouse.p.x <= win[6].x+263+120 and diff --git a/var.lua b/var.lua index 660e2a5..b1800cf 100644 --- a/var.lua +++ b/var.lua @@ -62,6 +62,7 @@ function loadVar() loadWin(8, 400, 300, "Video Player", nil, icons[16].video) loadWin(9, 250, 150, "Music Player", nil, icons[16].music) loadWin(10, 350, 500, "Document Viewer", nil, icons[16].document) + loadWin(11, 400, 600, "First Time Setup", nil, icons[16].help) win[4].crazy = false win[4].crazyLeft = false win[4].crazyUp = false @@ -134,6 +135,11 @@ function loadVar() internet.load = 0 internet.blinkTimer = 0 internet.blink = false + profile = {} + profile.setup = false + profile.name = "No Name" + profile.gender = "Person" + profile.pronoun = {they,them,their} v1.yes = false v1.timer = 0 v1.shakemin = 0 @@ -451,6 +457,7 @@ function loadRe() v1.turret[4] = {r=math.rad(-30),x=0,y=0,rt=math.rad(-30),t=0,tl=4} expl.frame = 1 loadVar() + loadSave() loadDia() scene = 0 end diff --git a/virus1.lua b/virus1.lua index f43f544..2746eed 100644 --- a/virus1.lua +++ b/virus1.lua @@ -543,6 +543,7 @@ function drawVirusFight1() if v1.explodeEndFrame >= 20 then v1.yes = false if v1.c.chat.msgs == 47 then + love.filesystem.write("savegame.txt", "v1.complete = true;virus1Lose = " .. virus1Lose .. ";") win[4].w = 200 antivirus.status = "Virus Defeated" win[4].update = true diff --git a/virus2.lua b/virus2.lua index ce2726c..317c8e4 100644 --- a/virus2.lua +++ b/virus2.lua @@ -322,6 +322,8 @@ function drawVirusFight2() if v1.explodeEndFrame >= 20 then v2.start = false if v2.c.health == -20 then + local prevSave = love.filesystem.read("savegame.txt") + love.filesystem.write("savegame.txt", prevSave .. "v2.complete = true;virus2Lose = " .. virus2Lose .. ";") scene = 1 win[4].w = 200 antivirus.status = "Virus Defeated" -- cgit