test some stuff
Some checks failed
Build Dusk / run-tests (push) Failing after 2m48s
Build Dusk / build-linux (push) Failing after 2m21s
Build Dusk / build-psp (push) Failing after 1m46s
Build Dusk / build-dolphin (push) Failing after 1m57s

This commit is contained in:
2026-02-09 10:39:46 -06:00
parent 2f5dccc3ef
commit bd54469891
7 changed files with 115 additions and 22 deletions

View File

@@ -4,3 +4,5 @@
# https://opensource.org/licenses/MIT
add_asset(TILESET ui.png type=PALETTIZED tileWidth=8 tileHeight=8)
add_asset(TILESET cell.png type=PALETTIZED tileWidth=8 tileHeight=8)
add_asset(TILESET grid.png type=PALETTIZED tileWidth=8 tileHeight=8)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 B

After

Width:  |  Height:  |  Size: 168 B

View File

@@ -9,11 +9,85 @@ 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)
tileset = tilesetGetByName("ui")
ui = textureLoad(tileset.texture)
tilesetUi = tilesetGetByName("ui")
textureUi = textureLoad(tilesetUi.texture)
tilesetGrid = tilesetGetByName("grid")
textureGrid = textureLoad(tilesetGrid.texture)
gridPiece = tilesetPositionGetUV(tilesetGrid, 0, 0)
gridSlice = tilesetPositionGetUV(tilesetGrid, 11, 3)
tilesetCell = tilesetGetByName("cell")
textureCell = textureLoad(tilesetCell.texture)
cellSliceHover = tilesetPositionGetUV(tilesetCell, 3, 4)
cellSliceDefault = tilesetPositionGetUV(tilesetCell, 3, 5)
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)
if type == CELL_STATE_HOVER then
slice = cellSliceHover
elseif type == CELL_STATE_DOWN then
slice = cellSliceDown
elseif type == CELL_STATE_DISABLED then
slice = cellSliceDisabled
else
slice = cellSliceDefault
end
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 * 3) % 1
local offXStart = gridPiece.u1 * t
local offYStart = gridPiece.v1 * t
local offXEnd = offXStart + gridPiece.u1
local offYEnd = offYStart + gridPiece.v1
-- Tile background
local cols = math.ceil(screenGetWidth() / tilesetGrid.tileWidth)
local rows = math.ceil(screenGetHeight() / tilesetGrid.tileHeight)
for y = 0, rows do
for x = 0, cols do
spriteBatchPush(
textureGrid,
x * tilesetGrid.tileWidth, y * tilesetGrid.tileHeight,
(x + 1) * tilesetGrid.tileWidth, (y + 1) * tilesetGrid.tileHeight,
colorWhite(),
gridSlice.u0 + offXStart, gridSlice.v0 + offYStart,
gridSlice.u1 + offXEnd, gridSlice.v1 + offYEnd
)
end
end
end
function sceneDispose()
end
@@ -27,17 +101,20 @@ function sceneRender()
camera.bottom = screenGetHeight()
camera.right = screenGetWidth()
slice = tilesetTileGetUV(tileset, 0)
spriteBatchPush(ui,
0, 0,
ui.width * slice.u1, ui.height * slice.v1,
colorRainbow(),
slice.u0, slice.v0,
slice.u1, slice.v1
)
spriteBatchFlush()
backgroundDraw()
-- textDraw(0, 0, "Hello World", colorRainbow())
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

View File

@@ -27,9 +27,8 @@ void moduleColor(scriptcontext_t *context) {
lua_pushstring(context->luaState, "__tostring");
lua_pushcfunction(context->luaState, moduleColorToString);
lua_settable(context->luaState, -3);
lua_pop(context->luaState, 1);
}
lua_pop(context->luaState, 1);
lua_register(context->luaState, "color", moduleColorFuncColor);
lua_register(context->luaState, "colorRainbow", moduleColorRainbow);

View File

@@ -46,6 +46,21 @@ int moduleTilesetIndex(lua_State *l) {
} else if(stringCompare(key, "texture") == 0) {
lua_pushstring(l, ts->image);
return 1;
} else if(stringCompare(key, "tileWidth") == 0) {
lua_pushnumber(l, ts->tileWidth);
return 1;
} else if(stringCompare(key, "tileHeight") == 0) {
lua_pushnumber(l, ts->tileHeight);
return 1;
} else if(stringCompare(key, "tileCount") == 0) {
lua_pushnumber(l, ts->tileCount);
return 1;
} else if(stringCompare(key, "columns") == 0) {
lua_pushnumber(l, ts->columns);
return 1;
} else if(stringCompare(key, "rows") == 0) {
lua_pushnumber(l, ts->rows);
return 1;
}
lua_pushnil(l);

View File

@@ -13,21 +13,20 @@ void moduleTime(scriptcontext_t *ctx) {
// Script structure
if(luaL_newmetatable(ctx->luaState, "time_mt")) {
// Metatable is new, set __index
lua_pushstring(ctx->luaState, "__index");
lua_pushcfunction(ctx->luaState, moduleTimeIndex);
lua_settable(ctx->luaState, -3);
lua_setfield(ctx->luaState, -2, "__index");
}
lua_pop(ctx->luaState, 1);
// Global time struct
lua_pushlightuserdata(ctx->luaState, &TIME);
dusktime_t **ud = (dusktime_t**)lua_newuserdatauv(
ctx->luaState, sizeof(dusktime_t*), 0
);
*ud = &TIME;
luaL_setmetatable(ctx->luaState, "time_mt");
lua_setglobal(ctx->luaState, "TIME");
}
int moduleTimeIndex(lua_State *L) {
assertNotNull(L, "Lua state cannot be NULL.");
const char_t *key = lua_tostring(L, 2);
assertStrLenMin(key, 1, "Key cannot be empty.");

View File

@@ -45,6 +45,7 @@ def processPalettizedImage(asset):
elif color[3] == 0 and palColor[3] == 0:
break
else:
print('Pallete {} does not contain color #{}'.format(p['paletteName'], '{:02x}{:02x}{:02x}{:02x}'.format(color[0], color[1], color[2], color[3])))
hasAllColors = False
break
if hasAllColors: