diff --git a/Source/Editor.lua b/Source/Editor.lua index efd1e05..5733a71 100644 --- a/Source/Editor.lua +++ b/Source/Editor.lua @@ -27,6 +27,10 @@ local pos1 = {x,y} local editor = "main" +local editorSongs = {"song1","song2","song5"} +local selSong = "song2" +local songIndexSel = 10 + local imgFloppy = gfx.imagetable.new("gfx/floppyT") local imgAdd = gfx.image.new("gfx/add") local imgMus = gfx.image.new("gfx/music") @@ -157,7 +161,7 @@ local curYlerp = -32 function editSave() playdate.datastore.delete("levels/"..levelname..".json") saveTime = 5 - playdate.datastore.write({tiles = tiles, inverted = inverted, rocket=playerPos, bigrocket=exitPos, fuel = powers,saws=sawblades,rotators=spins},"levels/"..levelname) + playdate.datastore.write({song=selSong, tiles = tiles, inverted = inverted, rocket=playerPos, bigrocket=exitPos, fuel = powers,saws=sawblades,rotators=spins},"levels/"..levelname) end local traveltime = 1 @@ -180,6 +184,20 @@ function editUpdate() if tileIndex > #tileTable then tileIndex = 0 end curY = (math.floor( tileIndex ) % 8) * 28 +7 + + elseif editor == "music" then + + if tileIndex > 2.9 then tileIndex = 0 end + if tileIndex < 0 then tileIndex = 2.9 end + + curY = math.floor( tileIndex ) * 28 +7 + + if songIndexSel ~= math.floor(tileIndex) then + songIndexSel = math.floor(tileIndex) + song:stop() + song:load("sfx/"..editorSongs[songIndexSel+1]) + song:play() + end elseif editor == "pos2Saw" then traveltime += change * 0.002 if traveltime < 0.2 then traveltime = 0.2 end @@ -197,9 +215,18 @@ function editUpdate() if editor == "pos2Saw" then sawblades[#sawblades+1] = {start={x=pos1.x,y=pos1.y},ends = {x=(position.x + 11) * 16,y=(position.y + 7) * 16}, speed = traveltime} editor = "main" + tileIndex = 2 + elseif editor == "music" then + selSong = editorSongs[math.floor(tileIndex) + 1] + editor = "main" + song:stop() + song:load("sfx/song1") + tileIndex = 6 + songIndexSel = #editorSongs + 1 elseif editor == "pos2Spin" then spins[#spins+1] = {middle=true,x=pos1.x,y=pos1.y,speed=traveltime,arms=armamount,armlen=armlength} editor = "main" + tileIndex = 3 printTable(spins[#spins]) elseif editor == "tiles" then if math.floor( tileIndex ) == 0 then @@ -233,6 +260,8 @@ function editUpdate() playerPos = {x = ((position.x + 11) * 16) - 6, y = ((position.y + 7) * 16) - 4} elseif math.floor(tileIndex) == 5 then exitPos = {x = (position.x + 11) * 16, y = (position.y + 7) * 16} + elseif math.floor(tileIndex) == 6 then + editor = "music" elseif math.floor(tileIndex) == 7 then editor = "view" end @@ -422,6 +451,10 @@ function editUpdate() tileTable[6+ind]:draw(373,153) tileTable[7+ind]:draw(373,181) tileTable[8+ind]:draw(373,209) + elseif editor == "music" then + for i = 1, #editorSongs do + gfx.drawText(i,374,12+(28*(i-1))) + end elseif editor == "pos2Saw" then gfx.drawText("SELECT TARGET POSITION \nTRAVEL TIME: "..traveltime.."S",0,0) elseif editor == "pos2Spin" then diff --git a/Source/Player.lua b/Source/Player.lua index ec089fc..8eeb2e9 100644 --- a/Source/Player.lua +++ b/Source/Player.lua @@ -116,6 +116,8 @@ local function playerWin() mainMenuCreation() createMenu(mainmenu) end + + createStars() end) end