Refator pass 1
21
archive/rpg/game.c
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Copyright (c) 2025 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "game/game.h"
|
||||
|
||||
errorret_t gameInit(void) {
|
||||
printf("Init RPG\n");
|
||||
errorOk();
|
||||
}
|
||||
|
||||
void gameUpdate(void) {
|
||||
|
||||
}
|
||||
|
||||
void gameDispose(void) {
|
||||
|
||||
}
|
@@ -7,8 +7,8 @@
|
||||
|
||||
#include "sceneoverworld.h"
|
||||
#include "rpg/entity/entity.h"
|
||||
#include "display/spritebatch/spritebatch.h"
|
||||
#include "display/framebuffer/framebuffer.h"
|
||||
#include "display/spritebatch.h"
|
||||
#include "display/framebuffer.h"
|
||||
#include "display/scene/scenemanager.h"
|
||||
#include "display/mesh/quad.h"
|
||||
#include "asset/assetmanager.h"
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "screen.h"
|
||||
#include "assert/assert.h"
|
||||
#include "display/spritebatch/spritebatch.h"
|
||||
#include "display/spritebatch.h"
|
||||
|
||||
screen_t SCREEN;
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "display/camera.h"
|
||||
#include "display/framebuffer/framebuffer.h"
|
||||
#include "display/framebuffer.h"
|
||||
|
||||
typedef struct {
|
||||
#if DISPLAY_SIZE_DYNAMIC == 1
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "scenetest.h"
|
||||
#include "display/scene/scenemanager.h"
|
||||
#include "display/spritebatch/spritebatch.h"
|
||||
#include "display/spritebatch.h"
|
||||
|
||||
scenetest_t SCENE_TEST;
|
||||
|
@@ -3,10 +3,11 @@
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
if(DUSK_TARGET_GAME STREQUAL "rpg")
|
||||
add_subdirectory(rpg)
|
||||
elseif(DUSK_TARGET_GAME STREQUAL "minesweeper")
|
||||
add_subdirectory(minesweeper)
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown game specified: ${DUSK_TARGET_GAME}")
|
||||
endif()
|
||||
set(DUSK_GAME_ASSETS_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL ${DUSK_CACHE_TARGET})
|
||||
|
||||
add_subdirectory(palette)# Palette asset needs to be added before any images.
|
||||
|
||||
add_subdirectory(config)
|
||||
add_subdirectory(entity)
|
||||
add_subdirectory(map)
|
||||
add_subdirectory(ui)
|
@@ -4,4 +4,5 @@
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
add_asset(CONFIG init.dcf)
|
||||
add_asset(CONFIG init_psp.dcf)
|
||||
add_asset(CONFIG init-base.dcf)
|
||||
add_asset(CONFIG init-psp.dcf)
|
2
assets/config/init-base.dcf
Normal file
@@ -0,0 +1,2 @@
|
||||
echo " = Dawn Init = ";
|
||||
fps 1;
|
@@ -1,4 +1,6 @@
|
||||
echo " = Dawn PSP = ";
|
||||
exec "config/init-base";
|
||||
|
||||
screen backbuffer;
|
||||
|
||||
bind up up;
|
||||
bind down down;
|
||||
@@ -8,10 +10,7 @@ bind cross accept;
|
||||
bind circle cancel;
|
||||
bind select toggleconsole;
|
||||
bind start toggleconsole;
|
||||
|
||||
bind lstick_negative_y up;
|
||||
bind lstick_positive_y down;
|
||||
bind lstick_negative_x left;
|
||||
bind lstick_positive_x right;
|
||||
|
||||
fps 1;
|
||||
bind lstick_positive_x right;
|
@@ -1,4 +1,6 @@
|
||||
echo " = Dawn Init = ";
|
||||
exec "config/init-base";
|
||||
|
||||
screen height 270;
|
||||
|
||||
bind ` toggleconsole;
|
||||
bind w up;
|
||||
@@ -12,6 +14,4 @@ bind right right;
|
||||
bind e accept;
|
||||
bind enter accept;
|
||||
bind q cancel;
|
||||
bind esc quit;
|
||||
|
||||
fps 1;
|
||||
bind esc quit;
|
Before Width: | Height: | Size: 336 B After Width: | Height: | Size: 336 B |
@@ -1,11 +0,0 @@
|
||||
# Copyright (c) 2025 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
set(DUSK_GAME_ASSETS_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL ${DUSK_CACHE_TARGET})
|
||||
|
||||
# Palette asset needs to be added before any images.
|
||||
add_subdirectory(palette)
|
||||
add_subdirectory(config)
|
||||
add_subdirectory(ui)
|
@@ -1,19 +0,0 @@
|
||||
echo " = Dawn Init = ";
|
||||
|
||||
bind ` toggleconsole;
|
||||
bind w up;
|
||||
bind s down;
|
||||
bind a left;
|
||||
bind d right;
|
||||
bind up up;
|
||||
bind down down;
|
||||
bind left left;
|
||||
bind right right;
|
||||
bind e accept;
|
||||
bind enter accept;
|
||||
bind q cancel;
|
||||
bind esc quit;
|
||||
|
||||
fps 1;
|
||||
|
||||
scene sweep;
|
@@ -1,19 +0,0 @@
|
||||
echo " = Dawn PSP = ";
|
||||
|
||||
bind up up;
|
||||
bind down down;
|
||||
bind left left;
|
||||
bind right right;
|
||||
bind cross accept;
|
||||
bind circle cancel;
|
||||
bind select toggleconsole;
|
||||
bind start toggleconsole;
|
||||
|
||||
bind lstick_negative_y up;
|
||||
bind lstick_positive_y down;
|
||||
bind lstick_negative_x left;
|
||||
bind lstick_positive_x right;
|
||||
|
||||
fps 1;
|
||||
|
||||
scene sweep;
|
Before Width: | Height: | Size: 145 B |
@@ -1,4 +0,0 @@
|
||||
# Copyright (c) 2025 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
Before Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 4.2 KiB |
@@ -1,9 +0,0 @@
|
||||
# Copyright (c) 2025 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
add_asset(TILESET minogram.png type=ALPHA tileWidth=6 tileHeight=10 columns=16 rows=6)
|
||||
add_asset(TILESET ui.png type=PALETTIZED tileWidth=16 tileHeight=16)
|
||||
add_asset(TILESET ui_frame.png type=PALETTIZED tileWidth=16 tileHeight=16)
|
||||
add_asset(TILESET background.png type=PALETTIZED tileWidth=16 tileHeight=16)
|
Before Width: | Height: | Size: 268 B |
Before Width: | Height: | Size: 421 B |
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 293 B |
Before Width: | Height: | Size: 241 B After Width: | Height: | Size: 241 B |
@@ -1,13 +0,0 @@
|
||||
# Copyright (c) 2025 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
set(DUSK_GAME_ASSETS_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL ${DUSK_CACHE_TARGET})
|
||||
|
||||
add_subdirectory(palette)# Palette asset needs to be added before any images.
|
||||
|
||||
add_subdirectory(config)
|
||||
add_subdirectory(entity)
|
||||
add_subdirectory(map)
|
||||
add_subdirectory(ui)
|
@@ -1,7 +0,0 @@
|
||||
# Copyright (c) 2025 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
add_asset(CONFIG init.dcf)
|
||||
add_asset(CONFIG init_psp.dcf)
|
@@ -1,6 +0,0 @@
|
||||
# Copyright (c) 2025 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
add_asset(PALETTE palette0.png)
|
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 758 B After Width: | Height: | Size: 758 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
@@ -33,7 +33,6 @@ add_subdirectory(console)
|
||||
add_subdirectory(display)
|
||||
add_subdirectory(engine)
|
||||
add_subdirectory(error)
|
||||
add_subdirectory(game)
|
||||
add_subdirectory(input)
|
||||
# add_subdirectory(locale)
|
||||
add_subdirectory(physics)
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "error/error.h"
|
||||
#include "display/texture/texture.h"
|
||||
#include "display/texture.h"
|
||||
|
||||
#define ASSET_ALPHA_IMAGE_WIDTH_MAX 256
|
||||
#define ASSET_ALPHA_IMAGE_HEIGHT_MAX 256
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "error/error.h"
|
||||
#include "display/texture/texture.h"
|
||||
#include "display/texture.h"
|
||||
|
||||
#define ASSET_PALETTE_IMAGE_WIDTH_MAX 128
|
||||
#define ASSET_PALETTE_IMAGE_HEIGHT_MAX 128
|
||||
|
22
src/console/cmd/cmdscreen.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Copyright (c) 2025 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "console/console.h"
|
||||
#include "display/screen.h"
|
||||
|
||||
void cmdScreen(const consolecmdexec_t *exec) {
|
||||
if(exec->argc < 1) {
|
||||
consolePrint("Expected 1 argument: <mode> [value]");
|
||||
return;
|
||||
}
|
||||
|
||||
if(strcmp(exec->argv[0], "backbuffer") == 0) {
|
||||
SCREEN.mode = SCREEN_MODE_BACKBUFFER;
|
||||
return;
|
||||
}
|
||||
}
|
@@ -20,6 +20,7 @@
|
||||
#include "console/cmd/cmdtoggleconsole.h"
|
||||
#include "console/cmd/cmdalias.h"
|
||||
#include "console/cmd/cmdscene.h"
|
||||
#include "console/cmd/cmdscreen.h"
|
||||
|
||||
console_t CONSOLE;
|
||||
|
||||
@@ -36,6 +37,7 @@ void consoleInit() {
|
||||
consoleRegCmd("toggleconsole", cmdToggleConsole);
|
||||
consoleRegCmd("alias", cmdAlias);
|
||||
consoleRegCmd("scene", cmdScene);
|
||||
consoleRegCmd("screen", cmdScreen);
|
||||
|
||||
#if CONSOLE_POSIX
|
||||
threadInit(&CONSOLE.thread, consoleInputThread);
|
||||
|
@@ -7,17 +7,17 @@
|
||||
target_sources(${DUSK_TARGET_NAME}
|
||||
PRIVATE
|
||||
display.c
|
||||
framebuffer.c
|
||||
camera.c
|
||||
tileset.c
|
||||
screen.c
|
||||
texture.c
|
||||
spritebatch.c
|
||||
)
|
||||
|
||||
# Subdirectories
|
||||
add_subdirectory(framebuffer)
|
||||
add_subdirectory(mesh)
|
||||
add_subdirectory(palette)
|
||||
add_subdirectory(texture)
|
||||
add_subdirectory(spritebatch)
|
||||
add_subdirectory(tileset)
|
||||
|
||||
if(DUSK_TARGET_SYSTEM STREQUAL "linux")
|
||||
target_compile_definitions(${DUSK_TARGET_NAME}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
#include "camera.h"
|
||||
#include "display/display.h"
|
||||
#include "assert/assert.h"
|
||||
#include "display/framebuffer/framebuffer.h"
|
||||
#include "display/framebuffer.h"
|
||||
|
||||
void cameraInit(camera_t *camera) {
|
||||
cameraInitPerspective(camera);
|
||||
|
@@ -7,11 +7,10 @@
|
||||
|
||||
#include "display/display.h"
|
||||
#include "console/console.h"
|
||||
#include "display/framebuffer/framebuffer.h"
|
||||
#include "display/framebuffer.h"
|
||||
#include "scene/scenemanager.h"
|
||||
#include "display/spritebatch/spritebatch.h"
|
||||
#include "display/spritebatch.h"
|
||||
#include "display/mesh/quad.h"
|
||||
#include "game/game.h"
|
||||
#include "display/screen.h"
|
||||
|
||||
display_t DISPLAY;
|
||||
|
@@ -9,7 +9,7 @@
|
||||
#include "displaydefs.h"
|
||||
#include "error/error.h"
|
||||
#include "display/camera.h"
|
||||
#include "display/framebuffer/framebuffer.h"
|
||||
#include "display/framebuffer.h"
|
||||
|
||||
typedef struct {
|
||||
#if DISPLAY_SDL2
|
||||
|
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "display/texture/texture.h"
|
||||
#include "display/texture.h"
|
||||
|
||||
#define FRAMEBUFFER_CLEAR_COLOR (1 << 0)
|
||||
#define FRAMEBUFFER_CLEAR_DEPTH (1 << 1)
|
@@ -1,10 +0,0 @@
|
||||
# Copyright (c) 2025 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Sources
|
||||
target_sources(${DUSK_TARGET_NAME}
|
||||
PRIVATE
|
||||
framebuffer.c
|
||||
)
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "dusk.h"
|
||||
#include "display/framebuffer/framebuffer.h"
|
||||
#include "display/framebuffer.h"
|
||||
#include "display/camera.h"
|
||||
#include "display/mesh/quad.h"
|
||||
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "display/mesh/quad.h"
|
||||
#include "display/texture/texture.h"
|
||||
#include "display/texture.h"
|
||||
|
||||
#define SPRITEBATCH_SPRITES_MAX 1
|
||||
#define SPRITEBATCH_VERTEX_COUNT (SPRITEBATCH_SPRITES_MAX * QUAD_VERTEX_COUNT)
|
@@ -1,13 +0,0 @@
|
||||
# Copyright (c) 2025 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Sources
|
||||
target_sources(${DUSK_TARGET_NAME}
|
||||
PRIVATE
|
||||
texture.c
|
||||
)
|
||||
|
||||
# Subdirs
|
||||
# add_subdirectory(draw)
|
@@ -6,5 +6,5 @@
|
||||
# Sources
|
||||
target_sources(${DUSK_TARGET_NAME}
|
||||
PRIVATE
|
||||
spritebatch.c
|
||||
tileset.c
|
||||
)
|
@@ -13,7 +13,6 @@
|
||||
#include "display/display.h"
|
||||
#include "scene/scenemanager.h"
|
||||
#include "asset/assetmanager.h"
|
||||
#include "game/game.h"
|
||||
|
||||
engine_t ENGINE;
|
||||
|
||||
@@ -31,11 +30,10 @@ errorret_t engineInit(void) {
|
||||
errorChain(assetManagerInit());
|
||||
errorChain(displayInit());
|
||||
errorChain(sceneManagerInit());
|
||||
errorChain(gameInit());
|
||||
|
||||
// Init scripts
|
||||
#if PSP
|
||||
consoleExec("exec config/init_psp.dcf");
|
||||
consoleExec("exec config/init-psp.dcf");
|
||||
#else
|
||||
consoleExec("exec config/init.dcf");
|
||||
#endif
|
||||
@@ -49,7 +47,6 @@ errorret_t engineUpdate(void) {
|
||||
consoleUpdate();
|
||||
assetManagerUpdate();
|
||||
|
||||
gameUpdate();
|
||||
sceneManagerUpdate();
|
||||
errorChain(displayUpdate());
|
||||
|
||||
@@ -57,11 +54,9 @@ errorret_t engineUpdate(void) {
|
||||
}
|
||||
|
||||
errorret_t engineDispose(void) {
|
||||
gameDispose();
|
||||
sceneManagerDispose();
|
||||
errorChain(displayDispose());
|
||||
assetManagerDispose();
|
||||
consoleDispose();
|
||||
|
||||
errorOk();
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
# Copyright (c) 2025 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
if(NOT DEFINED DUSK_TARGET_GAME)
|
||||
message(FATAL_ERROR "DUSK_TARGET_GAME is not defined.")
|
||||
endif()
|
||||
|
||||
string(TOUPPER "${DUSK_TARGET_GAME}" DUSK_TARGET_GAME_UPPER)
|
||||
|
||||
target_compile_definitions(${DUSK_TARGET_NAME}
|
||||
PRIVATE
|
||||
DUSK_TARGET_GAME=${DUSK_TARGET_GAME}
|
||||
DUSK_GAME_${DUSK_TARGET_GAME_UPPER}=1
|
||||
)
|
||||
|
||||
add_subdirectory(${DUSK_TARGET_GAME})
|
@@ -1,26 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2025 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "error/error.h"
|
||||
|
||||
/**
|
||||
* Initialize the game.
|
||||
*
|
||||
* @return Error code.
|
||||
*/
|
||||
errorret_t gameInit(void);
|
||||
|
||||
/**
|
||||
* Update the game state.
|
||||
*/
|
||||
void gameUpdate(void);
|
||||
|
||||
/**
|
||||
* Dispose of the game.
|
||||
*/
|
||||
void gameDispose(void);
|
@@ -1,15 +0,0 @@
|
||||
# Copyright (c) 2025 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Sources
|
||||
target_sources(${DUSK_TARGET_NAME}
|
||||
PRIVATE
|
||||
game.c
|
||||
)
|
||||
|
||||
# Subdirs
|
||||
add_subdirectory(display)
|
||||
add_subdirectory(scene)
|
||||
add_subdirectory(ui)
|
@@ -1,12 +0,0 @@
|
||||
# Copyright (c) 2025 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Sources
|
||||
target_sources(${DUSK_TARGET_NAME}
|
||||
PRIVATE
|
||||
sweepboard.c
|
||||
)
|
||||
|
||||
# Subdirs
|
@@ -1,30 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2025 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "sweepboard.h"
|
||||
|
||||
sweepboard_t SWEEPBOARD;
|
||||
|
||||
void sweepBoardInit() {
|
||||
// Initialize the sweep board
|
||||
}
|
||||
|
||||
void sweepBoardRender(const float_t x, const float_t y) {
|
||||
// Frame
|
||||
// uiFrameDrawTiled(
|
||||
// 32, 32,
|
||||
// w - 64, h - 64,
|
||||
// UI.frameTileset,
|
||||
// 0, 0,
|
||||
// true,
|
||||
// &UI.frameAsset->paletteImage.texture
|
||||
// );
|
||||
}
|
||||
|
||||
void sweepBoardDispose() {
|
||||
// Dispose of the sweep board resources
|
||||
}
|
@@ -1,25 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2025 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "dusk.h"
|
||||
|
||||
typedef struct {
|
||||
int32_t nothing;
|
||||
} sweepboard_t;
|
||||
|
||||
extern sweepboard_t SWEEPBOARD;
|
||||
|
||||
/**
|
||||
* Initializes the sweep board.
|
||||
*/
|
||||
void sweepBoardInit();
|
||||
|
||||
/**
|
||||
* Disposes of the sweep board resources.
|
||||
*/
|
||||
void sweepBoardDispose();
|
@@ -1,33 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2025 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "game/game.h"
|
||||
#include "game/minesweeper/ui/ui.h"
|
||||
#include "game/minesweeper/scene/scenesweep.h"
|
||||
#include "scene/scenemanager.h"
|
||||
#include "console/console.h"
|
||||
#include "display/screen.h"
|
||||
|
||||
errorret_t gameInit(void) {
|
||||
// Setup screen
|
||||
SCREEN.mode = SCREEN_MODE_FIXED_HEIGHT;
|
||||
SCREEN.fixedHeight.height = 270;
|
||||
|
||||
errorChain(uiInit());
|
||||
|
||||
sceneManagerRegisterScene(&SCENE_SWEEP);
|
||||
|
||||
errorOk();
|
||||
}
|
||||
|
||||
void gameUpdate(void) {
|
||||
|
||||
}
|
||||
|
||||
void gameDispose(void) {
|
||||
uiDispose();
|
||||
}
|
@@ -1,12 +0,0 @@
|
||||
# Copyright (c) 2025 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Sources
|
||||
target_sources(${DUSK_TARGET_NAME}
|
||||
PRIVATE
|
||||
scenesweep.c
|
||||
)
|
||||
|
||||
# Subdirs
|
@@ -1,76 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2025 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "scenesweep.h"
|
||||
#include "game/minesweeper/ui/ui.h"
|
||||
#include "ui/uiframe.h"
|
||||
#include "display/spritebatch/spritebatch.h"
|
||||
#include "game/minesweeper/display/sweepboard.h"
|
||||
#include "display/screen.h"
|
||||
|
||||
scene_t SCENE_SWEEP = {
|
||||
.name = "sweep",
|
||||
.init = sceneSweepInit,
|
||||
.update = sceneSweepUpdate,
|
||||
.render = sceneSweepRender,
|
||||
.dispose = sceneSweepDispose,
|
||||
.background = color_hex(0x48413cff)
|
||||
};
|
||||
|
||||
scenesweep_t SCENE_SWEEP_DATA;
|
||||
|
||||
errorret_t sceneSweepInit(void) {
|
||||
cameraInitOrthographic(&SCENE_SWEEP_DATA.camera);
|
||||
|
||||
// Initialize scene data here
|
||||
errorOk();
|
||||
}
|
||||
|
||||
void sceneSweepUpdate(void) {
|
||||
// Update scene logic here
|
||||
}
|
||||
|
||||
void sceneSweepRender(void) {
|
||||
int32_t w = SCREEN.width;
|
||||
int32_t h = SCREEN.height;
|
||||
|
||||
SCENE_SWEEP_DATA.camera.orthographic.left = 0;
|
||||
SCENE_SWEEP_DATA.camera.orthographic.right = w;
|
||||
SCENE_SWEEP_DATA.camera.orthographic.bottom = h;
|
||||
SCENE_SWEEP_DATA.camera.orthographic.top = 0;
|
||||
cameraPushMatrix(&SCENE_SWEEP_DATA.camera);
|
||||
|
||||
// Background
|
||||
uiFrameDrawTiled(
|
||||
8, 8,
|
||||
w - 16, h - 16,
|
||||
UI.backgroundTileset,
|
||||
0, 0,
|
||||
true,
|
||||
&UI.backgroundAsset->paletteImage.texture
|
||||
);
|
||||
|
||||
// Frame
|
||||
uiFrameDrawTiled(
|
||||
32, 32,
|
||||
w - 64, h - 64,
|
||||
UI.frameTileset,
|
||||
0, 0,
|
||||
true,
|
||||
&UI.frameAsset->paletteImage.texture
|
||||
);
|
||||
|
||||
spriteBatchFlush();
|
||||
cameraPopMatrix();
|
||||
|
||||
uiRender();
|
||||
}
|
||||
|
||||
void sceneSweepDispose(void) {
|
||||
// Clean up scene resources here
|
||||
printf("Disposing sweep scene\n");
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2025 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "scene/scene.h"
|
||||
#include "display/camera.h"
|
||||
|
||||
typedef struct {
|
||||
camera_t camera;
|
||||
} scenesweep_t;
|
||||
|
||||
extern scene_t SCENE_SWEEP;
|
||||
extern scenesweep_t SCENE_SWEEP_DATA;
|
||||
|
||||
/**
|
||||
* Initializes the scene.
|
||||
*/
|
||||
errorret_t sceneSweepInit(void);
|
||||
|
||||
/**
|
||||
* Updates the state of the scene.
|
||||
*/
|
||||
void sceneSweepUpdate(void);
|
||||
|
||||
/**
|
||||
* Renders the current state of the scene.
|
||||
*/
|
||||
void sceneSweepRender(void);
|
||||
|
||||
/**
|
||||
* Cleans up resources used by the scene.
|
||||
*/
|
||||
void sceneSweepDispose(void);
|