collisions died
This commit is contained in:
parent
a5499e3d72
commit
d48044f5a6
4 changed files with 46 additions and 10 deletions
|
@ -12,6 +12,7 @@ local tilemapEditor = gfx.tilemap.new()
|
|||
tilemapEditor:setImageTable(tileTable)
|
||||
local tiles = {}
|
||||
local sawblades = {}
|
||||
local spins = {}
|
||||
|
||||
tilemapEditor:setSize(1000,1000)
|
||||
local imgtiles = gfx.sprite.new(tilemapEditor)
|
||||
|
@ -153,10 +154,12 @@ local curYlerp = -32
|
|||
function editSave()
|
||||
playdate.datastore.delete("levels/"..levelname..".json")
|
||||
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
|
||||
|
||||
local traveltime = 1
|
||||
local armamount = 1
|
||||
local armlength = 1
|
||||
|
||||
function editUpdate()
|
||||
--print(math.floor( tileIndex ) )
|
||||
|
@ -175,9 +178,12 @@ function editUpdate()
|
|||
|
||||
curY = (math.floor( tileIndex ) % 8) * 28 +7
|
||||
elseif editor == "pos2Saw" then
|
||||
traveltime += change * 0.003
|
||||
traveltime += change * 0.002
|
||||
if traveltime < 0.2 then traveltime = 0.2 end
|
||||
traveltime = tonumber(string.format("%.2f", traveltime))
|
||||
elseif editor == "pos2Spin" then
|
||||
traveltime += change * 0.002
|
||||
traveltime = tonumber(string.format("%.2f", traveltime))
|
||||
end
|
||||
|
||||
curYlerp = playdate.math.lerp(curYlerp, curY, 0.4)
|
||||
|
@ -188,8 +194,10 @@ function editUpdate()
|
|||
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"
|
||||
printTable(sawblades[#sawblades])
|
||||
tileIndex = 2
|
||||
elseif editor == "pos2Spin" then
|
||||
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
|
||||
if math.floor( tileIndex ) == 0 then
|
||||
editor = "main"
|
||||
|
@ -209,9 +217,13 @@ function editUpdate()
|
|||
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) == 2 then
|
||||
traveltime = 1
|
||||
pos1.x,pos1.y=((position.x + 11) * 16), ((position.y + 7) * 16)
|
||||
editor = "pos2Saw"
|
||||
elseif math.floor( tileIndex ) == 3 then
|
||||
traveltime = 1
|
||||
armamount = 1
|
||||
armlength = 1
|
||||
pos1.x,pos1.y=((position.x + 11) * 16), ((position.y + 7) * 16)
|
||||
editor = "pos2Spin"
|
||||
elseif math.floor(tileIndex) == 4 then
|
||||
|
@ -234,9 +246,11 @@ function editUpdate()
|
|||
end
|
||||
end
|
||||
elseif editor == "pos2Saw" then
|
||||
pos1 = nil
|
||||
tileIndex = 2
|
||||
editor = "main"
|
||||
elseif editor == "pos2Spin" then
|
||||
tileIndex = 3
|
||||
editor = "main"
|
||||
elseif editor == "main" then
|
||||
--[[if math.floor( tileIndex ) == 0 then
|
||||
tilemapEditor:setTileAtPosition(position.x+12,position.y+8,0)
|
||||
|
@ -269,14 +283,32 @@ function editUpdate()
|
|||
end
|
||||
|
||||
if playdate.buttonJustPressed(playdate.kButtonLeft) then
|
||||
if editor ~= "pos2Spin" then
|
||||
position.x -= 1
|
||||
else
|
||||
armamount-=1
|
||||
if armamount < 1 then armamount = 1 end
|
||||
end
|
||||
elseif playdate.buttonJustPressed(playdate.kButtonRight) then
|
||||
if editor ~= "pos2Spin" then
|
||||
position.x += 1
|
||||
else
|
||||
armamount+=1
|
||||
end
|
||||
end
|
||||
if playdate.buttonJustPressed(playdate.kButtonUp) then
|
||||
if editor ~= "pos2Spin" then
|
||||
position.y -= 1
|
||||
else
|
||||
armlength += 1
|
||||
end
|
||||
elseif playdate.buttonJustPressed(playdate.kButtonDown) then
|
||||
if editor ~= "pos2Spin" then
|
||||
position.y += 1
|
||||
else
|
||||
armlength-=1
|
||||
if armlength < 1 then armlength = 1 end
|
||||
end
|
||||
end
|
||||
|
||||
if position.x + 11 < 0 then position.x = -11 end
|
||||
|
@ -345,7 +377,9 @@ function editUpdate()
|
|||
tileTable[7+ind]:draw(373,181)
|
||||
tileTable[8+ind]:draw(373,209)
|
||||
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
|
||||
imgMus:draw(366, 176)
|
||||
imgAdd:draw(366,8)
|
||||
|
|
|
@ -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)
|
||||
|
||||
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)
|
||||
|
|
|
@ -122,6 +122,7 @@ function updateSaws()
|
|||
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())
|
||||
|
|
BIN
Source/launcher/card-pressed.png
Normal file
BIN
Source/launcher/card-pressed.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
Loading…
Reference in a new issue