add quit command

This commit is contained in:
2025-08-17 12:55:08 -05:00
parent c3310a036f
commit 91b93b5b1e
18 changed files with 186 additions and 79 deletions

View File

@@ -16,6 +16,7 @@ target_sources(${DUSK_TARGET_NAME}
add_subdirectory(camera)
add_subdirectory(framebuffer)
add_subdirectory(mesh)
add_subdirectory(overworld)
add_subdirectory(texture)
add_subdirectory(spritebatch)
add_subdirectory(scene)

View File

@@ -0,0 +1,10 @@
# 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
renderoverworld.c
)

View File

@@ -0,0 +1,16 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "renderoverworld.h"
void renderOverworldInit(void) {
// Initialize overworld rendering resources here
}
void renderOverworldDispose(void) {
// Clean up overworld rendering resources here
}

View File

@@ -0,0 +1,34 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "world/chunk.h"
#include "display/mesh/mesh.h"
typedef struct {
mesh_t meshBase;
meshvertex_t verticesBase[CHUNK_TILE_COUNT];
mesh_t meshBaseOverlay;
meshvertex_t verticesBaseOverlay[CHUNK_TILE_COUNT];
} renderchunk_t;
typedef struct {
renderchunk_t chunks[CHUNK_MAP_COUNT];
} renderoverworld_t;
extern renderoverworld_t RENDER_OVERWORLD;
/**
* Initializes the render overworld.
*/
void renderOverworldInit(void);
/**
* Disposes of the render overworld.
*/
void renderOverworldDispose(void);

View File

@@ -6,6 +6,7 @@
*/
#include "renderscene.h"
#include "display/overworld/renderoverworld.h"
renderscenecallback_t RENDER_SCENE_CALLBACKS[SCENE_COUNT] = {
[SCENE_INITIAL] = {
@@ -15,9 +16,9 @@ renderscenecallback_t RENDER_SCENE_CALLBACKS[SCENE_COUNT] = {
},
[SCENE_OVERWORLD] = {
.init = NULL,
.init = renderOverworldInit,
.draw = NULL,
.dispose = NULL
.dispose = renderOverworldDispose
},
};

View File

@@ -49,6 +49,7 @@
{ SDL_SCANCODE_SPACE, INPUT_BIND_ACTION },
{ SDL_SCANCODE_ESCAPE, INPUT_BIND_CANCEL },
{ SDL_SCANCODE_GRAVE, INPUT_BIND_CONSOLE },
{ SDL_SCANCODE_Q, INPUT_BIND_QUIT },
{ 0, 0 }
};
#endif

View File

@@ -26,12 +26,8 @@ int main(int argc, char *argv[]) {
gameUpdate();
mainError(renderDraw());
if(inputPressed(INPUT_BIND_UP)) consolePrint("Up pressed");
if(inputPressed(INPUT_BIND_DOWN)) consolePrint("Down pressed");
if(inputPressed(INPUT_BIND_LEFT)) consolePrint("Left pressed");
if(inputPressed(INPUT_BIND_RIGHT)) consolePrint("Right pressed");
if(inputPressed(INPUT_BIND_ACTION)) consolePrint("Action pressed");
if(inputPressed(INPUT_BIND_CANCEL)) consolePrint("Cancel pressed");
if(inputPressed(INPUT_BIND_QUIT)) consoleExec("quit");
if(!GAME.running) break;
}
gameDispose();