diff --git a/Source/Main.lua b/Source/Main.lua index cd7358b..1f8e19d 100644 --- a/Source/Main.lua +++ b/Source/Main.lua @@ -3,7 +3,7 @@ import "CoreLibs/sprites" import "Player" import "Map" -gfx = playdate.graphics +local gfx = playdate.graphics local disp = playdate.display local font = gfx.font.new("gfx/font") @@ -13,9 +13,9 @@ gfx.setBackgroundColor(gfx.kColorBlack) local song1 = playdate.sound.sampleplayer.new("sfx/song1") song1:play(0, 1) -addTiles("levels/level1.rocketbyte") +addMap("levels/level1.json") -addPlayer(10,10) +addPlayer(50,50) function playdate.update() diff --git a/Source/Map.lua b/Source/Map.lua index 0901c79..8372ee3 100644 --- a/Source/Map.lua +++ b/Source/Map.lua @@ -1,6 +1,6 @@ +local gfx = playdate.graphics local tileTable = gfx.imagetable.new("gfx/tiles") local tilemap = gfx.tilemap.new() - tilemap:setImageTable(tileTable) tilemap:setSize(100,100) diff --git a/Source/Player.lua b/Source/Player.lua index b610018..975d76a 100644 --- a/Source/Player.lua +++ b/Source/Player.lua @@ -3,21 +3,39 @@ import "CoreLibs/math" local velocity = {x=0,y=0} local lerpmnt = 0.5 local grav = 0.2 -local active = false +local exists = false +local active = false +local gfx = playdate.graphics local imgRocket = gfx.image.new("gfx/rocket") assert(imgRocket) local sprRocket = gfx.sprite.new(imgRocket) sprRocket:setCollideRect(7, 7, 14, 14) +local startpos = {x=0,y=0} -function addPlayer(x,y) - active = true - sprRocket:moveTo(x,y) +function addPlayer(_x,_y) + exists = true + active = false + velocity = {x=0,y=0} + startpos = {x= _x,y=_y} + sprRocket:moveTo(_x,_y) sprRocket:add() end +function killPlayer() + exists = false + active = false + sprRocket:remove() +end + +local function die() + active = false + velocity = {x=0,y=0} + sprRocket:moveTo(startpos.x, startpos.y) +end + function updatePlayer() - if active then + if active == true then if playdate.buttonIsPressed(playdate.kButtonUp) then velocity.x = velocity.x + math.sin(math.rad(playdate.getCrankPosition())) velocity.y = velocity.y - math.cos(math.rad(playdate.getCrankPosition())) @@ -31,8 +49,19 @@ function updatePlayer() sprRocket:update() --print(#sprRocket:overlappingSprites()) - sprRocket:setRotation(playdate.getCrankPosition()) - velocity.y += grav + + if #sprRocket:overlappingSprites() > 0 then + die() + end + + elseif exists == true then + if playdate.buttonIsPressed(playdate.kButtonUp) then + active = true + end + local cx, cy = gfx.getDrawOffset() + gfx.setDrawOffset(playdate.math.lerp(cx,(-sprRocket.x + 200), lerpmnt), playdate.math.lerp(cy,(-sprRocket.y + 120), lerpmnt)) end + + sprRocket:setRotation(playdate.getCrankPosition()) end \ No newline at end of file diff --git a/Source/launcher/card.png b/Source/launcher/card.png new file mode 100644 index 0000000..46d3482 Binary files /dev/null and b/Source/launcher/card.png differ diff --git a/Source/levels/bits1.rocketbyte b/Source/levels/bits1.json similarity index 100% rename from Source/levels/bits1.rocketbyte rename to Source/levels/bits1.json diff --git a/Source/levels/level1.rocketbyte b/Source/levels/level1.json similarity index 100% rename from Source/levels/level1.rocketbyte rename to Source/levels/level1.json diff --git a/Source/pdxinfo b/Source/pdxinfo new file mode 100644 index 0000000..5c2b19b --- /dev/null +++ b/Source/pdxinfo @@ -0,0 +1,7 @@ +name=Rocket Bytes +author=PossiblyAxolotl +description=The sequel to Rocket Bits. Help a crew of rockets collect fuel to get back home! +bundleID=com.possiblyaxolotl.rocketbytes +version=1.0 +buildNumber=1 +imagePath=launcher \ No newline at end of file