Rocket-Bytes/Source/Editor.lua

597 lines
20 KiB
Lua
Raw Normal View History

2022-04-27 02:40:39 +00:00
local gfx <const> = playdate.graphics
2022-05-08 05:40:21 +00:00
local prevtext = ""
2022-05-22 17:27:01 +00:00
local levelname = nil
2022-05-20 17:01:59 +00:00
2022-05-22 02:06:58 +00:00
local tileTable <const> = gfx.imagetable.new("gfx/tiles")
local tilemapEditor = gfx.tilemap.new()
tilemapEditor:setImageTable(tileTable)
local tiles = {}
2022-06-12 03:08:20 +00:00
local sawblades = {}
2022-06-16 23:24:35 +00:00
local spins = {}
2022-05-22 02:06:58 +00:00
2022-05-22 20:40:42 +00:00
tilemapEditor:setSize(1000,1000)
2022-05-22 02:06:58 +00:00
2022-05-20 17:01:59 +00:00
local bool2int = {[true]=1,[false]=0}
2022-05-22 20:40:42 +00:00
local toolTipButton
local altClrButton
2022-05-22 02:06:58 +00:00
2022-06-12 03:08:20 +00:00
local pos1 = {x,y}
2022-05-22 02:06:58 +00:00
local editor = "main"
2022-05-20 17:01:59 +00:00
2022-09-26 05:14:41 +00:00
local editorSongs = {"song1","song2","song5", "song6", "song7", "song8", "song9"}
2022-07-01 22:15:02 +00:00
local selSong = "song2"
local songIndexSel = 10
2022-08-01 06:58:11 +00:00
local grav = 0.2
2022-05-22 17:27:01 +00:00
local imgFloppy = gfx.imagetable.new("gfx/floppyT")
2022-05-22 02:06:58 +00:00
local imgAdd = gfx.image.new("gfx/add")
2022-08-09 19:51:07 +00:00
local imgMus = gfx.image.new("gfx/checkpEditor")
2022-05-22 02:06:58 +00:00
local imgLine = gfx.image.new("gfx/line")
local imgSpin = gfx.image.new("gfx/spin")
local imgCursor = gfx.image.new("gfx/cursor2")
2022-05-22 17:27:01 +00:00
local imgCant = gfx.image.new("gfx/nothing")
2022-05-23 17:23:15 +00:00
local imgSquare = gfx.image.new("gfx/square")
local imgRocket = gfx.image.new("gfx/start")
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")
2022-06-05 19:14:47 +00:00
local imgExitMen = gfx.image.new("gfx/leave")
2022-06-12 03:08:20 +00:00
local imgSaw = gfx.imagetable.new("gfx/sawblades")
local imgTarget = gfx.image.new("gfx/target")
2022-06-27 06:21:44 +00:00
local imgGrid = gfx.image.new("gfx/grid")
2022-07-10 07:45:39 +00:00
local imgWarn = gfx.image.new("gfx/warningsign")
2022-05-20 17:01:59 +00:00
assert(imgFloppy)
2022-05-22 02:06:58 +00:00
assert(imgAdd)
assert(imgMus)
assert(imgLine)
assert(imgSpin)
assert(imgCursor)
2022-05-23 17:23:15 +00:00
assert(imgSquare)
assert(imgRocket)
assert(imgEye)
assert(imgPlayer)
assert(imgPlayerExit)
2022-06-12 03:08:20 +00:00
assert(imgSaw)
assert(imgTarget)
2022-06-27 06:21:44 +00:00
assert(imgGrid)
2022-07-10 07:45:39 +00:00
assert(imgWarn)
2022-04-27 02:40:39 +00:00
2022-05-22 17:27:01 +00:00
local animFloppy = gfx.animation.loop.new(100, imgFloppy)
local saveTime = 0
local playerPos = {x=1562,y=1564}
local exitPos = {x = 1616, y = 1536}
2022-05-23 17:23:15 +00:00
local position = {x=100,y=100}
local positionLerp = {x=0,y=0}
local powers = {}
2022-08-09 19:51:07 +00:00
local checks = {}
2022-04-27 02:40:39 +00:00
function newProject()
mode = "newproj"
2022-05-08 05:40:21 +00:00
playdate.keyboard.show("NEW LEVEL")
2022-04-27 02:40:39 +00:00
end
2022-09-26 05:14:41 +00:00
function loadBg()
gfx.sprite.setBackgroundDrawingCallback(
tilemapEditor:draw(0,0)
)
end
local createNewFont <const> = gfx.font.new("gfx/bigVisibleSpaces")
2022-04-27 02:40:39 +00:00
function updateNewproj()
gfx.clear()
processStars(-10,-10)
gfx.drawText("LEVEL NAME:", 35, 100)
gfx.drawTextInRect(playdate.keyboard.text:upper(),0,130, 210, 80,0,nil,kTextAlignment.center,createNewFont)
2022-04-27 02:40:39 +00:00
end
function playdate.keyPressed(key)
playdate.keyboard.text = playdate.keyboard.text..key
playdate.keyboard.textChangedCallback()
end
2022-05-22 20:40:42 +00:00
function editLoadName(name)
2022-05-31 23:10:00 +00:00
song:stop()
2022-06-12 03:08:20 +00:00
mode = "editor"
2022-05-22 20:40:42 +00:00
local data = json.decodeFile("levels/"..name)
powers = data.fuel
2022-06-12 03:08:20 +00:00
sawblades = data.saws
spins = data.rotators
2022-05-23 17:23:15 +00:00
playerPos = {x = data.rocket.x, y = data.rocket.y}
2022-05-23 17:55:20 +00:00
exitPos = {x = data.bigrocket.x, y = data.bigrocket.y}
position = {x = (data.rocket.x + 6) / 16, y = (data.rocket.y + 4)/16}
2022-08-09 19:51:07 +00:00
if data.checks then checks = data.checks end
2022-09-26 05:14:41 +00:00
selSong = data.song or "song2"
2022-05-22 20:40:42 +00:00
levelname = name:match("(.+)%..+$")
playdate.display.setInverted(data.inverted)
2022-08-01 06:58:11 +00:00
grav = data.grav or 0.2
2022-05-22 20:40:42 +00:00
saveTime = 0
-- loading tiles
for tile = 1, #data.tiles, 1 do
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
2022-08-01 06:58:11 +00:00
altClrButton = playdate.getSystemMenu():addMenuItem("level settings", function()
2022-08-09 19:51:07 +00:00
local m = {"NO GRAVITY","NEGATIVE GRAVITY","REGULAR GRAVITY","INVERT COLOURS","CHANGE MUSIC","RESUME"}
2022-08-01 06:58:11 +00:00
createMenu(m, true)
2022-05-22 20:40:42 +00:00
end)
toolTipButton = playdate.getSystemMenu():addMenuItem("save", function()
editSave()
end)
2022-09-26 05:14:41 +00:00
loadBg()
2022-05-22 20:40:42 +00:00
end
2022-04-27 02:40:39 +00:00
function playdate.keyboard.keyboardWillHideCallback(ok)
if ok == false then
page = 0
playdate.wait(0.3)
editLoad()
elseif #playdate.keyboard.text:upper() > 0 then
2022-05-31 23:10:00 +00:00
song:stop()
2022-06-12 03:08:20 +00:00
mode = "editor"
2022-05-23 17:23:15 +00:00
position = {x=89,y=93}
playerPos = {x=1562,y=1564}
exitPos = {x = 1616, y = 1536}
2022-05-22 20:40:42 +00:00
playdate.display.setInverted(false)
saveTime = 0
2022-08-01 06:58:11 +00:00
grav=0.2
2022-06-12 03:08:20 +00:00
song:stop()
2022-08-09 19:51:07 +00:00
playdate.getSystemMenu():addMenuItem("level settings", function()
local m = {"NO GRAVITY","NEGATIVE GRAVITY","REGULAR GRAVITY","INVERT COLOURS","CHANGE MUSIC","RESUME"}
2022-08-01 06:58:11 +00:00
createMenu(m, true)
end)
playdate.getSystemMenu():addMenuItem("save",false, function()
2022-05-22 17:27:01 +00:00
editSave()
2022-05-22 02:06:58 +00:00
end)
2022-05-22 17:27:01 +00:00
levelname = playdate.keyboard.text:upper()
2022-09-26 05:14:41 +00:00
loadBg()
else
page = 0
playdate.wait(0.3)
editLoad()
2022-04-27 02:40:39 +00:00
end
2022-05-08 05:40:21 +00:00
end
function playdate.keyboard.textChangedCallback()
local newTex = playdate.keyboard.text:gsub("/", ""):gsub("\\", ""):gsub("|", ""):gsub(":", ""):gsub("*", ""):gsub("?", ""):gsub('"', ""):gsub("<", ""):gsub(">", "")
2022-05-08 05:40:21 +00:00
if #newTex > 25 then
newTex = prevtext
2022-05-08 05:40:21 +00:00
end
playdate.keyboard.text = newTex
prevtext = newTex
2022-05-20 17:01:59 +00:00
end
local tileIndex = 0.0
2022-05-22 02:06:58 +00:00
local curY = math.floor( tileIndex ) * 28 + 3
2022-05-20 17:01:59 +00:00
local curYlerp = -32
2022-05-22 17:27:01 +00:00
function editSave()
2022-05-22 20:40:42 +00:00
playdate.datastore.delete("levels/"..levelname..".json")
2022-05-22 17:27:01 +00:00
saveTime = 5
2022-08-09 19:51:07 +00:00
playdate.datastore.write({song=selSong, grav=grav, tiles = tiles, inverted = playdate.display.getInverted(), checks=checks, rocket=playerPos, bigrocket=exitPos, fuel = powers,saws=sawblades,rotators=spins},"levels/"..levelname)
2022-05-22 17:27:01 +00:00
end
2022-06-12 03:08:20 +00:00
local traveltime = 1
2022-06-16 23:24:35 +00:00
local armamount = 1
local armlength = 1
2022-06-12 03:08:20 +00:00
2022-05-20 17:01:59 +00:00
function editUpdate()
2022-05-31 23:10:00 +00:00
--print(math.floor( tileIndex ) )
2022-05-20 17:01:59 +00:00
local change, aChange = playdate.getCrankChange()
tileIndex += change * 0.01
2022-08-01 06:58:11 +00:00
2022-05-22 17:27:01 +00:00
if editor == "main" then
if tileIndex > 7.9 then tileIndex = 0 end
if tileIndex < 0 then tileIndex = 7.9 end
2022-05-31 23:10:00 +00:00
2022-05-22 17:27:01 +00:00
curY = math.floor( tileIndex ) * 28 +7
2022-05-31 23:10:00 +00:00
elseif editor == "tiles" then
2022-06-05 19:14:47 +00:00
if tileIndex < 0 then tileIndex = #tileTable-.1 end
if tileIndex > #tileTable then tileIndex = 0 end
2022-05-31 23:10:00 +00:00
curY = (math.floor( tileIndex ) % 8) * 28 +7
2022-07-01 22:15:02 +00:00
elseif editor == "music" then
if tileIndex > #editorSongs - 0.1 then tileIndex = 0 end
if tileIndex < 0 then tileIndex = #editorSongs - 0.1 end
2022-07-01 22:15:02 +00:00
curY = math.floor( tileIndex ) * 28 +7
if songIndexSel ~= math.floor(tileIndex) then
songIndexSel = math.floor(tileIndex)
song:stop()
song:load("sfx/"..editorSongs[songIndexSel+1])
2022-08-01 05:40:47 +00:00
song:play(0)
2022-07-01 22:15:02 +00:00
end
2022-06-12 03:08:20 +00:00
elseif editor == "pos2Saw" then
2022-06-16 23:24:35 +00:00
traveltime += change * 0.002
2022-06-12 03:08:20 +00:00
if traveltime < 0.2 then traveltime = 0.2 end
traveltime = tonumber(string.format("%.2f", traveltime))
2022-06-16 23:24:35 +00:00
elseif editor == "pos2Spin" then
traveltime += change * 0.001
2022-06-16 23:24:35 +00:00
traveltime = tonumber(string.format("%.2f", traveltime))
2022-05-22 17:27:01 +00:00
end
2022-05-20 17:01:59 +00:00
2022-05-22 02:06:58 +00:00
curYlerp = playdate.math.lerp(curYlerp, curY, 0.4)
positionLerp.x = playdate.math.lerp(positionLerp.x, position.x * 16, 0.5)
positionLerp.y = playdate.math.lerp(positionLerp.y, position.y * 16, 0.5)
2022-05-20 17:01:59 +00:00
2022-09-26 05:14:41 +00:00
if playdate.buttonIsPressed(playdate.kButtonA) and editor == "tiles" and math.floor(tileIndex) > 0 then
2022-08-14 00:49:06 +00:00
tilemapEditor:setTileAtPosition(position.x+12,position.y+8,math.floor( tileIndex ) + 1)
for tile = 1, #tiles, 1 do
if tiles[tile].x == position.x + 12 and tiles[tile].y == position.y+8 then
table.remove(tiles,tile)
break
end
end
tiles[#tiles+1] = {x=position.x + 12, y=position.y + 8, t=math.floor( tileIndex ) + 1}
2022-09-26 05:14:41 +00:00
2022-08-14 00:49:06 +00:00
end
2022-05-20 17:01:59 +00:00
if playdate.buttonJustPressed(playdate.kButtonA) then
2022-06-12 03:08:20 +00:00
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"
2022-07-01 22:15:02 +00:00
tileIndex = 2
2022-08-14 00:49:06 +00:00
elseif editor == "tiles" and math.floor( tileIndex ) == 0 then
editor = "main"
2022-07-01 22:15:02 +00:00
elseif editor == "music" then
selSong = editorSongs[math.floor(tileIndex) + 1]
editor = "main"
2022-07-30 03:02:41 +00:00
if playdate.buttonIsPressed(playdate.kButtonB) ~= true or playdate.buttonIsPressed(playdate.kButtonDown) ~= true then
2022-07-01 22:15:02 +00:00
song:stop()
song:load("sfx/song1")
2022-07-30 03:02:41 +00:00
end
2022-07-01 22:15:02 +00:00
songIndexSel = #editorSongs + 1
2022-06-16 23:24:35 +00:00
elseif editor == "pos2Spin" then
spins[#spins+1] = {middle=true,x=pos1.x,y=pos1.y,speed=traveltime,arms=armamount,armlen=armlength}
editor = "main"
2022-07-01 22:15:02 +00:00
tileIndex = 3
2022-06-16 23:24:35 +00:00
printTable(spins[#spins])
2022-05-31 23:10:00 +00:00
elseif editor == "main" then
if math.floor( tileIndex ) == 0 then
editor = "tiles"
elseif math.floor(tileIndex) == 1 then
powers[#powers+1] = {x=((position.x + 11) * 16)-7, y=((position.y + 7) * 16)-5}
2022-06-12 03:08:20 +00:00
elseif math.floor(tileIndex) == 2 then
2022-06-16 23:24:35 +00:00
traveltime = 1
2022-06-12 03:08:20 +00:00
pos1.x,pos1.y=((position.x + 11) * 16), ((position.y + 7) * 16)
editor = "pos2Saw"
elseif math.floor( tileIndex ) == 3 then
traveltime = .1
2022-06-16 23:24:35 +00:00
armamount = 1
armlength = 1
pos1.x,pos1.y=((position.x + 11) * 16), ((position.y + 7) * 16)
editor = "pos2Spin"
2022-05-23 17:23:15 +00:00
elseif math.floor(tileIndex) == 4 then
playerPos = {x = ((position.x + 11) * 16) - 6, y = ((position.y + 7) * 16) - 4}
2022-05-23 17:23:15 +00:00
elseif math.floor(tileIndex) == 5 then
2022-05-23 17:55:20 +00:00
exitPos = {x = (position.x + 11) * 16, y = (position.y + 7) * 16}
2022-07-01 22:15:02 +00:00
elseif math.floor(tileIndex) == 6 then
2022-08-09 19:51:07 +00:00
checks[#checks+1] = {x = ((position.x + 11) * 16) - 7, y = ((position.y + 7) * 16) - 5}
2022-05-23 17:23:15 +00:00
elseif math.floor(tileIndex) == 7 then
editor = "view"
2022-05-22 20:40:42 +00:00
end
end
end
2022-08-14 00:49:06 +00:00
if playdate.isCrankDocked() then
editor = "main"
end
2022-09-26 05:14:41 +00:00
if playdate.buttonIsPressed(playdate.kButtonB) then
2022-05-31 23:10:00 +00:00
if editor == "tiles" then
tilemapEditor:setTileAtPosition(position.x+12,position.y+8,0)
for tile = 1, #tiles, 1 do
if tiles[tile].x == position.x + 12 and tiles[tile].y == position.y+8 then
table.remove(tiles,tile)
break
end
end
2022-09-26 05:14:41 +00:00
end
end
if playdate.buttonJustPressed(playdate.kButtonB) then
if editor == "pos2Saw" then
2022-06-12 03:08:20 +00:00
tileIndex = 2
editor = "main"
2022-06-16 23:24:35 +00:00
elseif editor == "pos2Spin" then
tileIndex = 3
editor = "main"
2022-05-31 23:10:00 +00:00
elseif editor == "main" then
if 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
2022-06-12 03:08:20 +00:00
elseif math.floor( tileIndex ) == 2 then
for saw= 1, #sawblades, 1 do
if sawblades[saw].start.x == (position.x + 11) * 16 and sawblades[saw].start.y == (position.y + 7) * 16 then
table.remove(sawblades, saw)
break
2022-06-12 03:08:20 +00:00
end
end
elseif math.floor( tileIndex ) == 3 then
for saw= 1, #spins, 1 do
if spins[saw].x == (position.x + 11) * 16 and spins[saw].y == (position.y + 7) * 16 then
table.remove(spins, saw)
break
end
end
2022-08-09 19:51:07 +00:00
elseif math.floor( tileIndex ) == 6 then
for check = 1, #checks, 1 do
if checks[check].x == (position.x + 11) * 16-7 and checks[check].y == (position.y + 7) * 16-5 then
table.remove(checks, check)
break
end
end
2022-05-22 17:27:01 +00:00
end
2022-05-23 17:23:15 +00:00
elseif editor == "view" then
editor = "main"
tileIndex = 7.5
2022-05-20 17:01:59 +00:00
end
end
2022-08-01 06:58:11 +00:00
if editor ~= "settings" then
2022-08-14 00:49:06 +00:00
if playdate.buttonIsPressed(playdate.kButtonLeft) and positionLerp.x/16 < position.x +0.03 then
2022-06-16 23:24:35 +00:00
if editor ~= "pos2Spin" then
position.x -= 1
end
2022-08-14 00:49:06 +00:00
elseif playdate.buttonIsPressed(playdate.kButtonRight) and positionLerp.x/16 > position.x -0.03 then
2022-06-16 23:24:35 +00:00
if editor ~= "pos2Spin" then
position.x += 1
end
2022-05-20 17:01:59 +00:00
end
2022-08-14 00:49:06 +00:00
if playdate.buttonIsPressed(playdate.kButtonUp) and positionLerp.y/16 < position.y+0.03 then
2022-06-16 23:24:35 +00:00
if editor ~= "pos2Spin" then
position.y -= 1
end
2022-08-14 00:49:06 +00:00
elseif playdate.buttonIsPressed(playdate.kButtonDown) and positionLerp.y/16 > position.y -0.03 then
2022-06-16 23:24:35 +00:00
if editor ~= "pos2Spin" then
position.y += 1
2022-09-26 05:14:41 +00:00
end
end
--AAAAAAAAAAaa
if playdate.buttonJustPressed(playdate.kButtonLeft) and positionLerp.x/16 < position.x +0.07 then
if editor == "pos2Spin" then
armamount-=1
if armamount < 1 then armamount = 1 end
end
elseif playdate.buttonJustPressed(playdate.kButtonRight) and positionLerp.x/16 > position.x -0.07 then
if editor == "pos2Spin" then
armamount+=1
end
end
if playdate.buttonJustPressed(playdate.kButtonUp) and positionLerp.y/16 < position.y+0.07 then
if editor == "pos2Spin" then
armlength += 1
end
elseif playdate.buttonJustPressed(playdate.kButtonDown) and positionLerp.y/16 > position.y -0.07 then
if editor == "pos2Spin" then
2022-06-16 23:24:35 +00:00
armlength-=1
if armlength < 1 then armlength = 1 end
end
2022-05-22 02:06:58 +00:00
end
2022-08-01 06:58:11 +00:00
end
2022-05-22 17:27:01 +00:00
if position.x + 11 < 0 then position.x = -11 end
if position.y + 7 < 0 then position.y = -7 end
2022-05-22 02:06:58 +00:00
gfx.clear()
2022-05-20 17:01:59 +00:00
-- draw map
2022-05-22 02:06:58 +00:00
gfx.setDrawOffset(-positionLerp.x, -positionLerp.y)
2022-05-22 20:40:42 +00:00
2022-09-26 05:14:41 +00:00
tilemapEditor:draw(0,0)
2022-05-23 17:55:20 +00:00
imgPlayerExit:draw(exitPos.x, exitPos.y)
imgPlayer:draw(playerPos.x,playerPos.y)
2022-05-23 17:23:15 +00:00
2022-06-12 03:08:20 +00:00
for saw = 1, #sawblades, 1 do
local b = sawblades[saw]
imgSaw[1]:draw(b.start.x,b.start.y)
imgTarget:draw(b.ends.x,b.ends.y)
if editor == "main" and math.floor( tileIndex ) == 2 then
playdate.graphics.setLineWidth(2)
gfx.drawLine(b.start.x+8,b.start.y+8,b.ends.x+8,b.ends.y+8)
gfx.drawText(b.speed,b.start.x+8 - (gfx.getTextSize(b.speed)/2),b.start.y-16)
2022-06-12 03:08:20 +00:00
end
end
2022-06-28 23:30:32 +00:00
for saw = 1, #spins, 1 do
local spin = spins[saw]
imgSaw[2]:draw(spin.x,spin.y)
for arm = 1, spin.arms do
for blade = 1, spin.armlen do
local degrees = 360 / spin.arms * arm
local position = {x=math.sin(math.rad(degrees)) * 20 * blade,y=math.cos(math.rad(degrees)) * 20 * blade}
imgSaw[2]:draw(spin.x+position.x,spin.y+position.y)
end
end
--[[ for spinner = 1, #spinblades, 1 do
for arm = 1, #spinblades[spinner].arms do
for blade = 1, #spinblades[spinner].arms[arm] do
spinblades[spinner].time += spinblades[spinner].speed
local degrees = (360 / #spinblades[spinner].arms * arm + spinblades[spinner].time)
if degrees % 360 == 0 then spinblades[spinner].time = 0 end
local position = {x=math.sin(math.rad(degrees)) * 20 * blade,y=math.cos(math.rad(degrees)) * 20 * blade}
spinblades[spinner].arms[arm][blade]:setImage(loopSaws:image())
spinblades[spinner].arms[arm][blade]:moveTo(spinblades[spinner].mid.x + position.x, spinblades[spinner].mid.y + position.y)
end
end
end]]
if editor == "main" and math.floor( tileIndex ) == 3 then
gfx.drawText(spin.speed,spin.x+8 - (gfx.getTextSize(spin.speed)/2),spin.y-16)
end
2022-06-28 23:30:32 +00:00
end
for power = 1, #powers, 1 do
imgSquare:draw(powers[power].x,powers[power].y)
end
2022-08-09 19:51:07 +00:00
for check = 1, #checks, 1 do
imgMus:draw(checks[check].x,checks[check].y)
end
2022-05-23 17:23:15 +00:00
if editor ~= "view" then
imgGrid:drawTiled((position.x-2)*16,(position.y-2)*16,416,288)
2022-05-23 17:23:15 +00:00
imgCursor:draw((position.x + 11) * 16, (position.y + 7) * 16)
end
--[[
gfx.setColor(playdate.graphics.kColorXOR)
gfx.fillRect(((position.x + 11) * 16) + 3, ((position.y + 7) * 16) + 3,10,10)
]]
2022-05-22 17:27:01 +00:00
if position.y < 1 then
imgCant:drawTiled((position.x-1) * 16,-112,400,112)
end
if position.x < 1 then
imgCant:drawTiled(-176,(position.y-1) * 16,176,272)
end
2022-06-12 03:08:20 +00:00
if editor == "pos2Saw" then
imgSaw[1]:draw(pos1.x,pos1.y)
end
2022-05-22 02:06:58 +00:00
-- draw ui/
2022-05-23 17:23:15 +00:00
if editor ~= "view" then
2022-06-12 03:08:20 +00:00
gfx.setLineWidth(5)
gfx.setDrawOffset(0,0)
gfx.setColor(gfx.kColorBlack)
gfx.fillRect(362,0,400,240)
2022-05-20 17:01:59 +00:00
gfx.setColor(gfx.kColorWhite)
gfx.drawLine(360,0,360,240)
2022-08-01 06:58:11 +00:00
2022-05-22 02:06:58 +00:00
-- draw changes
2022-05-31 23:10:00 +00:00
if editor == "tiles" then
gfx.drawText("A TO PLACE \nB TO DELETE",0,0)
2022-06-05 19:14:47 +00:00
local ind = math.floor( tileIndex / 8 ) * 8
2022-08-14 00:49:06 +00:00
if tileIndex < 8 then
gfx.setColor(gfx.kColorXOR)
imgExitMen:draw(366,8)
gfx.fillRect(391,41,2,2)
gfx.fillRect(391,69,2,2)
gfx.fillRect(391,97,2,2)
gfx.fillRect(391,125,2,2)
2022-09-26 05:14:41 +00:00
gfx.fillRect(391,153,2,2)
2022-08-14 00:49:06 +00:00
else
tileTable[1+ind]:draw(373,13)
end
2022-06-05 19:14:47 +00:00
tileTable[2+ind]:draw(373,41)
tileTable[3+ind]:draw(373,69)
tileTable[4+ind]:draw(373,97)
tileTable[5+ind]:draw(373,125)
tileTable[6+ind]:draw(373,153)
tileTable[7+ind]:draw(373,181)
tileTable[8+ind]:draw(373,209)
2022-07-01 22:15:02 +00:00
elseif editor == "music" then
for i = 1, #editorSongs do
gfx.drawText(i,374,12+(28*(i-1)))
end
2022-06-12 03:08:20 +00:00
elseif editor == "pos2Saw" then
2022-06-16 23:24:35 +00:00
gfx.drawText("SELECT TARGET POSITION \nTRAVEL TIME: "..traveltime.."S",0,0)
elseif editor == "pos2Spin" then
gfx.drawText("< "..armamount.." > ARMS\nV "..armlength.." ^ BLADES PER ARM\nROTATION SPEED: "..traveltime,0,0)
2022-05-31 23:10:00 +00:00
elseif editor == "main" then
2022-05-23 17:23:15 +00:00
imgMus:draw(366, 176)
2022-05-22 17:27:01 +00:00
imgAdd:draw(366,8)
2022-05-23 17:23:15 +00:00
imgLine:draw(366,64)
imgSpin:draw(366,92)
imgSquare:draw(366,36)
imgRocket:draw(366, 120)
imgExit:draw(366,148)
imgEye:draw(366,204)
if math.floor( tileIndex ) == 0 then
gfx.drawText("TILES",0,0)
elseif math.floor( tileIndex ) == 1 then
gfx.drawText("POWER",0,0)
2022-05-23 17:23:15 +00:00
elseif math.floor( tileIndex ) == 2 then
gfx.drawText("MOVERS",0,0)
elseif math.floor( tileIndex ) == 3 then
gfx.drawText("SPINNERS",0,0)
2022-07-10 07:45:39 +00:00
imgWarn:draw(0,18)
gfx.drawText("VERY LAGGY",18,18)
2022-05-23 17:23:15 +00:00
elseif math.floor( tileIndex ) == 4 then
gfx.drawText("PLAYER",0,0)
elseif math.floor( tileIndex ) == 5 then
gfx.drawText("EXIT",0,0)
elseif math.floor( tileIndex ) == 6 then
2022-08-09 19:51:07 +00:00
gfx.drawText("CHECKPOINTS",0,0)
2022-05-23 17:23:15 +00:00
elseif math.floor( tileIndex ) == 7 then
gfx.drawText("VIEW",0,0)
end
2022-05-22 02:06:58 +00:00
end
2022-05-20 17:01:59 +00:00
gfx.setColor(playdate.graphics.kColorXOR)
2022-05-22 02:06:58 +00:00
gfx.fillRect(365,curYlerp,33,28)
2022-05-23 17:23:15 +00:00
end
2022-05-22 17:27:01 +00:00
if saveTime > 0 then
saveTime -= 0.1
2022-05-31 23:10:00 +00:00
animFloppy:draw(2,210)
2022-05-22 17:27:01 +00:00
end
2022-07-25 19:23:02 +00:00
if editor == "view" then
processStars(positionLerp.x-10,positionLerp.y-10)
end
2022-05-20 17:01:59 +00:00
end
function editClose()
2022-05-22 02:06:58 +00:00
for tile = 1, #tiles, 1 do
tilemapEditor:setTileAtPosition(tiles[tile].x,tiles[tile].y,0)
end
powers = {}
2022-06-12 03:08:20 +00:00
sawblades = {}
2022-07-17 01:37:12 +00:00
spins = {}
2022-08-09 19:51:07 +00:00
checks = {}
2022-05-31 23:10:00 +00:00
editor = "main"
2022-09-26 05:14:41 +00:00
tiles = {}
2022-05-31 23:10:00 +00:00
tileIndex = 0
2022-05-22 20:40:42 +00:00
playdate.display.setInverted(false)
gfx.sprite.removeAll()
if #playdate.getSystemMenu():getMenuItems() > 1 then
playdate.getSystemMenu():removeMenuItem(playdate.getSystemMenu():getMenuItems()[3])
playdate.getSystemMenu():removeMenuItem(playdate.getSystemMenu():getMenuItems()[2])
end
2022-08-01 06:58:11 +00:00
end
function setGrav(val)
grav = val
end
2022-08-09 19:51:07 +00:00
function setEditor(val)
editor = val
end
2022-08-01 06:58:11 +00:00
local gravs = {[0.2]="REGULAR",[0]="NONE",[-0.2]="NEGATIVE"}
function getGrav()
2022-08-14 00:49:06 +00:00
if gravs[grav] then
return gravs[grav]
else return grav end
end