begun rotator system
This commit is contained in:
parent
1b4081d9fc
commit
51e2c74739
8 changed files with 87 additions and 4 deletions
22
Source/Editor.lua
Normal file
22
Source/Editor.lua
Normal file
|
@ -0,0 +1,22 @@
|
|||
import "CoreLibs/keyboard"
|
||||
|
||||
local gfx <const> = playdate.graphics
|
||||
|
||||
function newProject()
|
||||
mode = "newproj"
|
||||
playdate.keyboard.show("test")
|
||||
end
|
||||
|
||||
function updateNewproj()
|
||||
gfx.clear()
|
||||
gfx.drawText("LEVEL NAME:", 0, 105)
|
||||
gfx.drawText(playdate.keyboard.text:upper(),0,125)
|
||||
end
|
||||
|
||||
function playdate.keyboard.keyboardWillHideCallback(ok)
|
||||
if ok == false then
|
||||
page = 0
|
||||
playdate.wait(0.3)
|
||||
editLoad()
|
||||
end
|
||||
end
|
|
@ -5,6 +5,7 @@ import "Player"
|
|||
import "Map"
|
||||
import "Menu"
|
||||
import "Saws"
|
||||
import "Editor"
|
||||
|
||||
mode = "menu"
|
||||
map = "levels/level1.json"
|
||||
|
@ -16,8 +17,9 @@ local font <const> = gfx.font.new("gfx/big")
|
|||
gfx.setFont(font)
|
||||
gfx.setBackgroundColor(gfx.kColorBlack)
|
||||
|
||||
local song1 <const> = playdate.sound.sampleplayer.new("sfx/song1")
|
||||
song1:play(0, 1)
|
||||
song = playdate.sound.fileplayer.new("sfx/song1")
|
||||
song:play(0)
|
||||
|
||||
local imgCrank = gfx.image.new("gfx/crank")
|
||||
|
||||
gfx.setColor(gfx.kColorWhite)
|
||||
|
@ -45,6 +47,9 @@ function playdate.update()
|
|||
gfx.clear(gfx.kColorBlack)
|
||||
gfx.sprite.update()
|
||||
drawTiles()
|
||||
elseif mode == "newproj" then
|
||||
gfx.clear()
|
||||
updateNewproj()
|
||||
end
|
||||
updateSaws()
|
||||
end
|
|
@ -18,6 +18,7 @@ function addMap(_file)
|
|||
end
|
||||
|
||||
if level.saws then loadBlades(level.saws) end
|
||||
if level.rotators then loadSpins(level.rotators) end
|
||||
addPlayer(level.rocket.x,level.rocket.y, level.bigrocket.x, level.bigrocket.y)
|
||||
|
||||
gfx.sprite.addWallSprites(tilemap, {0,1})
|
||||
|
|
|
@ -6,7 +6,7 @@ local index = 0
|
|||
|
||||
local menuitems = {}
|
||||
local menu = null
|
||||
local page = 0
|
||||
page = 0
|
||||
|
||||
local imgCursor = gfx.image.new("gfx/cursor")
|
||||
local imgBytes = gfx.image.new("gfx/bytes")
|
||||
|
@ -27,7 +27,6 @@ end
|
|||
function createMenu(items)
|
||||
killBlades()
|
||||
killPlayer()
|
||||
mode = "menu"
|
||||
controlX = -80
|
||||
index = 0
|
||||
menuitems = {}
|
||||
|
@ -37,6 +36,14 @@ function createMenu(items)
|
|||
menuitems[i] = {name=items[i],y=_y}
|
||||
_y -= 20
|
||||
end
|
||||
|
||||
if mode == "game" then
|
||||
song:stop()
|
||||
song:load("sfx/song1")
|
||||
song:play(0)
|
||||
end
|
||||
|
||||
mode = "menu"
|
||||
end
|
||||
|
||||
function updateMenu()
|
||||
|
@ -65,6 +72,8 @@ function updateMenu()
|
|||
|
||||
if playdate.buttonJustPressed(playdate.kButtonA) or playdate.buttonJustPressed(playdate.kButtonRight) then
|
||||
menuButtonPress(menuitems[#menuitems - math.floor(index)].name)
|
||||
elseif playdate.buttonJustPressed(playdate.kButtonB) or playdate.buttonJustPressed(playdate.kButtonLeft) then
|
||||
menuButtonPress("BACK")
|
||||
end
|
||||
|
||||
imgBytes:draw(0,0)
|
||||
|
@ -93,6 +102,29 @@ local function customLoad()
|
|||
index = #lvls
|
||||
end
|
||||
|
||||
function editLoad()
|
||||
local lvls = playdate.file.listFiles("levels")
|
||||
local m = {}
|
||||
m[0], m[1], m[2] = "edits", "BACK", "CREATE NEW"
|
||||
if #lvls - ((6*page)) <= 0 then page = 0 end
|
||||
if #lvls < 6 then
|
||||
for i = 1, #lvls, 1 do
|
||||
m[i+2] = lvls[i]:upper()
|
||||
end
|
||||
elseif lvls[1 + (6*page)] then
|
||||
m[2] = "NEXT PAGE"
|
||||
for i = 1, 6, 1 do
|
||||
if lvls[i+(6*page)] then
|
||||
m[i+3] = lvls[i+(6*page)]:upper()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
createMenu(m)
|
||||
|
||||
index = #lvls
|
||||
end
|
||||
|
||||
function menuButtonPress(name)
|
||||
if name == "START NEW GAME" and menu == "mainPlay" then
|
||||
local m = {}
|
||||
|
@ -113,6 +145,11 @@ function menuButtonPress(name)
|
|||
elseif name == "USER LEVELS" then
|
||||
page = 0
|
||||
customLoad()
|
||||
elseif name == "LEVEL EDITOR" then
|
||||
page = 0
|
||||
editLoad()
|
||||
elseif name == "CREATE NEW" then
|
||||
newProject()
|
||||
elseif name == "NEXT PAGE" then
|
||||
page += 1
|
||||
if menu == "customs" then
|
||||
|
|
|
@ -23,6 +23,9 @@ sprBigRocket:setCollideRect(8,8,48,48)
|
|||
sprBigRocket:setGroups({2})
|
||||
|
||||
function addPlayer(_x,_y,__x,__y)
|
||||
song:stop()
|
||||
song:load("sfx/song2")
|
||||
song:play(0)
|
||||
exists = true
|
||||
dead = false
|
||||
scale = 1
|
||||
|
|
|
@ -32,6 +32,20 @@ function loadBlades(_blades)
|
|||
end
|
||||
end
|
||||
|
||||
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:setCollideRect(0,0,16,16)
|
||||
else
|
||||
s.middle = gfx.sprite.new(imgTarget)
|
||||
end
|
||||
s.middle:moveTo(s.x,s.y)
|
||||
s.middle:add()
|
||||
end
|
||||
end
|
||||
|
||||
function updateSaws()
|
||||
for b=1, #blades, 1 do
|
||||
b = blades[b]
|
||||
|
|
1
Source/levels/rotate.json
Normal file
1
Source/levels/rotate.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"bigrocket":{"x":73.333333,"y":144.79638},"dimensions":{"x":22,"y":17},"rocket":{"x":276.27907,"y":144.651163},"saws":[{"ends":{"x":200.000014,"y":81.105913},"speed":1,"start":{"x":141.013825,"y":168.202765}},{"ends":{"x":313.824857,"y":185.714272},"speed":3,"start":{"x":235.023041,"y":184.331797}}],"rotators":[{"x":200,"y":200,"arms":3,"armlen":2,"speed":20,"middle":true}],"tiles":[{"t":2,"x":2,"y":1},{"t":2,"x":14,"y":1},{"t":2,"x":14,"y":5},{"t":2,"x":22,"y":5},{"t":2,"x":8,"y":6},{"t":2,"x":2,"y":12},{"t":2,"x":8,"y":12},{"t":2,"x":11,"y":12},{"t":2,"x":14,"y":12},{"t":2,"x":8,"y":17},{"t":2,"x":22,"y":17},{"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":15,"y":5},{"t":3,"x":16,"y":5},{"t":3,"x":17,"y":5},{"t":3,"x":18,"y":5},{"t":3,"x":19,"y":5},{"t":3,"x":20,"y":5},{"t":3,"x":21,"y":5},{"t":3,"x":3,"y":12},{"t":3,"x":4,"y":12},{"t":3,"x":5,"y":12},{"t":3,"x":6,"y":12},{"t":3,"x":7,"y":12},{"t":3,"x":9,"y":12},{"t":3,"x":10,"y":12},{"t":3,"x":9,"y":17},{"t":3,"x":10,"y":17},{"t":3,"x":11,"y":17},{"t":3,"x":12,"y":17},{"t":3,"x":13,"y":17},{"t":3,"x":14,"y":17},{"t":3,"x":15,"y":17},{"t":3,"x":16,"y":17},{"t":3,"x":17,"y":17},{"t":3,"x":18,"y":17},{"t":3,"x":19,"y":17},{"t":3,"x":20,"y":17},{"t":3,"x":21,"y":17},{"t":4,"x":2,"y":2},{"t":4,"x":14,"y":2},{"t":4,"x":2,"y":3},{"t":4,"x":14,"y":3},{"t":4,"x":2,"y":4},{"t":4,"x":14,"y":4},{"t":4,"x":2,"y":5},{"t":4,"x":2,"y":6},{"t":4,"x":14,"y":6},{"t":4,"x":22,"y":6},{"t":4,"x":2,"y":7},{"t":4,"x":8,"y":7},{"t":4,"x":14,"y":7},{"t":4,"x":22,"y":7},{"t":4,"x":2,"y":8},{"t":4,"x":8,"y":8},{"t":4,"x":14,"y":8},{"t":4,"x":22,"y":8},{"t":4,"x":2,"y":9},{"t":4,"x":8,"y":9},{"t":4,"x":14,"y":9},{"t":4,"x":22,"y":9},{"t":4,"x":2,"y":10},{"t":4,"x":8,"y":10},{"t":4,"x":14,"y":10},{"t":4,"x":22,"y":10},{"t":4,"x":2,"y":11},{"t":4,"x":8,"y":11},{"t":4,"x":14,"y":11},{"t":4,"x":22,"y":11},{"t":4,"x":22,"y":12},{"t":4,"x":8,"y":13},{"t":4,"x":22,"y":13},{"t":4,"x":8,"y":14},{"t":4,"x":22,"y":14},{"t":4,"x":8,"y":15},{"t":4,"x":22,"y":15},{"t":4,"x":8,"y":16},{"t":4,"x":22,"y":16}]}
|
BIN
Source/sfx/song2.wav
Normal file
BIN
Source/sfx/song2.wav
Normal file
Binary file not shown.
Loading…
Reference in a new issue