started work on menu system
This commit is contained in:
parent
8ce96aaba5
commit
e8c43c72df
4 changed files with 34 additions and 9 deletions
|
@ -2,26 +2,35 @@ import "CoreLibs/graphics"
|
|||
import "CoreLibs/sprites"
|
||||
import "Player"
|
||||
import "Map"
|
||||
import "Menu"
|
||||
|
||||
local mode = "menu"
|
||||
|
||||
local gfx <const> = playdate.graphics
|
||||
local disp <const> = playdate.display
|
||||
|
||||
local font <const> = gfx.font.new("gfx/font")
|
||||
|
||||
gfx.setFont(font)
|
||||
gfx.setBackgroundColor(gfx.kColorBlack)
|
||||
|
||||
local song1 <const> = playdate.sound.sampleplayer.new("sfx/song1")
|
||||
song1:play(0, 1)
|
||||
|
||||
addMap("levels/level1.json")
|
||||
gfx.setColor(gfx.kColorWhite)
|
||||
|
||||
addPlayer(50,50)
|
||||
--addMap("levels/level1.json")
|
||||
|
||||
--addPlayer(50,50)
|
||||
|
||||
function playdate.update()
|
||||
if mode == "menu" then
|
||||
updateMenu()
|
||||
|
||||
elseif mode == "game" then
|
||||
updatePlayer()
|
||||
|
||||
gfx.clear(gfx.kColorBlack)
|
||||
gfx.sprite.update()
|
||||
drawTiles()
|
||||
end
|
||||
end
|
|
@ -2,10 +2,10 @@ local gfx <const> = playdate.graphics
|
|||
local tileTable <const> = gfx.imagetable.new("gfx/tiles")
|
||||
local tilemap <const> = gfx.tilemap.new()
|
||||
tilemap:setImageTable(tileTable)
|
||||
tilemap:setSize(100,100)
|
||||
|
||||
function addMap(_file)
|
||||
local level = json.decodeFile(_file)
|
||||
tilemap:setSize(level.dimensions.x,level.dimensions.x)
|
||||
for i = 1, #level.tiles, 1 do
|
||||
tilemap:setTileAtPosition(level.tiles[i].x,level.tiles[i].y,level.tiles[i].t)
|
||||
end
|
||||
|
|
16
Source/Menu.lua
Normal file
16
Source/Menu.lua
Normal file
|
@ -0,0 +1,16 @@
|
|||
local gfx <const> = playdate.graphics
|
||||
local controlY = 0
|
||||
|
||||
local crankY = 0
|
||||
|
||||
function updateMenu()
|
||||
gfx.clear(gfx.kColorBlack)
|
||||
-- input
|
||||
if playdate.buttonJustPressed(playdate.kButtonUp) then
|
||||
crankY -= 1
|
||||
elseif playdate.buttonJustPressed(playdate.kButtonDown) then
|
||||
crankY += 1
|
||||
end
|
||||
|
||||
gfx.fillRect(0,controlY + (10 * crankY),50,10)
|
||||
end
|
|
@ -1 +1 @@
|
|||
{"tiles":[{"x":1,"y":1,"t":2},{"x":2,"y":1,"t":3},{"x":3,"y":1,"t":3},{"x":4,"y":1,"t":2}]}
|
||||
{"tiles":[{"x":1,"y":1,"t":2},{"x":2,"y":1,"t":3},{"x":3,"y":1,"t":3},{"x":4,"y":1,"t":2}],"dimensions":{"x":4,"y":2}}
|
Loading…
Reference in a new issue