music box bas done, no art
This commit is contained in:
parent
d48044f5a6
commit
67e923af85
6 changed files with 58 additions and 7 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -64,3 +64,4 @@ $RECYCLE.BIN/
|
|||
*.pdx
|
||||
.vscode
|
||||
*.zip
|
||||
*.ase
|
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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"
|
||||
|
|
23
Source/Musicbox.lua
Normal file
23
Source/Musicbox.lua
Normal file
|
@ -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
|
Binary file not shown.
Loading…
Reference in a new issue