diff --git a/.gitignore b/.gitignore index d1b7ca4..da34c46 100644 --- a/.gitignore +++ b/.gitignore @@ -63,4 +63,5 @@ $RECYCLE.BIN/ .gitignore *.pdx .vscode -*.zip \ No newline at end of file +*.zip +*.ase \ No newline at end of file diff --git a/Source/Main.lua b/Source/Main.lua index 3a4be8d..d1afd1a 100644 --- a/Source/Main.lua +++ b/Source/Main.lua @@ -1,6 +1,7 @@ import "CoreLibs/graphics" import "CoreLibs/sprites" import "CoreLibs/ui" +import "Musicbox" import "Player" import "Map" import "Menu" @@ -71,7 +72,8 @@ if playdate.file.exists("levels") == false then playdate.file.mkdir("levels") en function playdate.update() if mode == "menu" then updateMenu() - + elseif mode == "music" then + updateBox() elseif mode == "game" or mode == "play" then song:setVolume(0.5) updatePlayer() diff --git a/Source/Map.lua b/Source/Map.lua index fb7b9d2..dc8828c 100644 --- a/Source/Map.lua +++ b/Source/Map.lua @@ -29,10 +29,13 @@ function addMap(_file, rs) end tilemap:setSize(width,height) + for i = 1, #level.tiles, 1 do tilemap:setTileAtPosition(level.tiles[i].x,level.tiles[i].y,level.tiles[i].t) end + tiles = gfx.sprite.addWallSprites(tilemap, {0,1,7,8,9,10,11,12,13,14,15,16}) + song:stop() if level.song then song:load("sfx/"..level.song) @@ -49,9 +52,6 @@ function addMap(_file, rs) if level.next then next = level.next end addPlayer(level.rocket.x+14,level.rocket.y+15, level.bigrocket.x+32, level.bigrocket.y+32) - tiles = gfx.sprite.addWallSprites(tilemap, {0,1,7,8,9,10,11,12,13,14,15,16}) - print(tilemap:getTileAtPosition(1,10)) - sprTiles:remove() sprTiles = gfx.sprite.new(tilemap) sprTiles:setZIndex(-1) diff --git a/Source/Menu.lua b/Source/Menu.lua index 7473b54..d8016a3 100644 --- a/Source/Menu.lua +++ b/Source/Menu.lua @@ -98,7 +98,7 @@ function updateMenu() imgCursor:draw(controlX - 17,controlY + (243 - (20 * #menuitems))) if playdate.buttonJustPressed(playdate.kButtonA) or playdate.buttonJustPressed(playdate.kButtonRight) then - menuButtonPress(menuitems[#menuitems - math.floor(index)].name) + menuButtonPress(menuitems[#menuitems - math.floor(index)].name,#menuitems - math.floor(index)) elseif playdate.buttonJustPressed(playdate.kButtonB) or playdate.buttonJustPressed(playdate.kButtonLeft) then menuButtonPress("BACK") end @@ -179,7 +179,10 @@ function editLoad() createMenu(m) end -function menuButtonPress(name) +songlist = {"EXTRAS","POV: YOU ARE A ROCKET","A LONELY, LOST SHIP", "LEVEL COMPLETE", "GAME COMPLETE", "CHIPVIBE2"} +songlist[0] = "musicbox" + +function menuButtonPress(name, index) logopos = 0 barpos = 0 @@ -226,11 +229,33 @@ function menuButtonPress(name) end elseif name == "BACK" or name == "CANCEL" or name == "MENU" then + if menu == "musicbox" then + local m = {} + m[0],m[1], m[2], m[3], m[4], m[5] = "extras", "MENU", "MUSIC BOX", "END CUTSCENE", "START CUTSCENE", "LEVEL SELECT" + if playdate.file.exists("bonusLevels.rocketbytes") then + m[6] = "EXTRA LEVELS" + end + song:stop() + song:load("sfx/song1") + song:play(0) + end createMenu(mainmenu) + elseif name == "MUSIC BOX" then + logopos = -112 + barpos = 160 + song:stop() + createMenu(songlist) elseif menu == "edits" then mode = "editor" menu = nil editLoadName(name) + elseif menu == "musicbox" then + logopos = -112 + barpos = 160 + mode = "music" + song:stop() + song:load("sfx/song"..index - 1) + song:play(0) elseif menu == "customs" then addMap("levels/"..name, true) mode = "play" diff --git a/Source/Musicbox.lua b/Source/Musicbox.lua new file mode 100644 index 0000000..53263a9 --- /dev/null +++ b/Source/Musicbox.lua @@ -0,0 +1,23 @@ +local paused = false +local playbackRate = 1.0 + +function updateBox() + local change, aChange = playdate.getCrankChange() + + if paused then + song:setRate(change*0.03) + else + playbackRate += change*0.001 + if playbackRate < 0.1 then playbackRate = 0.1 end + song:setRate(playbackRate) + end + if playdate.buttonJustPressed(playdate.kButtonA) then + if paused == true then paused = false else paused = true end + playbackRate = 1.0 + end + + if playdate.buttonJustPressed(playdate.kButtonB) or playdate.buttonJustPressed(playdate.kButtonLeft) then + createMenu(songlist) + song:stop() + end +end \ No newline at end of file diff --git a/Source/sfx/song5.wav b/Source/sfx/song5.wav index dbdfc1d..9adffa8 100644 Binary files a/Source/sfx/song5.wav and b/Source/sfx/song5.wav differ