diff options
author | nathan <nathansmith@disroot.org> | 2025-07-06 11:13:16 +0000 |
---|---|---|
committer | nathan <nathansmith@disroot.org> | 2025-07-06 11:13:16 +0000 |
commit | 601961a245a48112029341437912fe13b54dac0b (patch) | |
tree | a3cf0a664b02bbecb3c5e146c1b2eabcec191623 | |
parent | 942924f120d104cf0d6f080497c286d98bd14e11 (diff) | |
download | FindThings-601961a245a48112029341437912fe13b54dac0b.tar.gz FindThings-601961a245a48112029341437912fe13b54dac0b.tar.bz2 FindThings-601961a245a48112029341437912fe13b54dac0b.zip |
rreeee
-rw-r--r-- | assets/mint.png | bin | 0 -> 2581 bytes | |||
-rw-r--r-- | assets/nickel.png | bin | 0 -> 2372 bytes | |||
-rw-r--r-- | concepts.org | 8 | ||||
-rw-r--r-- | src/assets.c | 4 | ||||
-rw-r--r-- | src/assets.h | 6 | ||||
-rw-r--r-- | src/entity.c | 29 | ||||
-rw-r--r-- | src/entity.h | 25 | ||||
-rw-r--r-- | src/game.c | 13 | ||||
-rw-r--r-- | src/game.h | 8 | ||||
-rw-r--r-- | src/world.c | 2 | ||||
-rw-r--r-- | src/world.h | 2 |
11 files changed, 89 insertions, 8 deletions
diff --git a/assets/mint.png b/assets/mint.png Binary files differnew file mode 100644 index 0000000..013c13f --- /dev/null +++ b/assets/mint.png diff --git a/assets/nickel.png b/assets/nickel.png Binary files differnew file mode 100644 index 0000000..bdb5dc8 --- /dev/null +++ b/assets/nickel.png diff --git a/concepts.org b/concepts.org index 7a3d0aa..0d445dc 100644 --- a/concepts.org +++ b/concepts.org @@ -78,10 +78,16 @@ said you will have your neck snapped no matter what you do. + No real physics, just dummy physics. + Nearly everything will be a intractable object. + Very lite and careful use of memory allocation. Use the stack a lot more. -+ The world data will be stored in mostly arrays in a header file. ++ Procedural generation. ** Intractable objects All objects will have a simple object id. When you interact with it the procedure for that object will be called. The ids can also be used for mesh instancing. +** Procedural generation +The world will be procedural generated and try to make sure every world it +creates is possible to beat. A little wack is fine as long as its +beatable. Since most of the world will just be a height map a image will be +generated first than rest of the world will be based around it. + diff --git a/src/assets.c b/src/assets.c index 79c7ef9..b42dfae 100644 --- a/src/assets.c +++ b/src/assets.c @@ -5,7 +5,9 @@ const char imageAssetPaths[IMAGE_ASSET_COUNT][FT_NAMEMAX] = { }; const char textureAssetPaths[TEXTURE_ASSET_COUNT][FT_NAMEMAX] = { - "heightmap.png" + "heightmap.png", + "mint.png", + "nickel.png" }; void initAssets(Assets* assets) diff --git a/src/assets.h b/src/assets.h index 43c4b43..f276088 100644 --- a/src/assets.h +++ b/src/assets.h @@ -4,7 +4,7 @@ #define ASSETS_H #define IMAGE_ASSET_COUNT 1 -#define TEXTURE_ASSET_COUNT 1 +#define TEXTURE_ASSET_COUNT 3 extern const char imageAssetPaths[IMAGE_ASSET_COUNT][FT_NAMEMAX]; extern const char textureAssetPaths[TEXTURE_ASSET_COUNT][FT_NAMEMAX]; @@ -18,7 +18,9 @@ enum { // Texture asset ids. enum { - HEIGHT_MAP_TEXTURE + HEIGHT_MAP_TEXTURE, + MINT_TEXTURE, + NICK_TEXTURE }; typedef struct { diff --git a/src/entity.c b/src/entity.c new file mode 100644 index 0000000..ac3606b --- /dev/null +++ b/src/entity.c @@ -0,0 +1,29 @@ +#include "entity.h" +#include "game.h" + +// TODO: Entity creation system +Entity createEntity(EntityId id, Vector3 position) +{ + Entity entity; + entity.id = id; + entity.position = position; + + return entity; +} + +void updateEntity(Entity* entity, Game* game) +{ + switch (entity->id) + { + case OLD_MINT: + DrawBillboard(game->player.camera, game->assets.textures[MINT_TEXTURE], + entity->position, 1.0, WHITE); + break; + case STICKY_NICKEL: + DrawBillboard(game->player.camera, game->assets.textures[NICK_TEXTURE], + entity->position, 1.0, WHITE); + break; + default: + break; + } +} diff --git a/src/entity.h b/src/entity.h new file mode 100644 index 0000000..0c431ea --- /dev/null +++ b/src/entity.h @@ -0,0 +1,25 @@ +#include "utils.h" + +// Pretty much any object in the game. + +#ifndef ENTITY_H +#define ENTITY_H + +typedef int8_t EntityId; + +enum { + ENTITY_NONE = -1, + OLD_MINT, + STICKY_NICKEL +}; + +typedef struct { + EntityId id; + Vector3 position; + BoundingBox box; +} Entity; + +Entity createEntity(EntityId id, Vector3 position); +void updateEntity(Entity* entity, Game* game); + +#endif @@ -23,6 +23,14 @@ void initGame(Game* game) // World. game->world = createWorld(&game->assets); + game->entities[0] = createEntity(OLD_MINT, (Vector3){100.0, 0.0, 100.0}); + game->entities[1] = createEntity(STICKY_NICKEL, + (Vector3){100.0, 0.0, 105.0}); + game->entities[0].position.y = getWorldHeightAtLocation(game->world, + 100, 100) + 1.0; + game->entities[1].position.y = getWorldHeightAtLocation(game->world, + 100, 105) + 1.0; + DisableCursor(); } @@ -41,6 +49,11 @@ void updateGameScene(Game* game) updateWorld(&game->world, game); + for (int index = 0; index < 2; ++index) + { + updateEntity(&game->entities[index], game); + } + EndMode3D(); } @@ -3,6 +3,7 @@ #include "assets.h" #include "player.h" #include "world.h" +#include "entity.h" #ifndef GAME_H #define GAME_H @@ -10,14 +11,17 @@ typedef enum { MAIN_MENU_SCENE, GAME_SCENE -} SceneID; +} SceneId; struct Game { - SceneID sceneId; + SceneId sceneId; Settings settings; Assets assets; Player player; World world; + + // For testing only. + Entity entities[2]; }; void initGame(Game* game); diff --git a/src/world.c b/src/world.c index 0a6b544..db6e55d 100644 --- a/src/world.c +++ b/src/world.c @@ -43,7 +43,7 @@ float getWorldPixelHeight(World world, int x, int y) return (float)height / count; } -float getWorldHeightAtLocation(World world, int x, int y) +float getWorldHeightAtLocation(World world, float x, float y) { float toMapX = (float)world.image->width / world.size.x; float toMapY = (float)world.image->height / world.size.z; diff --git a/src/world.h b/src/world.h index d843094..6a214b6 100644 --- a/src/world.h +++ b/src/world.h @@ -19,6 +19,6 @@ void freeWorld(World world); // Dam, I wanta live in a free world ): float getWorldPixelHeight(World world, int x, int y); -float getWorldHeightAtLocation(World world, int x, int y); +float getWorldHeightAtLocation(World world, float x, float y); #endif |