From 7deae090656caa731b767a058bf1c17f4a0f5dd2 Mon Sep 17 00:00:00 2001 From: PossiblyAxolotl Date: Sun, 22 May 2022 14:40:42 -0600 Subject: [PATCH] --- Source/Editor.lua | 74 ++++++++++++++++++++++++--- Source/Menu.lua | 2 + Source/gfx/cursor2.png | Bin 99 -> 127 bytes Source/launcher/wrapping-pattern.png | Bin 2298 -> 1850 bytes 4 files changed, 69 insertions(+), 7 deletions(-) diff --git a/Source/Editor.lua b/Source/Editor.lua index d785831..b9f66a5 100644 --- a/Source/Editor.lua +++ b/Source/Editor.lua @@ -13,7 +13,7 @@ local tilemapEditor = gfx.tilemap.new() tilemapEditor:setImageTable(tileTable) local tiles = {} -tilemapEditor:setSize(10,10) +tilemapEditor:setSize(1000,1000) local imgtiles = gfx.sprite.new(tilemapEditor) local w, h = imgtiles:getSize() imgtiles:moveTo(w/2,h/2) @@ -23,8 +23,8 @@ local positionLerp = {x=0,y=0} local bool2int = {[true]=1,[false]=0} local menu = playdate.getSystemMenu() -local toolTipButton, error -local altClrButton, error +local toolTipButton +local altClrButton local editor = "main" @@ -59,17 +59,56 @@ function updateNewproj() gfx.drawTextInRect(playdate.keyboard.text:upper(),0,125, 210, 80) end +function editLoadName(name) + position = {x=100,y=100} + local data = json.decodeFile("levels/"..name) + levelname = name:match("(.+)%..+$") + inverted = data.inverted + printTable(data) + playdate.display.setInverted(data.inverted) + saveTime = 0 + mode = "editor" + + -- loading tiles + for tile = 1, #tiles, 1 do + tilemapEditor:setTileAtPosition(tiles[tile].x,tiles[tile].y,0) + end + 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 + + toolTipButton = menu:addMenuItem("save",data.inverted, function() + editSave() + end) + altClrButton = menu:addCheckmarkMenuItem("alt colours",inverted, function(value) + playdate.display.setInverted(value) + inverted = value + end) + imgtiles:add() + menuButton:setTitle("save & quit") + playdate.wait(0.1) +end + function playdate.keyboard.keyboardWillHideCallback(ok) if ok == false then page = 0 playdate.wait(0.3) editLoad() else + position = {x=100,y=100} + for tile = 1, #tiles, 1 do + tilemapEditor:setTileAtPosition(tiles[tile].x,tiles[tile].y,0) + end + inverted = false + playdate.display.setInverted(false) + saveTime = 0 mode = "editor" toolTipButton, error = menu:addMenuItem("save",false, function() editSave() end) - altClrButton, error = menu:addCheckmarkMenuItem("alt colours",inverted, function(value) + playdate.wait(0.1) + altClrButton, error = menu:addCheckmarkMenuItem("alt colours",false, function(value) playdate.display.setInverted(value) end) levelname = playdate.keyboard.text:upper() @@ -95,8 +134,9 @@ local curY = math.floor( tileIndex ) * 28 + 3 local curYlerp = -32 function editSave() + playdate.datastore.delete("levels/"..levelname..".json") saveTime = 5 - playdate.datastore.write({tiles = tiles},"levels/"..levelname) + playdate.datastore.write({tiles = tiles, inverted = inverted},"levels/"..levelname) end function editUpdate() @@ -122,8 +162,21 @@ 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) - w, h = imgtiles:getSize() - imgtiles:moveTo(w/2,h/2) + end + end + end + + if playdate.buttonJustPressed(playdate.kButtonB) then + if editor == "main" then + if math.floor( tileIndex ) == 0 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 + imgtiles = gfx.sprite.new(tilemapEditor) end end end @@ -146,8 +199,11 @@ function editUpdate() -- draw map gfx.setDrawOffset(-positionLerp.x, -positionLerp.y) + imgtiles:update() imgCursor:draw((position.x + 11) * 16, (position.y + 7) * 16) + --gfx.setColor(playdate.graphics.kColorXOR) + --gfx.fillRect((position.x + 11) * 16, (position.y + 7) * 16,16,16) if position.y < 1 then imgCant:drawTiled((position.x-1) * 16,-112,400,112) end @@ -184,8 +240,12 @@ function editClose() editSave() for tile = 1, #tiles, 1 do tilemapEditor:setTileAtPosition(tiles[tile].x,tiles[tile].y,0) + tiles[tile] = nil end + playdate.display.setInverted(false) + imgtiles = gfx.sprite.new(tilemapEditor) imgtiles:remove() playdate.getSystemMenu():removeMenuItem(toolTipButton) + playdate.getSystemMenu():removeMenuItem(altClrButton) menuButton:setTitle("game menu") end \ No newline at end of file diff --git a/Source/Menu.lua b/Source/Menu.lua index f104bcc..7f96e22 100644 --- a/Source/Menu.lua +++ b/Source/Menu.lua @@ -233,5 +233,7 @@ function menuButtonPress(name) elseif menu == "data" then addMap("data/"..name, true) mode = "play" + elseif menu == "edits" then + editLoadName(name) end end \ No newline at end of file diff --git a/Source/gfx/cursor2.png b/Source/gfx/cursor2.png index 90b0f5819ddb5623667e54a7318a9fb7258f9b29..aa8315faeb3d68be8749795ff439473635831cfe 100644 GIT binary patch delta 96 zcmYeUpP&-$=IP=XV$qwNl92G@yaQuGVgiuyf4+^egruY*+X0Iu3^SJMWIQ@Di>cg5 z*z;Nv<6^cRsRIWZW(s+p6DeRmaW3G=jV>Mr4J}^f*8l9v3_#%N>gTe~DWM4f7lI?? delta 68 zcmb}%WV$qxY=l}oz^=w`Ys%#*Zy|C*xV*`U8DTAy7D;Nb1cx0BbF>JLL V;N@7gyO9A1JYD@<);T3K0RY2x8La>S diff --git a/Source/launcher/wrapping-pattern.png b/Source/launcher/wrapping-pattern.png index f6e49aba5f7295ad628ebe7cfa404a2e209b2d8a..e7b9808e8bbae59356693bbe6ddf6bed538c2c5b 100644 GIT binary patch literal 1850 zcmZXUc~BE)7{)gtHo#PlV!<*T5iMG4s|X`g0wI*tf+CkEP{3n^2_23SAO>7Q)GAer zAf;moAysf{A%}>75E8IrrJ{t8NCqT{Rpc-iD#<#Dk#4{a8{I#4cD`?)XW#dEfBXFu zAN%ccM^8rp0G3BbkrDv_RS7@O+J6AwzYN{%2LM=9G$~@&kvgs7Vd9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