collisions died

This commit is contained in:
PossiblyAxolotl 2022-06-16 17:24:35 -06:00
parent a5499e3d72
commit d48044f5a6
4 changed files with 46 additions and 10 deletions

View file

@ -12,6 +12,7 @@ local tilemapEditor = gfx.tilemap.new()
tilemapEditor:setImageTable(tileTable) tilemapEditor:setImageTable(tileTable)
local tiles = {} local tiles = {}
local sawblades = {} local sawblades = {}
local spins = {}
tilemapEditor:setSize(1000,1000) tilemapEditor:setSize(1000,1000)
local imgtiles = gfx.sprite.new(tilemapEditor) local imgtiles = gfx.sprite.new(tilemapEditor)
@ -153,10 +154,12 @@ local curYlerp = -32
function editSave() function editSave()
playdate.datastore.delete("levels/"..levelname..".json") playdate.datastore.delete("levels/"..levelname..".json")
saveTime = 5 saveTime = 5
playdate.datastore.write({tiles = tiles, inverted = inverted, rocket=playerPos, bigrocket=exitPos, fuel = powers,saws=sawblades,rotators={}},"levels/"..levelname) playdate.datastore.write({tiles = tiles, inverted = inverted, rocket=playerPos, bigrocket=exitPos, fuel = powers,saws=sawblades,rotators=spins},"levels/"..levelname)
end end
local traveltime = 1 local traveltime = 1
local armamount = 1
local armlength = 1
function editUpdate() function editUpdate()
--print(math.floor( tileIndex ) ) --print(math.floor( tileIndex ) )
@ -175,9 +178,12 @@ function editUpdate()
curY = (math.floor( tileIndex ) % 8) * 28 +7 curY = (math.floor( tileIndex ) % 8) * 28 +7
elseif editor == "pos2Saw" then elseif editor == "pos2Saw" then
traveltime += change * 0.003 traveltime += change * 0.002
if traveltime < 0.2 then traveltime = 0.2 end if traveltime < 0.2 then traveltime = 0.2 end
traveltime = tonumber(string.format("%.2f", traveltime)) traveltime = tonumber(string.format("%.2f", traveltime))
elseif editor == "pos2Spin" then
traveltime += change * 0.002
traveltime = tonumber(string.format("%.2f", traveltime))
end end
curYlerp = playdate.math.lerp(curYlerp, curY, 0.4) curYlerp = playdate.math.lerp(curYlerp, curY, 0.4)
@ -188,8 +194,10 @@ function editUpdate()
if editor == "pos2Saw" then 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} 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" editor = "main"
printTable(sawblades[#sawblades]) elseif editor == "pos2Spin" then
tileIndex = 2 spins[#spins+1] = {middle=true,x=pos1.x,y=pos1.y,speed=traveltime,arms=armamount,armlen=armlength}
editor = "main"
printTable(spins[#spins])
elseif editor == "tiles" then elseif editor == "tiles" then
if math.floor( tileIndex ) == 0 then if math.floor( tileIndex ) == 0 then
editor = "main" editor = "main"
@ -209,9 +217,13 @@ function editUpdate()
elseif math.floor(tileIndex) == 1 then elseif math.floor(tileIndex) == 1 then
powers[#powers+1] = {x=((position.x + 11) * 16)-7, y=((position.y + 7) * 16)-5} powers[#powers+1] = {x=((position.x + 11) * 16)-7, y=((position.y + 7) * 16)-5}
elseif math.floor(tileIndex) == 2 then elseif math.floor(tileIndex) == 2 then
traveltime = 1
pos1.x,pos1.y=((position.x + 11) * 16), ((position.y + 7) * 16) pos1.x,pos1.y=((position.x + 11) * 16), ((position.y + 7) * 16)
editor = "pos2Saw" editor = "pos2Saw"
elseif math.floor( tileIndex ) == 3 then elseif math.floor( tileIndex ) == 3 then
traveltime = 1
armamount = 1
armlength = 1
pos1.x,pos1.y=((position.x + 11) * 16), ((position.y + 7) * 16) pos1.x,pos1.y=((position.x + 11) * 16), ((position.y + 7) * 16)
editor = "pos2Spin" editor = "pos2Spin"
elseif math.floor(tileIndex) == 4 then elseif math.floor(tileIndex) == 4 then
@ -234,9 +246,11 @@ function editUpdate()
end end
end end
elseif editor == "pos2Saw" then elseif editor == "pos2Saw" then
pos1 = nil
tileIndex = 2 tileIndex = 2
editor = "main" editor = "main"
elseif editor == "pos2Spin" then
tileIndex = 3
editor = "main"
elseif editor == "main" then elseif editor == "main" then
--[[if math.floor( tileIndex ) == 0 then --[[if math.floor( tileIndex ) == 0 then
tilemapEditor:setTileAtPosition(position.x+12,position.y+8,0) tilemapEditor:setTileAtPosition(position.x+12,position.y+8,0)
@ -269,14 +283,32 @@ function editUpdate()
end end
if playdate.buttonJustPressed(playdate.kButtonLeft) then if playdate.buttonJustPressed(playdate.kButtonLeft) then
position.x -= 1 if editor ~= "pos2Spin" then
position.x -= 1
else
armamount-=1
if armamount < 1 then armamount = 1 end
end
elseif playdate.buttonJustPressed(playdate.kButtonRight) then elseif playdate.buttonJustPressed(playdate.kButtonRight) then
position.x += 1 if editor ~= "pos2Spin" then
position.x += 1
else
armamount+=1
end
end end
if playdate.buttonJustPressed(playdate.kButtonUp) then if playdate.buttonJustPressed(playdate.kButtonUp) then
position.y -= 1 if editor ~= "pos2Spin" then
position.y -= 1
else
armlength += 1
end
elseif playdate.buttonJustPressed(playdate.kButtonDown) then elseif playdate.buttonJustPressed(playdate.kButtonDown) then
position.y += 1 if editor ~= "pos2Spin" then
position.y += 1
else
armlength-=1
if armlength < 1 then armlength = 1 end
end
end end
if position.x + 11 < 0 then position.x = -11 end if position.x + 11 < 0 then position.x = -11 end
@ -345,7 +377,9 @@ function editUpdate()
tileTable[7+ind]:draw(373,181) tileTable[7+ind]:draw(373,181)
tileTable[8+ind]:draw(373,209) tileTable[8+ind]:draw(373,209)
elseif editor == "pos2Saw" then elseif editor == "pos2Saw" then
gfx.drawText("SELECT TARGET POSITION \nTRAVEL TIME: "..traveltime,0,0) 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)
elseif editor == "main" then elseif editor == "main" then
imgMus:draw(366, 176) imgMus:draw(366, 176)
imgAdd:draw(366,8) imgAdd:draw(366,8)

View file

@ -50,6 +50,7 @@ function addMap(_file, rs)
addPlayer(level.rocket.x+14,level.rocket.y+15, level.bigrocket.x+32, level.bigrocket.y+32) 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}) 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:remove()
sprTiles = gfx.sprite.new(tilemap) sprTiles = gfx.sprite.new(tilemap)

View file

@ -122,6 +122,7 @@ function updateSaws()
spinblades[spinner].time += spinblades[spinner].speed spinblades[spinner].time += spinblades[spinner].speed
local degrees = (360 / #spinblades[spinner].arms * arm + spinblades[spinner].time) 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} 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]:setImage(loopSaws:image())

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB