diff --git a/assets/CMakeLists.txt b/assets/CMakeLists.txt index ce61067..b4d88af 100644 --- a/assets/CMakeLists.txt +++ b/assets/CMakeLists.txt @@ -15,7 +15,8 @@ add_subdirectory(locale) add_asset(SCRIPT init.lua) # Subdirs -add_subdirectory(entity) -add_subdirectory(map) +# add_subdirectory(entity) +# add_subdirectory(map) add_subdirectory(ui) -add_subdirectory(scene) \ No newline at end of file +add_subdirectory(minesweeper) +add_subdirectory(scene) diff --git a/assets/minesweeper/CMakeLists.txt b/assets/minesweeper/CMakeLists.txt new file mode 100644 index 0000000..96e0af1 --- /dev/null +++ b/assets/minesweeper/CMakeLists.txt @@ -0,0 +1,6 @@ +# Copyright (c) 2026 Dominic Masters +# +# This software is released under the MIT License. +# https://opensource.org/licenses/MIT + +add_asset(TILESET ui.png type=PALETTIZED tileWidth=8 tileHeight=8) \ No newline at end of file diff --git a/assets/minesweeper/background.png b/assets/minesweeper/background.png new file mode 100644 index 0000000..705b895 Binary files /dev/null and b/assets/minesweeper/background.png differ diff --git a/assets/minesweeper/border.png b/assets/minesweeper/border.png new file mode 100644 index 0000000..1b43d53 Binary files /dev/null and b/assets/minesweeper/border.png differ diff --git a/assets/minesweeper/cell.png b/assets/minesweeper/cell.png new file mode 100644 index 0000000..c00c9b3 Binary files /dev/null and b/assets/minesweeper/cell.png differ diff --git a/assets/minesweeper/grid.png b/assets/minesweeper/grid.png new file mode 100644 index 0000000..9db5901 Binary files /dev/null and b/assets/minesweeper/grid.png differ diff --git a/assets/minesweeper/ui.png b/assets/minesweeper/ui.png new file mode 100644 index 0000000..ba99805 Binary files /dev/null and b/assets/minesweeper/ui.png differ diff --git a/assets/palette/CMakeLists.txt b/assets/palette/CMakeLists.txt index d8eda53..52b3842 100644 --- a/assets/palette/CMakeLists.txt +++ b/assets/palette/CMakeLists.txt @@ -3,4 +3,5 @@ # This software is released under the MIT License. # https://opensource.org/licenses/MIT -add_asset(PALETTE palette0.png) \ No newline at end of file +add_asset(PALETTE palette0.png) +add_asset(PALETTE paletteMinesweeper.png) \ No newline at end of file diff --git a/assets/palette/paletteMinesweeper.png b/assets/palette/paletteMinesweeper.png new file mode 100644 index 0000000..26bb086 Binary files /dev/null and b/assets/palette/paletteMinesweeper.png differ diff --git a/assets/scene/CMakeLists.txt b/assets/scene/CMakeLists.txt index c58d25f..dae18d6 100644 --- a/assets/scene/CMakeLists.txt +++ b/assets/scene/CMakeLists.txt @@ -3,4 +3,5 @@ # This software is released under the MIT License. # https://opensource.org/licenses/MIT -add_asset(SCRIPT initial.lua) \ No newline at end of file +add_asset(SCRIPT initial.lua) +add_asset(SCRIPT minesweeper.lua) \ No newline at end of file diff --git a/assets/scene/minesweeper.lua b/assets/scene/minesweeper.lua new file mode 100644 index 0000000..d2c5820 --- /dev/null +++ b/assets/scene/minesweeper.lua @@ -0,0 +1,27 @@ +module('spritebatch') +module('camera') +module('color') +module('ui') +module('screen') +module('time') +module('glm') + +screenSetBackground(colorBlack()) +camera = cameraCreate(CAMERA_PROJECTION_TYPE_ORTHOGRAPHIC) + +function sceneDispose() +end + +function sceneUpdate() +end + +function sceneRender() + -- UI + cameraPushMatrix(camera) + camera.bottom = screenGetHeight() + camera.right = screenGetWidth() + + + + cameraPopMatrix() +end \ No newline at end of file diff --git a/tools/asset/process/image.py b/tools/asset/process/image.py index d2b202b..570527a 100644 --- a/tools/asset/process/image.py +++ b/tools/asset/process/image.py @@ -35,10 +35,23 @@ def processPalettizedImage(asset): imagePalette = extractPaletteFromImage(image) # Find palette that contains every color - for palette in palettes: - if all(color in palette['pixels'] for color in imagePalette): + palette = None + for p in palettes: + hasAllColors = True + for color in imagePalette: + for palColor in p['pixels']: + if color[0] == palColor[0] and color[1] == palColor[1] and color[2] == palColor[2] and color[3] == palColor[3]: + break + elif color[3] == 0 and palColor[3] == 0: + break + else: + hasAllColors = False + break + if hasAllColors: + palette = p break - else: + + if palette is None: palette = palettes[0] # Just to avoid reference error print(f"No matching palette found for {assetPath}!") # Find which pixel is missing diff --git a/tools/asset/process/palette.py b/tools/asset/process/palette.py index 3a1012b..46a7094 100644 --- a/tools/asset/process/palette.py +++ b/tools/asset/process/palette.py @@ -1,3 +1,4 @@ +import json import os from PIL import Image import datetime @@ -78,6 +79,7 @@ def processPalette(asset): def processPaletteList(): data = f"// Auto-generated palette list\n" + print(f"Generating palette list with {len(palettes)} palettes.") for palette in palettes: data += f"#include \"{palette['headerFile']}\"\n" data += f"\n"