Files
dusk/assets/scene/minesweeper.lua
Dominic Masters e1f08b07aa
All checks were successful
Build Dusk / run-tests (push) Successful in 1m36s
Build Dusk / build-linux (push) Successful in 1m14s
Build Dusk / build-psp (push) Successful in 2m2s
Build Dusk / build-dolphin (push) Successful in 2m49s
Need a break from Dolphin
2026-02-09 22:18:44 -06:00

105 lines
2.1 KiB
Lua

module('spritebatch')
module('camera')
module('color')
module('ui')
module('screen')
module('time')
module('glm')
module('text')
module('tileset')
module('texture')
CELL_STATE_DEFAULT = 0
CELL_STATE_HOVER = 1
CELL_STATE_DOWN = 2
CELL_STATE_DISABLED = 3
screenSetBackground(colorBlack())
camera = cameraCreate(CAMERA_PROJECTION_TYPE_ORTHOGRAPHIC)
tilesetUi = tilesetGetByName("ui")
textureUi = textureLoad(tilesetUi.texture)
textureGrid = textureLoad("minesweeper/grid_bg.dpi")
tilesetCell = tilesetGetByName("cell")
textureCell = textureLoad(tilesetCell.texture)
-- cellSliceDefault = tilesetPositionGetUV(tilesetCell, 3, 5)
cellSliceDefault = tilesetPositionGetUV(tilesetCell, 0, 4)
-- cellSliceHover = tilesetPositionGetUV(tilesetCell, 3, 4)
-- cellSliceDown = tilesetPositionGetUV(tilesetCell, 3, 6)
-- cellSliceDisabled = tilesetPositionGetUV(tilesetCell, 3, 7)
width = 10
height = 14
i = 0
cells = {}
for y = 1, height do
for x = 1, width do
cells[i] = CELL_STATE_DEFAULT
i = i + 1
end
end
function cellDraw(x, y, type)
slice = cellSliceDefault
spriteBatchPush(textureCell,
x, y,
x + tilesetCell.tileWidth, y + tilesetCell.tileHeight,
colorWhite(),
slice.u0, slice.v0,
slice.u1, slice.v1
)
end
function backgroundDraw()
local t = (TIME.time / 20) % 1
local scaleX = screenGetWidth() / textureGrid.width
local scaleY = screenGetHeight() / textureGrid.height
local u0 = t * scaleX
local v0 = t * scaleY
local u1 = scaleX + u0
local v1 = scaleY + v0
spriteBatchPush(textureGrid,
0, 0,
screenGetWidth(), screenGetHeight(),
colorWhite(),
u0, v0,
u1, v1
)
end
function sceneDispose()
end
function sceneUpdate()
end
function sceneRender()
-- UI
cameraPushMatrix(camera)
camera.bottom = screenGetHeight()
camera.right = screenGetWidth()
cellDraw(0, 0, 0)
-- backgroundDraw()
-- offsetX = 32
-- offsetY = 32
-- for y = 0, height - 1 do
-- for x = 0, width - 1 do
-- cellDraw(
-- x * tilesetCell.tileWidth + offsetX,
-- y * tilesetCell.tileHeight + offsetY,
-- cells[i]
-- )
-- end
-- end
spriteBatchFlush()
cameraPopMatrix()
end