add tilemap/tilesheet

This commit is contained in:
asrael 2025-09-24 00:39:44 -05:00
parent c18896def0
commit ff698730f1
13 changed files with 841 additions and 28 deletions

View file

@ -189,4 +189,64 @@ function pxl8.gfx_fade_palette(start, count, amount, target_color)
C.pxl8_gfx_fade_palette(gfx, start, count, amount, target_color)
end
function pxl8.tilesheet_new(tile_size)
return C.pxl8_tilesheet_new(tile_size or 16)
end
function pxl8.tilesheet_destroy(tilesheet)
C.pxl8_tilesheet_destroy(tilesheet)
end
function pxl8.tilesheet_load(tilesheet, filepath)
return C.pxl8_tilesheet_load(tilesheet, filepath, gfx)
end
function pxl8.tilemap_new(width, height, tile_size)
return C.pxl8_tilemap_new(width, height, tile_size or 16)
end
function pxl8.tilemap_destroy(tilemap)
C.pxl8_tilemap_destroy(tilemap)
end
function pxl8.tilemap_set_tilesheet(tilemap, tilesheet)
return C.pxl8_tilemap_set_tilesheet(tilemap, tilesheet)
end
function pxl8.tilemap_set_tile(tilemap, layer, x, y, tile_id, flags)
C.pxl8_tilemap_set_tile(tilemap, layer or 0, x, y, tile_id or 0, flags or 0)
end
function pxl8.tilemap_get_tile_id(tilemap, layer, x, y)
return C.pxl8_tilemap_get_tile_id(tilemap, layer or 0, x, y)
end
function pxl8.tilemap_set_camera(tilemap, x, y)
C.pxl8_tilemap_set_camera(tilemap, x, y)
end
function pxl8.tilemap_render(tilemap)
C.pxl8_tilemap_render(tilemap, gfx)
end
function pxl8.tilemap_render_layer(tilemap, layer)
C.pxl8_tilemap_render_layer(tilemap, gfx, layer)
end
function pxl8.tilemap_is_solid(tilemap, x, y)
return C.pxl8_tilemap_is_solid(tilemap, x, y)
end
function pxl8.tilemap_check_collision(tilemap, x, y, w, h)
return C.pxl8_tilemap_check_collision(tilemap, x, y, w, h)
end
pxl8.TILE_FLIP_X = 1
pxl8.TILE_FLIP_Y = 2
pxl8.TILE_SOLID = 4
pxl8.TILE_TRIGGER = 8
pxl8.gfx = gfx
pxl8.input = input
return pxl8