diff --git a/CMakeLists.txt b/CMakeLists.txt index ddd7eaae..ed0a5731 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,6 +76,10 @@ else() set(DUSK_LIBRARY_TARGET_NAME "${DUSK_BINARY_TARGET_NAME}" CACHE INTERNAL ${DUSK_CACHE_TARGET}) endif() +if(NOT DEFINED DUSK_VERSION) + string(TIMESTAMP DUSK_VERSION "debug-%y%m%d%H%M%S") +endif() + # Definitions target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC @@ -84,6 +88,7 @@ target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} DUSK_GAME_AUTHOR="${DUSK_GAME_AUTHOR}" DUSK_GAME_SHORT_DESCRIPTION="${DUSK_GAME_SHORT_DESCRIPTION}" DUSK_GAME_LONG_DESCRIPTION="${DUSK_GAME_LONG_DESCRIPTION}" + DUSK_VERSION="${DUSK_VERSION}" ) # Toolchains diff --git a/src/dusk/asset/assetcache.c b/src/dusk/asset/assetcache.c index be54c497..c11a1a07 100644 --- a/src/dusk/asset/assetcache.c +++ b/src/dusk/asset/assetcache.c @@ -15,8 +15,8 @@ void assetCacheInit(assetcache_t *cache) { } void *assetCacheLookup(assetcache_t *cache, const char_t *path) { - for (uint8_t i = 0; i < cache->count; i++) { - if (stringCompare(cache->entries[i].path, path) == 0) { + for(uint8_t i = 0; i < cache->count; i++) { + if(stringCompare(cache->entries[i].path, path) == 0) { return cache->entries[i].data; } } diff --git a/src/dusk/engine/engine.c b/src/dusk/engine/engine.c index 9158341d..61a7424d 100644 --- a/src/dusk/engine/engine.c +++ b/src/dusk/engine/engine.c @@ -33,6 +33,7 @@ errorret_t engineInit(const int32_t argc, const char_t **argv) { ENGINE.running = true; ENGINE.argc = argc; ENGINE.argv = argv; + ENGINE.version = DUSK_VERSION; // Init systems. Order is important. errorChain(systemInit()); diff --git a/src/dusk/engine/engine.h b/src/dusk/engine/engine.h index c519ecf3..6defef96 100644 --- a/src/dusk/engine/engine.h +++ b/src/dusk/engine/engine.h @@ -15,6 +15,7 @@ typedef struct { bool_t running; int32_t argc; const char_t **argv; + const char_t *version; } engine_t; extern engine_t ENGINE; diff --git a/src/dusk/scene/overworld/overworldground.c b/src/dusk/scene/overworld/overworldground.c index 665f14b8..6411247d 100644 --- a/src/dusk/scene/overworld/overworldground.c +++ b/src/dusk/scene/overworld/overworldground.c @@ -35,11 +35,28 @@ void overworldGroundAdd(overworldground_t *ground) { entityPositionSetLocalScale(ground->entityId, ground->posCompId, scale); entityRenderableSetDraw(ground->entityId, renderComp, overworldGroundDraw); - ground->physCompId = entityAddComponent(ground->entityId, COMPONENT_TYPE_PHYSICS); - entityPhysicsSetBodyType(ground->entityId, ground->physCompId, PHYSICS_BODY_STATIC); + // Separate physics entity centered on the finite ground area. + // The visual entity's position is its corner {-size, 0, -size}, not its + // center, so a box collider on it would be misplaced. This entity sits at + // the true center {0, -0.5, 0} with halfExtents matching the visual extent. + ground->floorEntityId = entityManagerAdd(); + componentid_t floorPosComp = entityAddComponent( + ground->floorEntityId, COMPONENT_TYPE_POSITION + ); + componentid_t floorPhysComp = entityAddComponent( + ground->floorEntityId, COMPONENT_TYPE_PHYSICS + ); + + vec3 floorPos = { 0.0f, -0.5f, 0.0f }; + entityPositionSetLocalPosition(ground->floorEntityId, floorPosComp, floorPos); + entityPhysicsSetBodyType(ground->floorEntityId, floorPhysComp, PHYSICS_BODY_STATIC); physicsshape_t shape = { - .type = PHYSICS_SHAPE_PLANE, - .data.plane = { .normal = { 0.0f, 1.0f, 0.0f }, .distance = 0.0f } + .type = PHYSICS_SHAPE_CUBE, + .data.cube = { .halfExtents = { + OVERWORLD_GROUND_SIZE, + 0.5f, + OVERWORLD_GROUND_SIZE + }} }; - entityPhysicsSetShape(ground->entityId, ground->physCompId, shape); + entityPhysicsSetShape(ground->floorEntityId, floorPhysComp, shape); } diff --git a/src/dusk/scene/overworld/overworldground.h b/src/dusk/scene/overworld/overworldground.h index 51d26e20..bd77ff1b 100644 --- a/src/dusk/scene/overworld/overworldground.h +++ b/src/dusk/scene/overworld/overworldground.h @@ -11,7 +11,7 @@ typedef struct { entityid_t entityId; componentid_t posCompId; - componentid_t physCompId; + entityid_t floorEntityId; } overworldground_t; /** diff --git a/src/dusk/scene/overworld/overworldscene.c b/src/dusk/scene/overworld/overworldscene.c index afc21e98..13e5cdc9 100644 --- a/src/dusk/scene/overworld/overworldscene.c +++ b/src/dusk/scene/overworld/overworldscene.c @@ -73,6 +73,7 @@ void overworldSceneDispose(void) { OVERWORLD.cameraCamCompId = COMPONENT_ID_INVALID; OVERWORLD.ground.entityId = ENTITY_ID_INVALID; OVERWORLD.ground.posCompId = COMPONENT_ID_INVALID; + OVERWORLD.ground.floorEntityId = ENTITY_ID_INVALID; OVERWORLD.player.entityId = ENTITY_ID_INVALID; OVERWORLD.player.posCompId = COMPONENT_ID_INVALID; OVERWORLD.refCubeEntityId = ENTITY_ID_INVALID; diff --git a/src/dusk/ui/uifps.c b/src/dusk/ui/uifps.c index e80f72ef..0edf851c 100644 --- a/src/dusk/ui/uifps.c +++ b/src/dusk/ui/uifps.c @@ -9,6 +9,8 @@ #include "time/time.h" #include "display/spritebatch/spritebatch.h" #include "display/text/text.h" +#include "display/screen/screen.h" +#include "engine/engine.h" uifps_t UIFPS; @@ -53,6 +55,17 @@ errorret_t uiFPSDraw() { fpsText, textColor, &FONT_DEFAULT )); - + errorChain(spriteBatchFlush()); + + int32_t versionWidth, versionHeight; + textMeasure(ENGINE.version, &FONT_DEFAULT, &versionWidth, &versionHeight); + errorChain(textDraw( + (float_t)(SCREEN.width - versionWidth), + (float_t)(SCREEN.height - versionHeight), + ENGINE.version, + color(255, 255, 255, 128), + &FONT_DEFAULT + )); + return spriteBatchFlush(); } \ No newline at end of file