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 "CoreLibs/sprites"
|
||||||
import "Player"
|
import "Player"
|
||||||
import "Map"
|
import "Map"
|
||||||
|
import "Menu"
|
||||||
|
|
||||||
|
local mode = "menu"
|
||||||
|
|
||||||
local gfx <const> = playdate.graphics
|
local gfx <const> = playdate.graphics
|
||||||
local disp <const> = playdate.display
|
local disp <const> = playdate.display
|
||||||
|
|
||||||
local font <const> = gfx.font.new("gfx/font")
|
local font <const> = gfx.font.new("gfx/font")
|
||||||
|
|
||||||
gfx.setFont(font)
|
gfx.setFont(font)
|
||||||
gfx.setBackgroundColor(gfx.kColorBlack)
|
gfx.setBackgroundColor(gfx.kColorBlack)
|
||||||
|
|
||||||
local song1 <const> = playdate.sound.sampleplayer.new("sfx/song1")
|
local song1 <const> = playdate.sound.sampleplayer.new("sfx/song1")
|
||||||
song1:play(0, 1)
|
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()
|
function playdate.update()
|
||||||
|
if mode == "menu" then
|
||||||
|
updateMenu()
|
||||||
|
|
||||||
|
elseif mode == "game" then
|
||||||
updatePlayer()
|
updatePlayer()
|
||||||
|
|
||||||
gfx.clear(gfx.kColorBlack)
|
gfx.clear(gfx.kColorBlack)
|
||||||
gfx.sprite.update()
|
gfx.sprite.update()
|
||||||
drawTiles()
|
drawTiles()
|
||||||
end
|
end
|
||||||
|
end
|
|
@ -2,10 +2,10 @@ local gfx <const> = playdate.graphics
|
||||||
local tileTable <const> = gfx.imagetable.new("gfx/tiles")
|
local tileTable <const> = gfx.imagetable.new("gfx/tiles")
|
||||||
local tilemap <const> = gfx.tilemap.new()
|
local tilemap <const> = gfx.tilemap.new()
|
||||||
tilemap:setImageTable(tileTable)
|
tilemap:setImageTable(tileTable)
|
||||||
tilemap:setSize(100,100)
|
|
||||||
|
|
||||||
function addMap(_file)
|
function addMap(_file)
|
||||||
local level = json.decodeFile(_file)
|
local level = json.decodeFile(_file)
|
||||||
|
tilemap:setSize(level.dimensions.x,level.dimensions.x)
|
||||||
for i = 1, #level.tiles, 1 do
|
for i = 1, #level.tiles, 1 do
|
||||||
tilemap:setTileAtPosition(level.tiles[i].x,level.tiles[i].y,level.tiles[i].t)
|
tilemap:setTileAtPosition(level.tiles[i].x,level.tiles[i].y,level.tiles[i].t)
|
||||||
end
|
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