fixed invert saving, nerfed save & quit
|
@ -38,6 +38,7 @@ local imgExit = gfx.image.new("gfx/exit")
|
|||
local imgEye = gfx.image.new("gfx/eye")
|
||||
local imgPlayer = gfx.image.new("gfx/rocket")
|
||||
local imgPlayerExit = gfx.image.new("gfx/bigrocket")
|
||||
local imgB = gfx.image.new("gfx/bButton")
|
||||
assert(imgFloppy)
|
||||
assert(imgAdd)
|
||||
assert(imgMus)
|
||||
|
@ -49,16 +50,19 @@ assert(imgRocket)
|
|||
assert(imgEye)
|
||||
assert(imgPlayer)
|
||||
assert(imgPlayerExit)
|
||||
assert(imgB)
|
||||
|
||||
local animFloppy = gfx.animation.loop.new(100, imgFloppy)
|
||||
|
||||
local saveTime = 0
|
||||
|
||||
local playerPos = {x=100,y=100}
|
||||
local exitPos = {x = 105, y = 100}
|
||||
local playerPos = {x=1562,y=1564}
|
||||
local exitPos = {x = 1616, y = 1536}
|
||||
local position = {x=100,y=100}
|
||||
local positionLerp = {x=0,y=0}
|
||||
|
||||
local powers = {}
|
||||
|
||||
function newProject()
|
||||
mode = "newproj"
|
||||
playdate.keyboard.show("NEW LEVEL")
|
||||
|
@ -71,13 +75,14 @@ function updateNewproj()
|
|||
end
|
||||
|
||||
function editLoadName(name)
|
||||
removeMap()
|
||||
local data = json.decodeFile("levels/"..name)
|
||||
powers = data.fuel
|
||||
playerPos = {x = data.rocket.x, y = data.rocket.y}
|
||||
exitPos = {x = data.bigrocket.x, y = data.bigrocket.y}
|
||||
position = {x = (data.rocket.x - 2) / 16, y = (data.rocket.y-1)/16}
|
||||
position = {x = (data.rocket.x + 6) / 16, y = (data.rocket.y + 4)/16}
|
||||
levelname = name:match("(.+)%..+$")
|
||||
inverted = data.inverted
|
||||
printTable(data)
|
||||
playdate.display.setInverted(data.inverted)
|
||||
saveTime = 0
|
||||
mode = "editor"
|
||||
|
@ -90,16 +95,15 @@ function editLoadName(name)
|
|||
tilemapEditor:setTileAtPosition(data.tiles[tile].x,data.tiles[tile].y,data.tiles[tile].t)
|
||||
tiles[tile] = {x=data.tiles[tile].x,y=data.tiles[tile].y,t=data.tiles[tile].t}
|
||||
end
|
||||
|
||||
toolTipButton = menu:addMenuItem("save",data.inverted, function()
|
||||
editSave()
|
||||
end)
|
||||
altClrButton = menu:addCheckmarkMenuItem("alt colours",inverted, function(value)
|
||||
playdate.display.setInverted(value)
|
||||
inverted = value
|
||||
end)
|
||||
toolTipButton = menu:addMenuItem("save", function()
|
||||
editSave()
|
||||
end)
|
||||
|
||||
imgtiles:add()
|
||||
menuButton:setTitle("save & quit")
|
||||
playdate.wait(0.1)
|
||||
end
|
||||
|
||||
|
@ -109,9 +113,10 @@ function playdate.keyboard.keyboardWillHideCallback(ok)
|
|||
playdate.wait(0.3)
|
||||
editLoad()
|
||||
else
|
||||
removeMap()
|
||||
position = {x=89,y=93}
|
||||
playerPos = {x=100,y=100}
|
||||
exitPos = {x = 105, y = 100}
|
||||
playerPos = {x=1562,y=1564}
|
||||
exitPos = {x = 1616, y = 1536}
|
||||
for tile = 1, #tiles, 1 do
|
||||
tilemapEditor:setTileAtPosition(tiles[tile].x,tiles[tile].y,0)
|
||||
end
|
||||
|
@ -119,22 +124,22 @@ function playdate.keyboard.keyboardWillHideCallback(ok)
|
|||
playdate.display.setInverted(false)
|
||||
saveTime = 0
|
||||
mode = "editor"
|
||||
altClrButton, error = menu:addCheckmarkMenuItem("alt colours",false, function(value)
|
||||
playdate.display.setInverted(value)
|
||||
inverted = value
|
||||
end)
|
||||
toolTipButton, error = menu:addMenuItem("save",false, function()
|
||||
editSave()
|
||||
end)
|
||||
playdate.wait(0.1)
|
||||
altClrButton, error = menu:addCheckmarkMenuItem("alt colours",false, function(value)
|
||||
playdate.display.setInverted(value)
|
||||
end)
|
||||
|
||||
levelname = playdate.keyboard.text:upper()
|
||||
imgtiles:add()
|
||||
menuButton:setTitle("save & quit")
|
||||
playdate.wait(0.1)
|
||||
end
|
||||
end
|
||||
|
||||
function playdate.keyboard.textChangedCallback()
|
||||
print(#playdate.keyboard.text)
|
||||
|
||||
if #playdate.keyboard.text > 24 then
|
||||
playdate.keyboard.text = prevtext
|
||||
|
@ -151,11 +156,10 @@ local curYlerp = -32
|
|||
function editSave()
|
||||
playdate.datastore.delete("levels/"..levelname..".json")
|
||||
saveTime = 5
|
||||
playdate.datastore.write({tiles = tiles, inverted = inverted, rocket=playerPos, bigrocket=exitPos},"levels/"..levelname)
|
||||
playdate.datastore.write({tiles = tiles, inverted = inverted, rocket=playerPos, bigrocket=exitPos, fuel = powers},"levels/"..levelname)
|
||||
end
|
||||
|
||||
function editUpdate()
|
||||
printTable(exitPos)
|
||||
|
||||
local change, aChange = playdate.getCrankChange()
|
||||
|
||||
|
@ -178,8 +182,10 @@ function editUpdate()
|
|||
tilemapEditor:setTileAtPosition(position.x+12,position.y+8,2)
|
||||
tiles[#tiles+1] = {x=position.x + 12, y=position.y + 8, t=2}
|
||||
imgtiles = gfx.sprite.new(tilemapEditor)
|
||||
elseif math.floor(tileIndex) == 1 then
|
||||
powers[#powers+1] = {x=((position.x + 11) * 16)-7, y=((position.y + 7) * 16)-5}
|
||||
elseif math.floor(tileIndex) == 4 then
|
||||
playerPos = {x = ((position.x + 11) * 16) + 2, y = ((position.y + 7) * 16)+1}
|
||||
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) == 7 then
|
||||
|
@ -199,6 +205,13 @@ function editUpdate()
|
|||
end
|
||||
end
|
||||
imgtiles = gfx.sprite.new(tilemapEditor)
|
||||
elseif math.floor(tileIndex) == 1 then
|
||||
for power = 1, #powers, 1 do
|
||||
if powers[power].x == ((position.x + 11) * 16)-7 and powers[power].y == ((position.y + 7) * 16)-5 then
|
||||
table.remove(powers,power)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif editor == "view" then
|
||||
editor = "main"
|
||||
|
@ -229,6 +242,10 @@ function editUpdate()
|
|||
imgPlayerExit:draw(exitPos.x, exitPos.y)
|
||||
imgPlayer:draw(playerPos.x,playerPos.y)
|
||||
|
||||
for power = 1, #powers, 1 do
|
||||
imgSquare:draw(powers[power].x,powers[power].y)
|
||||
end
|
||||
|
||||
if editor ~= "view" then
|
||||
imgCursor:draw((position.x + 11) * 16, (position.y + 7) * 16)
|
||||
end
|
||||
|
@ -236,6 +253,7 @@ function editUpdate()
|
|||
gfx.setColor(playdate.graphics.kColorXOR)
|
||||
gfx.fillRect(((position.x + 11) * 16) + 3, ((position.y + 7) * 16) + 3,10,10)
|
||||
]]
|
||||
|
||||
if position.y < 1 then
|
||||
imgCant:drawTiled((position.x-1) * 16,-112,400,112)
|
||||
end
|
||||
|
@ -245,12 +263,12 @@ function editUpdate()
|
|||
|
||||
-- draw ui/
|
||||
if editor ~= "view" then
|
||||
gfx.setDrawOffset(0,0)
|
||||
gfx.setColor(gfx.kColorBlack)
|
||||
gfx.fillRect(362,0,400,240)
|
||||
gfx.setDrawOffset(0,0)
|
||||
gfx.setColor(gfx.kColorBlack)
|
||||
gfx.fillRect(362,0,400,240)
|
||||
|
||||
gfx.setColor(gfx.kColorWhite)
|
||||
gfx.drawLine(360,0,360,240)
|
||||
gfx.setColor(gfx.kColorWhite)
|
||||
gfx.drawLine(360,0,360,240)
|
||||
|
||||
-- draw changes
|
||||
if editor == "main" then
|
||||
|
@ -266,7 +284,7 @@ function editUpdate()
|
|||
if math.floor( tileIndex ) == 0 then
|
||||
gfx.drawText("TILES",0,0)
|
||||
elseif math.floor( tileIndex ) == 1 then
|
||||
gfx.drawText("FUEL",0,0)
|
||||
gfx.drawText("POWER",0,0)
|
||||
elseif math.floor( tileIndex ) == 2 then
|
||||
gfx.drawText("MOVERS",0,0)
|
||||
elseif math.floor( tileIndex ) == 3 then
|
||||
|
@ -284,25 +302,24 @@ function editUpdate()
|
|||
|
||||
gfx.setColor(playdate.graphics.kColorXOR)
|
||||
gfx.fillRect(365,curYlerp,33,28)
|
||||
|
||||
end
|
||||
|
||||
if saveTime > 0 then
|
||||
saveTime -= 0.1
|
||||
animFloppy:draw(2,2)
|
||||
animFloppy:draw(2,16)
|
||||
end
|
||||
end
|
||||
|
||||
function editClose()
|
||||
editSave()
|
||||
for tile = 1, #tiles, 1 do
|
||||
tilemapEditor:setTileAtPosition(tiles[tile].x,tiles[tile].y,0)
|
||||
tiles[tile] = nil
|
||||
end
|
||||
powers = {}
|
||||
playdate.display.setInverted(false)
|
||||
imgtiles = gfx.sprite.new(tilemapEditor)
|
||||
imgtiles:remove()
|
||||
playdate.getSystemMenu():removeMenuItem(toolTipButton)
|
||||
playdate.getSystemMenu():removeMenuItem(altClrButton)
|
||||
menuButton:setTitle("game menu")
|
||||
end
|
||||
|
||||
|
|
|
@ -189,8 +189,8 @@ function menuButtonPress(name)
|
|||
|
||||
elseif name == "START NEW GAME" or name == "CONFIRM" then
|
||||
deaths = 0
|
||||
map = "data/level.rocketbyte"
|
||||
addMapSave("data/level.rocketbyte")
|
||||
map = "data/level.json"
|
||||
addMapSave("data/level.json")
|
||||
|
||||
elseif name == "CONTINUE" then
|
||||
addMap(map)
|
||||
|
|
|
@ -20,6 +20,7 @@ sprRocket = gfx.sprite.new(imgRocket)
|
|||
local loopFire = gfx.animation.loop.new(200,imgFire)
|
||||
sprRocket:setCollideRect(9, 9, 10, 10)
|
||||
local startpos = {x=0,y=0}
|
||||
sprRocket:setGroups({1,2,3})
|
||||
|
||||
local imgBigRocket = gfx.image.new("gfx/bigrocket")
|
||||
local imgBigFire = gfx.imagetable.new("gfx/bigrocketfire")
|
||||
|
@ -27,8 +28,18 @@ assert(imgBigRocket)
|
|||
assert(imgBigFire)
|
||||
local loopBigFire = gfx.animation.loop.new(200,imgBigFire)
|
||||
local sprBigRocket = gfx.sprite.new(imgBigRocket)
|
||||
sprBigRocket:setCollideRect(8,8,48,48)
|
||||
sprBigRocket:setCollideRect(0,0,64,64)
|
||||
sprBigRocket:setGroups({2})
|
||||
sprBigRocket:setCollidesWithGroups({2})
|
||||
|
||||
local resetButton = nil
|
||||
|
||||
local function die()
|
||||
deaths +=1
|
||||
active = false
|
||||
velocity = {x=0,y=0}
|
||||
sprRocket:moveTo(startpos.x, startpos.y)
|
||||
end
|
||||
|
||||
function addPlayer(_x,_y,__x,__y)
|
||||
exists = true
|
||||
|
@ -43,6 +54,9 @@ function addPlayer(_x,_y,__x,__y)
|
|||
sprRocket:moveTo(_x,_y)
|
||||
sprRocket:add()
|
||||
sprRocket:setVisible(true)
|
||||
resetButton = playdate.getSystemMenu():addMenuItem("respawn", function()
|
||||
die()
|
||||
end)
|
||||
end
|
||||
|
||||
function killPlayer()
|
||||
|
@ -51,10 +65,12 @@ function killPlayer()
|
|||
sprRocket:remove()
|
||||
sprBigRocket:remove()
|
||||
gfx.setDrawOffset(0,0)
|
||||
if resetButton ~= nil then playdate.getSystemMenu():removeMenuItem(resetButton) end
|
||||
end
|
||||
|
||||
local function playerWin()
|
||||
if active then
|
||||
playdate.getSystemMenu():removeMenuItem(resetButton)
|
||||
song:stop()
|
||||
song:load("sfx/song3")
|
||||
song:play(1)
|
||||
|
@ -96,13 +112,6 @@ local function playerWin()
|
|||
|
||||
end
|
||||
|
||||
local function die()
|
||||
deaths +=1
|
||||
active = false
|
||||
velocity = {x=0,y=0}
|
||||
sprRocket:moveTo(startpos.x, startpos.y)
|
||||
end
|
||||
|
||||
function updatePlayer()
|
||||
playdate.timer.updateTimers()
|
||||
sprRocket:setImage(imgRocket)
|
||||
|
@ -155,7 +164,7 @@ function updatePlayer()
|
|||
end
|
||||
|
||||
function updateExit()
|
||||
if sprBigRocket:alphaCollision(sprRocket) and energy == totalEnergy then
|
||||
if #sprBigRocket:overlappingSprites() > 0 and energy == totalEnergy then
|
||||
playerWin()
|
||||
end
|
||||
end
|
||||
|
|
|
@ -75,8 +75,9 @@ function loadFuel(_fuel)
|
|||
for i = 1, #_fuel, 1 do
|
||||
local fuel = _fuel[i]
|
||||
fuels[i] = gfx.sprite.new()
|
||||
fuels[i]:moveTo(fuel.x,fuel.y)
|
||||
fuels[i]:moveTo(fuel.x+15,fuel.y+15)
|
||||
fuels[i]:setGroups({2})
|
||||
fuels[i]:setCollidesWithGroups({3})
|
||||
fuels[i].active = true
|
||||
fuels[i]:setZIndex(1)
|
||||
fuels[i]:setCollideRect(-6,-6 ,30,30)
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
{"bigrocket":{"x":73.333333,"y":144.79638},"song":"song6","next":"data/level2.rocketbyte","fuel":[{"x":73.333333,"y":100}],"dimensions":{"x":22,"y":17},"rocket":{"x":276.27907,"y":144.651163},"tiles":[{"t":2,"x":2,"y":1},{"t":2,"x":14,"y":1},{"t":2,"x":14,"y":5},{"t":2,"x":22,"y":5},{"t":2,"x":8,"y":6},{"t":2,"x":2,"y":12},{"t":2,"x":8,"y":12},{"t":2,"x":11,"y":12},{"t":2,"x":14,"y":12},{"t":2,"x":8,"y":17},{"t":2,"x":22,"y":17},{"t":3,"x":3,"y":1},{"t":3,"x":4,"y":1},{"t":3,"x":5,"y":1},{"t":3,"x":6,"y":1},{"t":3,"x":7,"y":1},{"t":3,"x":8,"y":1},{"t":3,"x":9,"y":1},{"t":3,"x":10,"y":1},{"t":3,"x":11,"y":1},{"t":3,"x":12,"y":1},{"t":3,"x":13,"y":1},{"t":3,"x":15,"y":5},{"t":3,"x":16,"y":5},{"t":3,"x":17,"y":5},{"t":3,"x":18,"y":5},{"t":3,"x":19,"y":5},{"t":3,"x":20,"y":5},{"t":3,"x":21,"y":5},{"t":3,"x":3,"y":12},{"t":3,"x":4,"y":12},{"t":3,"x":5,"y":12},{"t":3,"x":6,"y":12},{"t":3,"x":7,"y":12},{"t":3,"x":9,"y":12},{"t":3,"x":10,"y":12},{"t":3,"x":9,"y":17},{"t":3,"x":10,"y":17},{"t":3,"x":11,"y":17},{"t":3,"x":12,"y":17},{"t":3,"x":13,"y":17},{"t":3,"x":14,"y":17},{"t":3,"x":15,"y":17},{"t":3,"x":16,"y":17},{"t":3,"x":17,"y":17},{"t":3,"x":18,"y":17},{"t":3,"x":19,"y":17},{"t":3,"x":20,"y":17},{"t":3,"x":21,"y":17},{"t":4,"x":2,"y":2},{"t":4,"x":14,"y":2},{"t":4,"x":2,"y":3},{"t":4,"x":14,"y":3},{"t":4,"x":2,"y":4},{"t":4,"x":14,"y":4},{"t":4,"x":2,"y":5},{"t":4,"x":2,"y":6},{"t":4,"x":14,"y":6},{"t":4,"x":22,"y":6},{"t":4,"x":2,"y":7},{"t":4,"x":8,"y":7},{"t":4,"x":14,"y":7},{"t":4,"x":22,"y":7},{"t":4,"x":2,"y":8},{"t":4,"x":8,"y":8},{"t":4,"x":14,"y":8},{"t":4,"x":22,"y":8},{"t":4,"x":2,"y":9},{"t":4,"x":8,"y":9},{"t":4,"x":14,"y":9},{"t":4,"x":22,"y":9},{"t":4,"x":2,"y":10},{"t":4,"x":8,"y":10},{"t":4,"x":14,"y":10},{"t":4,"x":22,"y":10},{"t":4,"x":2,"y":11},{"t":4,"x":8,"y":11},{"t":4,"x":14,"y":11},{"t":4,"x":22,"y":11},{"t":4,"x":22,"y":12},{"t":4,"x":8,"y":13},{"t":4,"x":22,"y":13},{"t":4,"x":8,"y":14},{"t":4,"x":22,"y":14},{"t":4,"x":8,"y":15},{"t":4,"x":22,"y":15},{"t":4,"x":8,"y":16},{"t":4,"x":22,"y":16}]}
|
|
@ -1 +0,0 @@
|
|||
{"bigrocket":{"x":73.333333,"y":144.79638},"dimensions":{"x":22,"y":17},"rocket":{"x":276.27907,"y":144.651163},"tiles":[{"t":2,"x":2,"y":1},{"t":2,"x":14,"y":1},{"t":2,"x":14,"y":5},{"t":2,"x":22,"y":5},{"t":2,"x":8,"y":6},{"t":2,"x":2,"y":12},{"t":2,"x":8,"y":12},{"t":2,"x":11,"y":12},{"t":2,"x":14,"y":12},{"t":2,"x":8,"y":17},{"t":2,"x":22,"y":17},{"t":3,"x":3,"y":1},{"t":3,"x":4,"y":1},{"t":3,"x":5,"y":1},{"t":3,"x":6,"y":1},{"t":3,"x":7,"y":1},{"t":3,"x":8,"y":1},{"t":3,"x":9,"y":1},{"t":3,"x":10,"y":1},{"t":3,"x":11,"y":1},{"t":3,"x":12,"y":1},{"t":3,"x":13,"y":1},{"t":3,"x":15,"y":5},{"t":3,"x":16,"y":5},{"t":3,"x":17,"y":5},{"t":3,"x":18,"y":5},{"t":3,"x":19,"y":5},{"t":3,"x":20,"y":5},{"t":3,"x":21,"y":5},{"t":3,"x":3,"y":12},{"t":3,"x":4,"y":12},{"t":3,"x":5,"y":12},{"t":3,"x":6,"y":12},{"t":3,"x":7,"y":12},{"t":3,"x":9,"y":12},{"t":3,"x":10,"y":12},{"t":3,"x":9,"y":17},{"t":3,"x":10,"y":17},{"t":3,"x":11,"y":17},{"t":3,"x":12,"y":17},{"t":3,"x":13,"y":17},{"t":3,"x":14,"y":17},{"t":3,"x":15,"y":17},{"t":3,"x":16,"y":17},{"t":3,"x":17,"y":17},{"t":3,"x":18,"y":17},{"t":3,"x":19,"y":17},{"t":3,"x":20,"y":17},{"t":3,"x":21,"y":17},{"t":4,"x":2,"y":2},{"t":4,"x":14,"y":2},{"t":4,"x":2,"y":3},{"t":4,"x":14,"y":3},{"t":4,"x":2,"y":4},{"t":4,"x":14,"y":4},{"t":4,"x":2,"y":5},{"t":4,"x":2,"y":6},{"t":4,"x":14,"y":6},{"t":4,"x":22,"y":6},{"t":4,"x":2,"y":7},{"t":4,"x":8,"y":7},{"t":4,"x":14,"y":7},{"t":4,"x":22,"y":7},{"t":4,"x":2,"y":8},{"t":4,"x":8,"y":8},{"t":4,"x":14,"y":8},{"t":4,"x":22,"y":8},{"t":4,"x":2,"y":9},{"t":4,"x":8,"y":9},{"t":4,"x":14,"y":9},{"t":4,"x":22,"y":9},{"t":4,"x":2,"y":10},{"t":4,"x":8,"y":10},{"t":4,"x":14,"y":10},{"t":4,"x":22,"y":10},{"t":4,"x":2,"y":11},{"t":4,"x":8,"y":11},{"t":4,"x":14,"y":11},{"t":4,"x":22,"y":11},{"t":4,"x":22,"y":12},{"t":4,"x":8,"y":13},{"t":4,"x":22,"y":13},{"t":4,"x":8,"y":14},{"t":4,"x":22,"y":14},{"t":4,"x":8,"y":15},{"t":4,"x":22,"y":15},{"t":4,"x":8,"y":16},{"t":4,"x":22,"y":16}]}
|
BIN
Source/gfx/bButton.png
Normal file
After Width: | Height: | Size: 210 B |
Before Width: | Height: | Size: 215 B After Width: | Height: | Size: 153 B |
Before Width: | Height: | Size: 200 B After Width: | Height: | Size: 196 B |
Before Width: | Height: | Size: 172 B After Width: | Height: | Size: 182 B |
Before Width: | Height: | Size: 261 B After Width: | Height: | Size: 195 B |
Before Width: | Height: | Size: 133 B After Width: | Height: | Size: 193 B |