Comitting before AI destroys it.

This commit is contained in:
2025-06-12 21:52:19 -05:00
parent ffaef7aa8d
commit e508d6575d
29 changed files with 632 additions and 492 deletions

View File

@ -0,0 +1,11 @@
# 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
drawscene.c
drawoverworld.c
)

View File

@ -0,0 +1,51 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "drawoverworld.h"
#include "world/chunk.h"
#include "world/overworld.h"
#include "display/render.h"
Camera2D DRAW_OVERWORLD_CAMERA = { 0 };
void drawOverworldInit(void) {
DRAW_OVERWORLD_CAMERA = (Camera2D){
.offset = { 0, 0 },
.target = { 0, 0 },
.rotation = 0.0f,
.zoom = 1.0f
};
}
void drawOverworldDraw(void) {
BeginMode2D(DRAW_OVERWORLD_CAMERA);
DRAW_OVERWORLD_CAMERA.target.x = (
OVERWORLD_CAMERA_X * TILE_WIDTH + OVERWORLD_CAMERA_SUB_X
) - (
RENDER_WIDTH / 2
);
DRAW_OVERWORLD_CAMERA.target.y = (
OVERWORLD_CAMERA_Y * TILE_HEIGHT + OVERWORLD_CAMERA_SUB_Y
) - (
RENDER_HEIGHT / 2
);
chunk_t *chunk = CHUNK_MAP.chunks;
do {
DrawRectangle(
((int32_t)chunk->x) * CHUNK_WIDTH * TILE_WIDTH,
((int32_t)chunk->y) * CHUNK_HEIGHT * TILE_HEIGHT,
CHUNK_WIDTH * TILE_WIDTH,
CHUNK_HEIGHT * TILE_HEIGHT,
(chunk->tiles[0] == 0) ? RED : GREEN
);
chunk++;
} while(chunk < CHUNK_MAP.chunks + CHUNK_MAP_COUNT);
EndMode2D();
}

View File

@ -0,0 +1,19 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "duskraylib.h"
/**
* Initializes the overworld drawing system.
*/
void drawOverworldInit(void);
/**
* Renders the overworld, including map and characters.
*/
void drawOverworldDraw(void);

View File

@ -0,0 +1,25 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "drawscene.h"
#include "display/scene.h"
#include "assert/assert.h"
#include "drawoverworld.h"
void drawScene(void) {
switch(SCENE_CURRENT){
case SCENE_INITIAL:
break;
case SCENE_OVERWORLD:
drawOverworldDraw();
break;
default:
assertUnreachable("Unknown scene in drawScene");
}
}

View File

@ -0,0 +1,14 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "duskraylib.h"
/**
* Draws the current scene to the screen.
*/
void drawScene(void);