mathbad
This commit is contained in:
parent
4aaa0dbc8f
commit
29c4d0e106
7 changed files with 29 additions and 7 deletions
|
@ -23,7 +23,7 @@ gfx.setBackgroundColor(gfx.kColorBlack)
|
|||
|
||||
song = playdate.sound.fileplayer.new("sfx/song1")
|
||||
song:setVolume(0)
|
||||
song:setVolume(0.5,0.5, 2)
|
||||
song:setVolume(0.5,0.5, 1)
|
||||
song:play(0)
|
||||
|
||||
local imgCrank = gfx.image.new("gfx/crank")
|
||||
|
@ -57,6 +57,7 @@ function playdate.update()
|
|||
updateMenu()
|
||||
|
||||
elseif mode == "game" or mode == "play" then
|
||||
song:setVolume(0.5)
|
||||
updatePlayer()
|
||||
gfx.sprite.update()
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ local gfx <const> = playdate.graphics
|
|||
local tileTable <const> = gfx.imagetable.new("gfx/tiles")
|
||||
local tilemap <const> = gfx.tilemap.new()
|
||||
tilemap:setImageTable(tileTable)
|
||||
|
||||
local tiles = {}
|
||||
|
||||
local sprTiles = gfx.sprite.new(tilemap)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import "CoreLibs/math"
|
||||
import "CoreLibs/animator"
|
||||
import "CoreLibs/animation"
|
||||
|
||||
local velocity = {x=0,y=0}
|
||||
local lerpmnt <const> = 0.5
|
||||
|
@ -11,8 +11,11 @@ local exists = false
|
|||
local active = false
|
||||
local gfx <const> = playdate.graphics
|
||||
local imgRocket = gfx.image.new("gfx/rocket")
|
||||
local imgFire = gfx.imagetable.new("gfx/fire")
|
||||
assert(imgRocket)
|
||||
local sprRocket = gfx.sprite.new(imgRocket)
|
||||
local loopFire = gfx.animation.loop.new(200,imgFire)
|
||||
local sprFire = gfx.sprite.new(loopFire:image())
|
||||
sprRocket:setCollideRect(7, 7, 14, 14)
|
||||
local startpos = {x=0,y=0}
|
||||
|
||||
|
@ -36,6 +39,7 @@ function addPlayer(_x,_y,__x,__y)
|
|||
sprBigRocket:add()
|
||||
sprRocket:moveTo(_x,_y)
|
||||
sprRocket:add()
|
||||
sprFire:add()
|
||||
sprRocket:setVisible(true)
|
||||
end
|
||||
|
||||
|
@ -47,6 +51,11 @@ function killPlayer()
|
|||
end
|
||||
|
||||
local function playerWin()
|
||||
if active then
|
||||
song:stop()
|
||||
song:load("sfx/song3")
|
||||
song:play(1)
|
||||
end
|
||||
active = false
|
||||
exists = false
|
||||
dead = true
|
||||
|
@ -60,6 +69,7 @@ local function die()
|
|||
end
|
||||
|
||||
function updatePlayer()
|
||||
sprFire:setImage(loopFire:image())
|
||||
if active == true then
|
||||
if playdate.buttonIsPressed(playdate.kButtonUp) or playdate.buttonIsPressed(playdate.kButtonA) then
|
||||
velocity.x = velocity.x + math.sin(math.rad(playdate.getCrankPosition())) /2
|
||||
|
@ -97,7 +107,10 @@ function updatePlayer()
|
|||
|
||||
sprRocket:setScale(scale,scale)
|
||||
|
||||
sprFire:moveTo(sprRocket.x-math.sin(math.rad(playdate.getCrankPosition())*10),sprRocket.y+math.cos(math.rad(playdate.getCrankPosition()))*10)
|
||||
|
||||
sprRocket:setRotation(playdate.getCrankPosition())
|
||||
sprFire:setRotation(playdate.getCrankPosition())
|
||||
end
|
||||
|
||||
function updateExit()
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
import "CoreLibs/animator"
|
||||
import "CoreLibs/animation"
|
||||
local gfx <const> = playdate.graphics
|
||||
|
||||
local imgSaw = gfx.image.new("gfx/sawblade")
|
||||
local imgSaw = gfx.imagetable.new("gfx/sawblades")
|
||||
local imgTarget = gfx.image.new("gfx/target")
|
||||
assert(imgSaw)
|
||||
assert(imgTarget)
|
||||
|
||||
local loopSaws = gfx.animation.loop.new(200, imgSaw)
|
||||
|
||||
local blades = {}
|
||||
local spinblades = {}
|
||||
|
||||
|
@ -14,7 +17,7 @@ function loadBlades(_blades)
|
|||
local b = _blades[i]
|
||||
b.start = playdate.geometry.point.new(b.start.x,b.start.y)
|
||||
b.ends = playdate.geometry.point.new(b.ends.x,b.ends.y)
|
||||
b.saw = gfx.sprite.new(imgSaw)
|
||||
b.saw = gfx.sprite.new(loopSaws:image())
|
||||
b.saw:moveTo(b.start)
|
||||
b.saw:setCollideRect(0,0,16,16)
|
||||
b.saw:add()
|
||||
|
@ -37,7 +40,7 @@ function loadSpins(_spins)
|
|||
for i = 1, #_spins, 1 do
|
||||
local s = _spins[i]
|
||||
if s.middle then
|
||||
s.middle = gfx.sprite.new(imgSaw)
|
||||
s.middle = gfx.sprite.new(loopSaws:image())
|
||||
s.middle:setCollideRect(0,0,16,16)
|
||||
else
|
||||
s.middle = gfx.sprite.new(imgTarget)
|
||||
|
@ -52,7 +55,7 @@ function loadSpins(_spins)
|
|||
local degrees = (360 / s.arms) * i
|
||||
local position = {x=math.sin(math.rad(degrees)) * 20 * p,y=math.cos(math.rad(degrees)) * 20 * p}
|
||||
|
||||
sb.arms[i][p] = gfx.sprite.new(imgSaw)
|
||||
sb.arms[i][p] = gfx.sprite.new(loopSaws:image())
|
||||
sb.arms[i][p]:moveTo(s.x + position.x, s.y + position.y)
|
||||
sb.arms[i][p]:setCollideRect(0,0,16,16)
|
||||
sb.arms[i][p]:add()
|
||||
|
@ -65,6 +68,7 @@ end
|
|||
function updateSaws()
|
||||
for b=1, #blades, 1 do
|
||||
b = blades[b]
|
||||
b.saw:setImage(loopSaws:image())
|
||||
local pos = playdate.geometry.point.new(b.saw:getPosition())
|
||||
if pos == b.start then
|
||||
local a = gfx.animator.new(b.speed*1000, b.start, b.ends)
|
||||
|
@ -86,6 +90,7 @@ function updateSaws()
|
|||
local degrees = (360 / #spinblades[spinner].arms * arm + spinblades[spinner].time)
|
||||
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
|
||||
|
|
BIN
Source/gfx/fire-table-8-6.png
Normal file
BIN
Source/gfx/fire-table-8-6.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 137 B |
BIN
Source/gfx/sawblades-table-16-16.png
Normal file
BIN
Source/gfx/sawblades-table-16-16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 189 B |
4
Source/levels/THX.rocketbytes
Normal file
4
Source/levels/THX.rocketbytes
Normal file
|
@ -0,0 +1,4 @@
|
|||
{"bigrocket":{"x":500,"y":160},"dimensions":{"x":35,"y":13},"rocket":{"x":107.906977,"y":157.674419},
|
||||
"saws":[{"ends":{"x":72,"y":88},"speed":2.5,"start":{"x":25,"y":88}},
|
||||
{"ends":{"x":248,"y":184},"speed":2,"start":{"x":248,"y":136}}],
|
||||
"tiles":[{"t":2,"x":1,"y":1},{"t":2,"x":16,"y":1},{"t":2,"x":20,"y":1},{"t":2,"x":35,"y":1},{"t":2,"x":16,"y":5},{"t":2,"x":20,"y":5},{"t":2,"x":6,"y":6},{"t":2,"x":9,"y":6},{"t":2,"x":12,"y":6},{"t":2,"x":24,"y":7},{"t":2,"x":28,"y":7},{"t":2,"x":16,"y":8},{"t":2,"x":20,"y":8},{"t":2,"x":25,"y":8},{"t":2,"x":27,"y":8},{"t":2,"x":26,"y":9},{"t":2,"x":26,"y":10},{"t":2,"x":25,"y":11},{"t":2,"x":27,"y":11},{"t":2,"x":24,"y":12},{"t":2,"x":28,"y":12},{"t":2,"x":1,"y":13},{"t":2,"x":9,"y":13},{"t":2,"x":24,"y":13},{"t":2,"x":28,"y":13},{"t":2,"x":35,"y":13},{"t":3,"x":2,"y":1},{"t":3,"x":3,"y":1},{"t":3,"x":4,"y":1},{"t":3,"x":5,"y":1},{"t":3,"x":6,"y":1},{"t":3,"x":7,"y":1},{"t":3,"x":8,"y":1},{"t":3,"x":9,"y":1},{"t":3,"x":10,"y":1},{"t":3,"x":11,"y":1},{"t":3,"x":12,"y":1},{"t":3,"x":13,"y":1},{"t":3,"x":14,"y":1},{"t":3,"x":15,"y":1},{"t":3,"x":17,"y":1},{"t":3,"x":18,"y":1},{"t":3,"x":19,"y":1},{"t":3,"x":21,"y":1},{"t":3,"x":22,"y":1},{"t":3,"x":23,"y":1},{"t":3,"x":24,"y":1},{"t":3,"x":25,"y":1},{"t":3,"x":26,"y":1},{"t":3,"x":27,"y":1},{"t":3,"x":28,"y":1},{"t":3,"x":29,"y":1},{"t":3,"x":30,"y":1},{"t":3,"x":31,"y":1},{"t":3,"x":32,"y":1},{"t":3,"x":33,"y":1},{"t":3,"x":34,"y":1},{"t":3,"x":17,"y":5},{"t":3,"x":18,"y":5},{"t":3,"x":19,"y":5},{"t":3,"x":7,"y":6},{"t":3,"x":8,"y":6},{"t":3,"x":10,"y":6},{"t":3,"x":11,"y":6},{"t":3,"x":2,"y":13},{"t":3,"x":3,"y":13},{"t":3,"x":4,"y":13},{"t":3,"x":5,"y":13},{"t":3,"x":6,"y":13},{"t":3,"x":7,"y":13},{"t":3,"x":8,"y":13},{"t":3,"x":10,"y":13},{"t":3,"x":11,"y":13},{"t":3,"x":12,"y":13},{"t":3,"x":13,"y":13},{"t":3,"x":14,"y":13},{"t":3,"x":15,"y":13},{"t":3,"x":16,"y":13},{"t":3,"x":17,"y":13},{"t":3,"x":18,"y":13},{"t":3,"x":19,"y":13},{"t":3,"x":20,"y":13},{"t":3,"x":21,"y":13},{"t":3,"x":22,"y":13},{"t":3,"x":23,"y":13},{"t":3,"x":25,"y":13},{"t":3,"x":26,"y":13},{"t":3,"x":27,"y":13},{"t":3,"x":29,"y":13},{"t":3,"x":30,"y":13},{"t":3,"x":31,"y":13},{"t":3,"x":32,"y":13},{"t":3,"x":33,"y":13},{"t":3,"x":34,"y":13},{"t":4,"x":1,"y":2},{"t":4,"x":16,"y":2},{"t":4,"x":20,"y":2},{"t":4,"x":35,"y":2},{"t":4,"x":1,"y":3},{"t":4,"x":16,"y":3},{"t":4,"x":20,"y":3},{"t":4,"x":35,"y":3},{"t":4,"x":1,"y":4},{"t":4,"x":16,"y":4},{"t":4,"x":20,"y":4},{"t":4,"x":35,"y":4},{"t":4,"x":1,"y":5},{"t":4,"x":35,"y":5},{"t":4,"x":1,"y":6},{"t":4,"x":16,"y":6},{"t":4,"x":20,"y":6},{"t":4,"x":35,"y":6},{"t":4,"x":1,"y":7},{"t":4,"x":9,"y":7},{"t":4,"x":16,"y":7},{"t":4,"x":20,"y":7},{"t":4,"x":35,"y":7},{"t":4,"x":1,"y":8},{"t":4,"x":9,"y":8},{"t":4,"x":35,"y":8},{"t":4,"x":1,"y":9},{"t":4,"x":9,"y":9},{"t":4,"x":35,"y":9},{"t":4,"x":1,"y":10},{"t":4,"x":9,"y":10},{"t":4,"x":35,"y":10},{"t":4,"x":1,"y":11},{"t":4,"x":9,"y":11},{"t":4,"x":35,"y":11},{"t":4,"x":1,"y":12},{"t":4,"x":9,"y":12},{"t":4,"x":35,"y":12}]}
|
Loading…
Reference in a new issue