33 Commits

Author SHA1 Message Date
doylet 03920e311c fp: Update website directory to 'Terry_Cherry' 2024-01-21 00:37:07 +11:00
doylet ee95cefdff fp: Update build script for new tely 2023-12-01 16:46:58 +11:00
doylet 4d1fffcc02 build: Fix sokol_audio outputting .obj file 2023-11-27 00:13:04 +11:00
doylet 8663f1b73c fp: Don't use pthreads for emscripten, needs webserver config 2023-11-27 00:08:49 +11:00
doylet 00986fa6a1 fp: Async load audio 2023-11-26 23:45:50 +11:00
doylet 13d356cbfd fp: Fix UB in copies of posix synchronisation primitives 2023-11-26 21:59:36 +11:00
doylet 5ac952eb83 fp: Fix more threading bugs on Windows 2023-11-26 18:51:36 +11:00
doylet 04b4f61810 build: Get changes for linux 2023-11-26 18:43:04 +11:00
doylet 5868fc96df fp: Add posix implementation of pthreads 2023-11-26 18:32:59 +11:00
doylet bca013bf05 fp: Support building via GCC on Windows 2023-11-26 16:54:21 +11:00
doylet 801b9051c9 fp: Address warnings on GCC 2023-11-26 16:28:35 +11:00
doylet f176d66058 build: Fix emscripten build using MSVC style flags 2023-11-26 16:03:53 +11:00
doylet 20d7b7763b build: Fix compile errors on Windows from Linux changes 2023-11-26 14:03:46 +11:00
doylet 05788cc726 build: Get basic linux build working 2023-11-26 00:52:50 +11:00
doylet 88d996af87 build: Add flags for linux build 2023-11-25 18:28:55 +11:00
doylet f8890f0be2 fp: Start working on linux support 2023-11-24 00:22:07 +11:00
doylet 50d6271413 fp: Use audio handles 2023-11-21 22:47:54 +11:00
doylet 93e5302c60 fp: Add initial impl of fade in and out wave music 2023-11-21 00:14:50 +11:00
doylet b03c6c3e56 fp: Get new audio stop functionality 2023-11-15 09:47:34 +11:00
Jojangles 074ba436cb Honestly i'm floundering right now 2023-11-14 09:05:25 +11:00
Jojangles 2d685fcdb9 Submodule changes 2023-11-14 08:59:28 +11:00
Jojangles ebc969603d tely: Add a way to stop music from playing 2023-11-14 08:44:10 +11:00
Jojangles d0b3ce1bd0 fp: Add potential ambience and background music options 2023-11-09 08:37:08 +11:00
Jojangles 97a83b20f6 fp: Add entrance sounds for perry and game start 2023-11-06 08:29:55 +11:00
Jojangles 9ad3754829 fp: Do some wave balancing 2023-11-02 08:30:37 +11:00
doylet 0522e842c4 fp: Switch to sokol audio to fix audio bugs 2023-10-31 00:02:34 +11:00
doylet 9ba6071f9b fp: Only count enemies that are a mob 2023-10-29 23:55:36 +11:00
doylet 131323fbea fp: Update website deploy script source path 2023-10-29 23:49:52 +11:00
doylet e77c85b004 fp: Update readme for new build details 2023-10-29 23:47:50 +11:00
doylet 11d5f34522 fp: Improve tutorial, add a wave break every 3 waves 2023-10-29 23:45:45 +11:00
doylet 285cc9b5ad fp: Add quick tutorial at beginning of game 2023-10-29 17:30:08 +11:00
doylet b4438c1510 tely: Fix DLL build using wrong DLL nameg 2023-10-29 15:14:16 +11:00
doylet 989b0d30cc fp: Upgrade TELY and simplify build 2023-10-29 15:14:16 +11:00
26 changed files with 1307 additions and 1156 deletions
+1
View File
@@ -1,5 +1,6 @@
Build/
Nocheckin/
feely_pona_build.exe
feely_pona_build
feely_pona_version.txt
Tools/emsdk
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
+1 -1
+1 -21
View File
@@ -1,25 +1,5 @@
@echo off
setlocal
set script_dir_backslash=%~dp0
set script_dir=%script_dir_backslash:~0,-1%
set build_dir=%script_dir%\Build
set code_dir=%script_dir%
call build_all.bat %* || exit /b 1
REM Bootstrap a version
git show -s --date=format:%%Y-%%m-%%d --format=%%cd HEAD> feely_pona_version.txt
git rev-parse --short=8 HEAD>> feely_pona_version.txt
git rev-list --count HEAD>> feely_pona_version.txt
REM Bootstrap the build program
mkdir %build_dir% 2>nul
pushd %build_dir%
cl /nologo /Z7 /W4 %code_dir%\feely_pona_build.cpp || exit /B 1
copy feely_pona_build.exe %code_dir% 1>nul
popd
REM Run the build program
%code_dir%\feely_pona_build.exe %* || exit /B 1
popd
exit /B 1
Executable
+21
View File
@@ -0,0 +1,21 @@
#!/bin/bash
set -e
script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
build_dir=${script_dir}/Build
code_dir=${script_dir}
# Bootstrap a version
git show -s --date=format:%Y-%m-%d --format=%cd HEAD> feely_pona_version.txt
git rev-parse --short=8 HEAD>> feely_pona_version.txt
git rev-list --count HEAD>> feely_pona_version.txt
# Bootstrap the build program
mkdir --parents ${build_dir}
pushd ${build_dir}
g++ -g -Wall -o feely_pona_build ${code_dir}/feely_pona_build.cpp -lm -lpthread
cp --force feely_pona_build ${code_dir}
popd
# Run the build program
${code_dir}/feely_pona_build $@
+25
View File
@@ -0,0 +1,25 @@
@echo off
setlocal
set script_dir_backslash=%~dp0
set script_dir=%script_dir_backslash:~0,-1%
set build_dir=%script_dir%\Build
set code_dir=%script_dir%
REM Bootstrap a version
git show -s --date=format:%%Y-%%m-%%d --format=%%cd HEAD> feely_pona_version.txt
git rev-parse --short=8 HEAD>> feely_pona_version.txt
git rev-list --count HEAD>> feely_pona_version.txt
REM Bootstrap the build program
mkdir %build_dir% 2>nul
pushd %build_dir%
cl /nologo /Z7 /W4 %code_dir%\feely_pona_build.cpp || exit /B 1
copy feely_pona_build.exe %code_dir% 1>nul
popd
REM Run the build program
%code_dir%\feely_pona_build.exe %* || exit /B 1
popd
exit /B 1
+4 -4
View File
@@ -5,7 +5,7 @@ set script_dir_backslash=%~dp0
set script_dir=%script_dir_backslash:~0,-1%
set build_dir=%script_dir%\Build
scp -P 8110 %build_dir%\Terry_Cherry_Emscripten\Terry_Cherry.html doylet@doylet.dev:/selfhost/TerryCherry/index.html
scp -P 8110 %build_dir%\Terry_Cherry_Emscripten\Terry_Cherry.data doylet@doylet.dev:/selfhost/TerryCherry/Terry_Cherry.data
scp -P 8110 %build_dir%\Terry_Cherry_Emscripten\Terry_Cherry.js doylet@doylet.dev:/selfhost/TerryCherry/Terry_Cherry.js
scp -P 8110 %build_dir%\Terry_Cherry_Emscripten\Terry_Cherry.wasm doylet@doylet.dev:/selfhost/TerryCherry/Terry_Cherry.wasm
scp -P 8110 %build_dir%\Terry_Cherry\Terry_Cherry.html doylet@doylet.dev:/selfhost/Terry_Cherry/index.html
scp -P 8110 %build_dir%\Terry_Cherry\Terry_Cherry.data doylet@doylet.dev:/selfhost/Terry_Cherry/Terry_Cherry.data
scp -P 8110 %build_dir%\Terry_Cherry\Terry_Cherry.js doylet@doylet.dev:/selfhost/Terry_Cherry/Terry_Cherry.js
scp -P 8110 %build_dir%\Terry_Cherry\Terry_Cherry.wasm doylet@doylet.dev:/selfhost/Terry_Cherry/Terry_Cherry.wasm
+544 -327
View File
File diff suppressed because it is too large Load Diff
+6
View File
@@ -165,6 +165,12 @@ struct FP_ParticleDescriptor
Dqn_usize duration_ms;
};
struct FP_ListenForNewPlayerResult
{
bool yes;
bool tutorial_requested;
};
#if defined(DQN_PLATFORM_EMSCRIPTEN)
#define FP_DEVELOPER_MODE 0
#else
+546 -536
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -185,6 +185,7 @@ static FP_GameEntityHandle FP_Entity_CreateTerryInternal(FP_Game *game, Dqn_V2 p
entity->local_hit_box_size = FP_Game_MetersToPixelsNx2(game->play, 0.5f, entity->sprite_height.meters * .6f);
entity->hp_cap = FP_DEFAULT_DAMAGE * 3;
entity->hp = entity->hp_cap;
entity->coins = 10;
FP_Entity_AddDebugEditorFlags(game, result);
entity->flags |= FP_GameEntityFlag_NonTraversable;
entity->flags |= FP_GameEntityFlag_Attackable;
+7 -31
View File
@@ -3,24 +3,24 @@
#include "feely_pona_unity.h"
#endif
static bool FP_Game_KeyBindIsPressed(TELY_PlatformInput const *input, FP_GameControls const *controls, FP_GameKeyBind key_bind)
static bool FP_Game_KeyBindIsPressed(TELY_Input const *input, FP_GameControls const *controls, FP_GameKeyBind key_bind)
{
bool result = false;
if (controls->mode == FP_GameControlMode_Keyboard) {
result = TELY_Platform_InputScanCodeIsPressed(input, key_bind.scan_code);
result = TELY_Input_ScanKeyIsPressed(input, key_bind.scan_key);
} else {
result = TELY_Platform_InputGamepadKeyIsPressed(input, controls->gamepad_index, key_bind.gamepad_key);
result = TELY_Input_GamepadKeyIsPressed(input, controls->gamepad_index, key_bind.gamepad_key);
}
return result;
}
static bool FP_Game_KeyBindIsDown(TELY_PlatformInput const *input, FP_GameControls const *controls, FP_GameKeyBind key_bind)
static bool FP_Game_KeyBindIsDown(TELY_Input const *input, FP_GameControls const *controls, FP_GameKeyBind key_bind)
{
bool result = false;
if (controls->mode == FP_GameControlMode_Keyboard) {
result = TELY_Platform_InputScanCodeIsDown(input, key_bind.scan_code);
result = TELY_Input_ScanKeyIsDown(input, key_bind.scan_key);
} else {
result = TELY_Platform_InputGamepadKeyIsDown(input, controls->gamepad_index, key_bind.gamepad_key);
result = TELY_Input_GamepadKeyIsDown(input, controls->gamepad_index, key_bind.gamepad_key);
}
return result;
}
@@ -250,6 +250,7 @@ static FP_GameEntity *FP_Game_MakeEntityPointerFV(FP_Game *game, DQN_FMT_ATTRIB
result->buildings_visited = FP_SentinelList_Init<FP_GameEntityHandle>(game->play.chunk_pool);
result->action.sprite_alpha = 1.f;
result->stamina_cap = 93;
result->stamina = result->stamina_cap;
result->hp_cap = DQN_CAST(uint32_t)(FP_DEFAULT_DAMAGE * .8f);
result->hp = result->hp_cap;
@@ -291,19 +292,6 @@ static FP_GameEntity *FP_Game_MakeEntityPointerF(FP_Game *game, DQN_FMT_ATTRIB c
return result;
}
static FP_GameEntityHandle FP_Game_MakeEntityF(FP_Game *game, DQN_FMT_ATTRIB char const *fmt, ...)
{
va_list args;
va_start(args, fmt);
FP_GameEntity *entity = FP_Game_MakeEntityPointerF(game, fmt, args);
va_end(args);
FP_GameEntityHandle result = {};
if (entity)
result = entity->handle;
return result;
}
static bool FP_Game_IsNilEntity(FP_GameEntity *entity)
{
bool result = entity ? ((entity->handle.id & FP_GAME_ENTITY_HANDLE_INDEX_MASK) == 0) : true;
@@ -536,18 +524,6 @@ static void FP_Game_EntityActionReset(FP_Game *game, FP_GameEntityHandle entity_
entity->action.end_at_clock_ms = DQN_MAX(duration_ms, game->play.clock_ms + duration_ms);
}
static Dqn_V2I FP_Game_WorldPosToTilePos(FP_Game *game, Dqn_V2 world_pos)
{
Dqn_V2I result = Dqn_V2I_InitNx2(world_pos.x / game->play.tile_size, world_pos.y / game->play.tile_size);
return result;
}
static Dqn_V2 FP_Game_TilePosToWorldPos(FP_Game *game, Dqn_V2I tile_pos)
{
Dqn_V2 result = Dqn_V2_InitNx2(tile_pos.x * game->play.tile_size, tile_pos.y * game->play.tile_size);
return result;
}
static Dqn_V2 FP_Game_CalcWaypointWorldPos(FP_Game *game, FP_GameEntityHandle entity_handle, FP_GameWaypoint const *waypoint)
{
Dqn_V2 result = {};
+58 -11
View File
@@ -168,8 +168,8 @@ enum FP_GameInGameMenu
struct FP_GameKeyBind
{
TELY_PlatformInputScanCode scan_code;
TELY_PlatformInputGamepadKey gamepad_key;
TELY_InputScanKey scan_key;
TELY_InputGamepadKey gamepad_key;
};
enum FP_GameControlMode
@@ -334,12 +334,19 @@ enum FP_GameAudio
FP_GameAudio_Message,
FP_GameAudio_Monkey,
FP_GameAudio_PortalDestroy,
FP_GameAudio_GameStart,
FP_GameAudio_PerryStart,
FP_GameAudio_Ambience1,
FP_GameAudio_Ambience2,
FP_GameAudio_Music1,
FP_GameAudio_Music2,
FP_GameAudio_Count,
};
enum FP_GameState
{
FP_GameState_IntroScreen,
FP_GameState_Tutorial,
FP_GameState_Play,
FP_GameState_Pause,
FP_GameState_WinGame,
@@ -365,6 +372,35 @@ struct FP_Particle
Dqn_usize end_ms;
};
enum FP_GameStateTutorial
{
FP_GameStateTutorial_ShowPlayer,
FP_GameStateTutorial_ShowPlayerWait,
FP_GameStateTutorial_ShowPortalOne,
FP_GameStateTutorial_ShowPortalOneWait,
FP_GameStateTutorial_ShowPortalTwo,
FP_GameStateTutorial_ShowPortalTwoWait,
FP_GameStateTutorial_ShowPortalThree,
FP_GameStateTutorial_ShowPortalThreeWait,
FP_GameStateTutorial_ShowBillboardBuild,
FP_GameStateTutorial_ShowBillboardBuildWait,
FP_GameStateTutorial_Count,
};
Dqn_V2 const FP_MONKEY_SPAWN_LOCATIONS[] =
{
Dqn_V2_InitNx2(-592, 538),
Dqn_V2_InitNx2(-1503, -568),
Dqn_V2_InitNx2(1890, 1150),
Dqn_V2_InitNx2(1815, -1192),
Dqn_V2_InitNx2(520, 1230),
Dqn_V2_InitNx2(-934, -238),
Dqn_V2_InitNx2(1915, 15),
Dqn_V2_InitNx2(247, 560),
Dqn_V2_InitNx2(-290, -1120),
Dqn_V2_InitNx2(1126, -646),
};
struct FP_GamePlay
{
TELY_ChunkPool *chunk_pool;
@@ -388,6 +424,7 @@ struct FP_GamePlay
FP_GameEntityHandle merchant_graveyard;
FP_GameEntityHandle merchant_gym;
FP_GameEntityHandle merchant_phone_company;
FP_GameEntityHandle billboard_build;
FP_GameEntityHandle clicked_entity;
FP_GameEntityHandle hot_entity;
@@ -429,22 +466,32 @@ struct FP_GamePlay
FP_Particle particles[256];
uint32_t particle_next_index;
FP_GameStateTutorial tutorial_state;
uint64_t tutorial_wait_end_time_ms;
uint8_t monkey_spawn_shuffled_list[DQN_ARRAY_UCOUNT(FP_MONKEY_SPAWN_LOCATIONS)];
uint8_t monkey_spawn_count;
};
struct FP_Game
{
TELY_AssetFontHandle inter_regular_font_large;
TELY_AssetFontHandle inter_regular_font;
TELY_AssetFontHandle inter_italic_font;
TELY_AssetFontHandle jetbrains_mono_font;
TELY_AssetFontHandle talkco_font;
TELY_AssetFontHandle talkco_font_large;
TELY_AssetFontHandle talkco_font_xlarge;
TELY_AssetAudioHandle audio[FP_GameAudio_Count];
TELY_AssetSpriteSheet atlas_sprite_sheet;
TELY_RFui rfui;
FP_GamePlay play;
Dqn_Arena *frame_arena;
TELY_AssetAudioHandle audio[FP_GameAudio_Count];
TELY_AudioPlaybackHandle bg_music1;
TELY_AudioPlaybackHandle bg_music2;
TELY_AssetSpriteSheet atlas_sprite_sheet;
TELY_RFui rfui;
FP_GamePlay play;
Dqn_Arena *frame_arena;
uint16_t font_size;
uint16_t large_font_size;
uint16_t large_talkco_font_size;
uint16_t xlarge_talkco_font_size;
};
struct FP_GameAStarNode
@@ -473,7 +520,7 @@ FP_GamePlaceableBuilding const PLACEABLE_BUILDINGS[] = {
{FP_EntityType_AirportTerry, FP_EntityAirportTerryState_Idle},
{FP_EntityType_ChurchTerry, FP_EntityChurchTerryState_Idle},
{FP_EntityType_ClubTerry, FP_EntityClubTerryState_Idle},
{FP_EntityType_KennelTerry, FP_EntityKennelTerryState_Idle},
// {FP_EntityType_KennelTerry, FP_EntityKennelTerryState_Idle},
};
struct FP_GameCanMoveToPositionResult
+7 -7
View File
@@ -3,7 +3,7 @@
#include "feely_pona_unity.h"
#endif
void FP_UnitTests(TELY_Platform *platform)
void FP_UnitTests(TELY_OS *os)
{
{
uint32_t array[] = {1};
@@ -318,9 +318,9 @@ void FP_UnitTests(TELY_Platform *platform)
}
{
Dqn_Arena_TempMemoryScope(&platform->arena);
Dqn_Arena_TempMemoryScope(&os->arena);
TELY_ChunkPool pool = {};
pool.arena = &platform->arena;
pool.arena = &os->arena;
void *bytes16 = TELY_ChunkPool_Alloc(&pool, 16);
TELY_ChunkPool_Dealloc(&pool, bytes16);
@@ -346,13 +346,13 @@ void FP_UnitTests(TELY_Platform *platform)
}
// NOTE: Unit test DFS pre-order and post-order walk
Dqn_Arena_TempMemoryScope(&platform->arena);
Dqn_Arena_TempMemoryScope(&os->arena);
TELY_ChunkPool chunk_pool = {};
chunk_pool.arena = &platform->arena;
chunk_pool.arena = &os->arena;
FP_Game *game = Dqn_Arena_New(&platform->arena, FP_Game, Dqn_ZeroMem_Yes);
FP_Game *game = Dqn_Arena_New(&os->arena, FP_Game, Dqn_ZeroMem_Yes);
game->play.chunk_pool = &chunk_pool;
game->play.entities = Dqn_VArray_Init<FP_GameEntity>(&platform->arena, 1024 * 8);
game->play.entities = Dqn_VArray_Init<FP_GameEntity>(&os->arena, 1024 * 8);
game->play.root_entity = Dqn_VArray_Make(&game->play.entities, Dqn_ZeroMem_No);
Dqn_FArray_Add(&game->play.parent_entity_stack, game->play.root_entity->handle);
+56 -54
View File
@@ -8,6 +8,8 @@
#define DQN_ONLY_DSMAP
#define DQN_ONLY_LIST
#define DQN_ONLY_FS
#define DQN_ONLY_SEMAPHORE
#define DQN_ONLY_THREAD
#define _CRT_SECURE_NO_WARNINGS
#define DQN_IMPLEMENTATION
#include "External/tely/External/dqn/dqn.h"
@@ -15,13 +17,13 @@
DQN_MSVC_WARNING_PUSH
DQN_MSVC_WARNING_DISABLE(4244) // warning C4244: 'argument': conversion from 'int' to 'short', possible loss of data
#define STB_RECT_PACK_IMPLEMENTATION
#include "External/tely/external/stb/stb_rect_pack.h"
#include "External/tely/External/stb/stb_rect_pack.h"
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "External/tely/external/stb/stb_image_write.h"
#include "External/tely/External/stb/stb_image_write.h"
#define STB_IMAGE_IMPLEMENTATION
#include "External/tely/external/stb/stb_image.h"
#include "External/tely/External/stb/stb_image.h"
DQN_MSVC_WARNING_POP
DQN_MSVC_WARNING_PUSH
@@ -37,17 +39,17 @@ struct SpriteSpecification
uint16_t frames_per_second;
};
static Dqn_String8 SpriteAnimNameFromFilePath(Dqn_String8 path)
static Dqn_Str8 SpriteAnimNameFromFilePath(Dqn_Str8 path)
{
// NOTE: Enumerate the number of frames for this animation =================================
Dqn_String8 file_name = Dqn_String8_FileNameFromPath(path);
Dqn_String8 file_name_without_extension = Dqn_String8_BinarySplit(file_name, DQN_STRING8(".")).lhs;
Dqn_Str8 file_name = Dqn_Str8_FileNameFromPath(path);
Dqn_Str8 file_name_without_extension = Dqn_Str8_BinarySplit(file_name, DQN_STR8(".")).lhs;
// NOTE: If the sprite is a standalone sprite without any frame suffix (e.g. "_1.png") then
// we accept the entry as the name of the sprite as is.
Dqn_String8 result = {};
Dqn_Str8 result = {};
if (Dqn_Char_IsDigit(file_name_without_extension.data[file_name_without_extension.size - 1])) {
Dqn_String8BinarySplitResult split = Dqn_String8_BinarySplitReverse(file_name_without_extension, DQN_STRING8("_"));
Dqn_Str8BinarySplitResult split = Dqn_Str8_BinarySplitReverse(file_name_without_extension, DQN_STR8("_"));
result = split.lhs;
} else {
result = file_name_without_extension;
@@ -67,26 +69,26 @@ int main(int argc, char const *argv[])
}
// NOTE: Verify some arguments =================================================================
Dqn_String8 atlas_dimensions = Dqn_String8_InitCString8(argv[1]);
Dqn_String8 sprite_spec_path = Dqn_String8_InitCString8(argv[2]);
Dqn_String8 dir = Dqn_String8_InitCString8(argv[3]);
Dqn_Str8 atlas_dimensions = Dqn_Str8_InitCStr8(argv[1]);
Dqn_Str8 sprite_spec_path = Dqn_Str8_InitCStr8(argv[2]);
Dqn_Str8 dir = Dqn_Str8_InitCStr8(argv[3]);
if (!Dqn_Fs_Exists(sprite_spec_path)) {
Dqn_Log_ErrorF("Sprite specification file does not exist, we tried to find \"%.*s\" but it does not exist", DQN_STRING_FMT(sprite_spec_path));
Dqn_Log_ErrorF("Sprite specification file does not exist, we tried to find \"%.*s\" but it does not exist", DQN_STR_FMT(sprite_spec_path));
return -1;
}
if (!Dqn_Fs_DirExists(dir)) {
Dqn_Log_ErrorF("Directory to load sprites from does not exist, we tried to find \"%.*s\" but it does not exist", DQN_STRING_FMT(dir));
Dqn_Log_ErrorF("Directory to load sprites from does not exist, we tried to find \"%.*s\" but it does not exist", DQN_STR_FMT(dir));
return -1;
}
// NOTE: Parse the atlas size ==================================================================
Dqn_V2I atlas_size = {};
{
Dqn_String8BinarySplitResult atlas_dimensions_split = Dqn_String8_BinarySplit(atlas_dimensions, DQN_STRING8("x"));
Dqn_String8ToU64Result width = Dqn_String8_ToU64(atlas_dimensions_split.lhs, 0);
Dqn_String8ToU64Result height = Dqn_String8_ToU64(atlas_dimensions_split.rhs, 0);
Dqn_Str8BinarySplitResult atlas_dimensions_split = Dqn_Str8_BinarySplit(atlas_dimensions, DQN_STR8("x"));
Dqn_Str8ToU64Result width = Dqn_Str8_ToU64(atlas_dimensions_split.lhs, 0);
Dqn_Str8ToU64Result height = Dqn_Str8_ToU64(atlas_dimensions_split.rhs, 0);
if (!width.success || width.value == 0) {
Dqn_Log_ErrorF("Width for the sprite atlas was not a number > 0");
@@ -106,51 +108,51 @@ int main(int argc, char const *argv[])
Dqn_DSMap<SpriteSpecification> sprite_spec_table = Dqn_DSMap_Init<SpriteSpecification>(1024);
{
Dqn_ThreadScratch inner_scratch = Dqn_Thread_GetScratch(scratch.arena);
Dqn_String8 sprite_spec_buffer = Dqn_Fs_Read(sprite_spec_path, inner_scratch.allocator);
Dqn_String8SplitAllocResult sprite_spec_lines = Dqn_String8_SplitAlloc(inner_scratch.allocator, sprite_spec_buffer, DQN_STRING8("\n"));
Dqn_Str8 sprite_spec_buffer = Dqn_Fs_Read(sprite_spec_path, inner_scratch.allocator);
Dqn_Str8SplitAllocResult sprite_spec_lines = Dqn_Str8_SplitAlloc(inner_scratch.allocator, sprite_spec_buffer, DQN_STR8("\n"));
DQN_FOR_UINDEX(line_index, sprite_spec_lines.size) {
Dqn_String8 line = Dqn_String8_TrimWhitespaceAround(sprite_spec_lines.data[line_index]);
Dqn_Str8 line = Dqn_Str8_TrimWhitespaceAround(sprite_spec_lines.data[line_index]);
if (line.size == 0) // NOTE: Support empty lines, just ignore them
continue;
Dqn_String8SplitAllocResult line_parts = Dqn_String8_SplitAlloc(inner_scratch.allocator, line, DQN_STRING8(";"));
Dqn_Str8SplitAllocResult line_parts = Dqn_Str8_SplitAlloc(inner_scratch.allocator, line, DQN_STR8(";"));
DQN_ASSERTF(line_parts.size == 2, "Line must have 2 parts in the sprite specification\n"
"\n"
"<animation name>;<frames per second>\\n\n"
"\n"
"Line was '%.*s' loaded from '%.*s'", DQN_STRING_FMT(line), DQN_STRING_FMT(sprite_spec_path));
"Line was '%.*s' loaded from '%.*s'", DQN_STR_FMT(line), DQN_STR_FMT(sprite_spec_path));
Dqn_String8 anim_name = line_parts.data[0];
Dqn_String8ToU64Result frames_per_second = Dqn_String8_ToU64(line_parts.data[1], 0);
Dqn_Str8 anim_name = line_parts.data[0];
Dqn_Str8ToU64Result frames_per_second = Dqn_Str8_ToU64(line_parts.data[1], 0);
DQN_ASSERTF(frames_per_second.success, "Frames per second was not a convertible number, line was '%.*s'", line);
Dqn_DSMapResult<SpriteSpecification> slot = Dqn_DSMap_MakeKeyString8Copy(&sprite_spec_table, scratch.allocator, anim_name);
Dqn_DSMapResult<SpriteSpecification> slot = Dqn_DSMap_MakeKeyStr8Copy(&sprite_spec_table, scratch.allocator, anim_name);
slot.value->frames_per_second = DQN_CAST(uint16_t)frames_per_second.value;
}
}
// NOTE: Get the list of files =================================================================
Dqn_List<Dqn_String8> file_list_raw = Dqn_List_Init<Dqn_String8>(scratch.arena, 128);
Dqn_List<Dqn_Str8> file_list_raw = Dqn_List_Init<Dqn_Str8>(scratch.arena, 128);
for (Dqn_Win_FolderIterator it = {}; Dqn_Win_FolderIterate(dir, &it); ) {
if (Dqn_String8_EndsWithInsensitive(it.file_name, DQN_STRING8(".png"))) {
Dqn_String8 *item = Dqn_List_Make(&file_list_raw, Dqn_ZeroMem_Yes);
*item = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/%.*s", DQN_STRING_FMT(dir), DQN_STRING_FMT(it.file_name));
if (Dqn_Str8_EndsWithInsensitive(it.file_name, DQN_STR8(".png"))) {
Dqn_Str8 *item = Dqn_List_Make(&file_list_raw, Dqn_ZeroMem_Yes);
*item = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/%.*s", DQN_STR_FMT(dir), DQN_STR_FMT(it.file_name));
}
}
// NOTE: Sort the list of files ================================================================
if (file_list_raw.count == 0) {
Dqn_Log_InfoF("There are no '.png' files in the directory '%.*s' to create an atlas from, exiting", DQN_STRING_FMT(dir));
Dqn_Log_InfoF("There are no '.png' files in the directory '%.*s' to create an atlas from, exiting", DQN_STR_FMT(dir));
return 0;
}
// NOTE: Bubble sort the file list naturally ===================================================
Dqn_Slice<Dqn_String8> file_list = Dqn_List_ToSliceCopy(&file_list_raw, scratch.arena);
Dqn_Slice<Dqn_Str8> file_list = Dqn_List_ToSliceCopy(&file_list_raw, scratch.arena);
for (bool swapped = true; swapped; ) {
swapped = false;
for (Dqn_usize list_index = 0; list_index < file_list.size - 1; list_index++) {
Dqn_String8 left = file_list.data[list_index + 0];
Dqn_String8 right = file_list.data[list_index + 1];
Dqn_Str8 left = file_list.data[list_index + 0];
Dqn_Str8 right = file_list.data[list_index + 1];
if (strnatcmp(left.data, right.data) > 0) {
DQN_SWAP(file_list.data[list_index + 0], file_list.data[list_index + 1]);
swapped = true;
@@ -165,7 +167,7 @@ int main(int argc, char const *argv[])
// NOTE: Load the sprites to determine their dimensions for rect packing =======================
Dqn_SArray<stbrp_rect> rects = Dqn_SArray_Init<stbrp_rect>(scratch.arena, file_list.size, Dqn_ZeroMem_Yes);
for (Dqn_String8 it : file_list) {
for (Dqn_Str8 it : file_list) {
int x = 0, y = 0, channels_in_file = 0;
stbi_uc *pixels = stbi_load(it.data, &x, &y, &channels_in_file, 4 /*desired_channels*/);
DQN_ASSERT(pixels);
@@ -177,16 +179,16 @@ int main(int argc, char const *argv[])
rect->h = y;
// NOTE: Enumerate the number of frames for this animation =================================
Dqn_String8 anim_prefix = SpriteAnimNameFromFilePath(it);
Dqn_String8 file_name = Dqn_String8_FileNameFromPath(it);
DQN_ASSERTF(!Dqn_String8_HasChar(file_name, ';'),
Dqn_Str8 anim_prefix = SpriteAnimNameFromFilePath(it);
Dqn_Str8 file_name = Dqn_Str8_FileNameFromPath(it);
DQN_ASSERTF(!Dqn_Str8_HasChar(file_name, ';'),
"\n\nSprite frame loaded from file\n"
" '%.*s'\n"
"\n"
"however the file name has a semicolon which is not supported because we use a semicolon to delimit our sprite specification",
DQN_STRING_FMT(file_name));
DQN_STR_FMT(file_name));
Dqn_DSMapResult<SpriteSpecification> slot = Dqn_DSMap_FindKeyString8(&sprite_spec_table, anim_prefix);
Dqn_DSMapResult<SpriteSpecification> slot = Dqn_DSMap_FindKeyStr8(&sprite_spec_table, anim_prefix);
DQN_ASSERTF(slot.found,
"\n\nSprite frame loaded from file\n"
" '%.*s'\n"
@@ -196,12 +198,12 @@ int main(int argc, char const *argv[])
"\n"
"Add a line in format of <animation name>;<frames_per_second> to the file, e.g.\n"
" %.*s;8\n",
DQN_STRING_FMT(it),
DQN_STRING_FMT(sprite_spec_path),
DQN_STRING_FMT(anim_prefix));
DQN_STR_FMT(it),
DQN_STR_FMT(sprite_spec_path),
DQN_STR_FMT(anim_prefix));
slot.value->frame_count++;
Dqn_Log_InfoF("Packing sprite: %.*s", DQN_STRING_FMT(it));
Dqn_Log_InfoF("Packing sprite: %.*s", DQN_STR_FMT(it));
}
// NOTE: Pack the rects ========================================================================
@@ -217,7 +219,7 @@ int main(int argc, char const *argv[])
int final_bpp = 4;
int final_image_stride = atlas_size.w * final_bpp;
char *final_image = Dqn_Arena_NewArray(scratch.arena, char, atlas_size.h * final_image_stride, Dqn_ZeroMem_Yes);
Dqn_String8 atlas_path = Dqn_String8_InitF(scratch.allocator, "%.*s.png", DQN_STRING_FMT(dir));
Dqn_Str8 atlas_path = Dqn_Str8_InitF(scratch.allocator, "%.*s.png", DQN_STR_FMT(dir));
// NOTE: Generate the meta file ================================================================
// NOTE: Count the number of animations we loaded frames fore
@@ -231,18 +233,18 @@ int main(int argc, char const *argv[])
}
}
Dqn_String8 meta_path = Dqn_String8_InitF(scratch.allocator, "%.*s.txt", DQN_STRING_FMT(dir));
Dqn_Str8 meta_path = Dqn_Str8_InitF(scratch.allocator, "%.*s.txt", DQN_STR_FMT(dir));
Dqn_FsFile meta_file = Dqn_Fs_OpenFile(meta_path, Dqn_FsFileOpen_CreateAlways, Dqn_FsFileAccess_Write);
Dqn_Fs_WriteFileF(&meta_file,
"@file;%.*s;%d;%d\n",
DQN_STRING_FMT(Dqn_String8_FileNameFromPath(atlas_path)),
DQN_STR_FMT(Dqn_Str8_FileNameFromPath(atlas_path)),
DQN_CAST(int) num_anim_rects,
DQN_CAST(int) num_anims);
Dqn_Log_InfoF("Generating meta file: %.*s", DQN_STRING_FMT(meta_path));
Dqn_String8 active_anim_prefix = {};
Dqn_Log_InfoF("Generating meta file: %.*s", DQN_STR_FMT(meta_path));
Dqn_Str8 active_anim_prefix = {};
DQN_FOR_UINDEX (file_list_index, file_list.size) {
Dqn_String8 it = file_list.data[file_list_index];
Dqn_Str8 it = file_list.data[file_list_index];
int w, h, channels_in_file;
stbi_uc *loaded_image = stbi_load(it.data, &w, &h, &channels_in_file, 4 /*desired_channels*/);
@@ -263,22 +265,22 @@ int main(int argc, char const *argv[])
stbi_image_free(loaded_image);
// NOTE: Detect what animation we are currently processing =================================
Dqn_String8 anim_prefix = SpriteAnimNameFromFilePath(it);
Dqn_Str8 anim_prefix = SpriteAnimNameFromFilePath(it);
if (active_anim_prefix.size == 0 || active_anim_prefix != anim_prefix) {
// NOTE: Anim prefix is different, we are starting a new animation- mark it accordingly
active_anim_prefix = anim_prefix;
Dqn_DSMapResult<SpriteSpecification> slot = Dqn_DSMap_FindKeyString8(&sprite_spec_table, active_anim_prefix);
Dqn_Fs_WriteFileF(&meta_file, "@anim;%.*s;%u;%u\n", DQN_STRING_FMT(active_anim_prefix), slot.value->frames_per_second, slot.value->frame_count);
Dqn_DSMapResult<SpriteSpecification> slot = Dqn_DSMap_FindKeyStr8(&sprite_spec_table, active_anim_prefix);
Dqn_Fs_WriteFileF(&meta_file, "@anim;%.*s;%u;%u\n", DQN_STR_FMT(active_anim_prefix), slot.value->frames_per_second, slot.value->frame_count);
}
// NOTE: Write the sprite rectangles in ====================================================
Dqn_String8 file_name = Dqn_String8_FileNameFromPath(it);
Dqn_Fs_WriteFileF(&meta_file, "%d;%d;%d;%d;%.*s", packed_rect.x, packed_rect.y, packed_rect.w, packed_rect.h, DQN_STRING_FMT(file_name));
Dqn_Str8 file_name = Dqn_Str8_FileNameFromPath(it);
Dqn_Fs_WriteFileF(&meta_file, "%d;%d;%d;%d;%.*s", packed_rect.x, packed_rect.y, packed_rect.w, packed_rect.h, DQN_STR_FMT(file_name));
if (file_list_index != (file_list.size - 1))
Dqn_Fs_WriteFileF(&meta_file, "\n");
}
Dqn_Log_InfoF("Generating atlas: %.*s", DQN_STRING_FMT(atlas_path));
Dqn_Log_InfoF("Generating atlas: %.*s", DQN_STR_FMT(atlas_path));
stbi_write_png(atlas_path.data, atlas_size.w, atlas_size.h, 4, final_image, final_image_stride);
return 0;
}
+1
View File
@@ -0,0 +1 @@
#include "feely_pona_unity.h"
+8 -59
View File
@@ -1,65 +1,13 @@
// =================================================================================================
// NOTE: feely_pona ================================================================================
// Unity build header to compile the entire application as a single translation unit
// NOTE(doyle): Work-around for clangd to correctly resolve symbols in unity
// builds by providing symbol definition and prototypes by including this
// mega-header in all files and using the "#pragma once" directive to
// avoid multiple defined symbols when compiling the unity build itself.
//
// See: https://www.frogtoss.com/labs/clangd-with-unity-builds.html
#pragma once
// NOTE: DQN =======================================================================================
// NOTE: C-strings declared in a ternary cause global-buffer-overflow in
// MSVC2022.
// stb_sprintf assumes c-string literals are 4 byte aligned which is always
// true, however, reading past the end of a string whose size is not a multiple
// of 4 is UB causing ASAN to complain.
#if defined(_MSC_VER) && !defined(__clang__)
#define STBSP__ASAN __declspec(no_sanitize_address)
#endif
#define DQN_ASAN_POISON 0
#define DQN_ASAN_VET_POISON 1
#define DQN_ONLY_RECT
#define DQN_ONLY_V2
#define DQN_ONLY_V3
#define DQN_ONLY_V4
#define DQN_ONLY_WIN
#define DQN_ONLY_FARRAY
#define DQN_ONLY_PROFILER
#define DQN_ONLY_SLICE
#define DQN_ONLY_LIST
#define DQN_ONLY_VARRAY
#define DQN_ONLY_DSMAP
#define DQN_ONLY_FS
#define _CRT_SECURE_NO_WARNINGS
#define DQN_IMPLEMENTATION
#include "External/tely/External/dqn/dqn.h"
// NOTE: TELY ======================================================================================
DQN_MSVC_WARNING_PUSH
DQN_MSVC_WARNING_DISABLE(4505) // warning C4505: unreferenced function with internal linkage has been removed
#include "External/tely/tely_profile.h"
#include "External/tely/tely_platform_input.h"
#include "External/tely/tely_tools.h"
#include "External/tely/tely_asset.h"
#include "External/tely/tely_colour.h"
#include "External/tely/tely_render.h"
#include "External/tely/tely_audio.h"
#include "External/tely/tely_platform.h"
#include "External/tely/tely_rfui.h"
#include "External/tely/tely_tools.cpp"
#include "External/tely/tely_asset.cpp"
#include "External/tely/tely_audio.cpp"
#include "External/tely/tely_render.cpp"
#include "External/tely/tely_platform_input.cpp"
#include "External/tely/tely_rfui.cpp"
#define TELY_PLATFORM_DLL_FILE_NAME "terry_cherry_dev_dll"
#include "External/tely/tely_backend_raylib_unity.h"
// NOTE: feely_pona ================================================================================
#if defined(_CLANGD) || defined(FEELY_PONA_IMPLEMENTATION)
DQN_MSVC_WARNING_PUSH
DQN_MSVC_WARNING_DISABLE(4505) // warning C4505: unreferenced function with internal linkage has been removed
#include "feely_pona.h"
#include "feely_pona_stdlib.h"
#include "feely_pona_entity.h"
@@ -71,3 +19,4 @@ DQN_MSVC_WARNING_DISABLE(4505) // warning C4505: unreferenced function with inte
#include "feely_pona_misc.cpp"
#include "feely_pona.cpp"
DQN_MSVC_WARNING_POP
#endif
-1
View File
@@ -1 +0,0 @@
#include "feely_pona_unity_nodll.h"
-102
View File
@@ -1,102 +0,0 @@
// =================================================================================================
// NOTE(doyle): Work-around for clangd to correctly resolve symbols in unity
// builds by providing symbol definition and prototypes by including this
// mega-header in all files and using the "#pragma once" directive to
// avoid multiple defined symbols when compiling the unity build itself.
//
// See: https://www.frogtoss.com/labs/clangd-with-unity-builds.html
#pragma once
// NOTE: DQN =======================================================================================
// NOTE: C-strings declared in a ternary cause global-buffer-overflow in
// MSVC2022.
// stb_sprintf assumes c-string literals are 4 byte aligned which is always
// true, however, reading past the end of a string whose size is not a multiple
// of 4 is UB causing ASAN to complain.
#if defined(_MSC_VER) && !defined(__clang__)
#define STBSP__ASAN __declspec(no_sanitize_address)
#endif
#define DQN_ASAN_POISON 0
#define DQN_ASAN_VET_POISON 1
#define DQN_ONLY_RECT
#define DQN_ONLY_V2
#define DQN_ONLY_V3
#define DQN_ONLY_V4
#define DQN_ONLY_WIN
#define DQN_ONLY_FARRAY
#define DQN_ONLY_PROFILER
#define DQN_ONLY_SLICE
#define DQN_ONLY_LIST
#define DQN_ONLY_VARRAY
#define DQN_ONLY_DSMAP
#define DQN_ONLY_FS
#define _CRT_SECURE_NO_WARNINGS
#define DQN_IMPLEMENTATION
#include "External/tely/External/dqn/dqn.h"
// NOTE: STB Headers ===============================================================================
DQN_GCC_WARNING_PUSH
DQN_GCC_WARNING_DISABLE(-Wunused-function)
#include "External/tely/External/stb/stb_image.h"
DQN_GCC_WARNING_POP
// =================================================================================================
#include "External/tely/External/raylib/raylib.h"
#include "External/tely/External/raylib/rlgl.h"
#include "External/tely/External/raylib/external/glfw/include/GLFW/glfw3.h"
// NOTE: TELY ======================================================================================
DQN_MSVC_WARNING_PUSH
DQN_MSVC_WARNING_DISABLE(4505) // warning C4505: unreferenced function with internal linkage has been removed
DQN_GCC_WARNING_PUSH
DQN_GCC_WARNING_DISABLE(-Wunused-function)
#include "External/tely/tely_profile.h"
#include "External/tely/tely_platform_input.h"
#include "External/tely/tely_tools.h"
#include "External/tely/tely_asset.h"
#include "External/tely/tely_colour.h"
#include "External/tely/tely_render.h"
#include "External/tely/tely_audio.h"
#include "External/tely/tely_platform.h"
#include "External/tely/tely_rfui.h"
#include "External/tely/tely_tools.cpp"
#include "External/tely/tely_asset.cpp"
#include "External/tely/tely_audio.cpp"
#include "External/tely/tely_render.cpp"
#include "External/tely/tely_platform_input.cpp"
#include "External/tely/tely_rfui.cpp"
// NOTE: feely_pona ================================================================================
#include "feely_pona.h"
#include "feely_pona_stdlib.h"
#include "feely_pona_entity.h"
#include "feely_pona_game.h"
#include "feely_pona_entity.cpp"
#include "feely_pona_game.cpp"
#include "feely_pona_entity_create.cpp"
#include "feely_pona_misc.cpp"
#include "feely_pona.cpp"
DQN_MSVC_WARNING_POP
DQN_GCC_WARNING_POP
#if defined(DQN_PLATFORM_EMSCRIPTEN)
#include <emscripten/emscripten.h>
#include <emscripten/html5.h>
#endif
// NOTE: TELY_Platform =============================================================================
#define TELY_PLATFORM_NO_DLL
#include "External/tely/tely_platform.cpp"
#include "External/tely/tely_platform_raylib.cpp"
BIN
View File
Binary file not shown.
+2 -2
View File
@@ -25,7 +25,7 @@ forwards them to the command line).
You must ensure you have MSVC's `cl.exe` on your path to build. This game was
tested on MSVC 2023 (v14.34.31933).
For most intents and purposes you may simply execute `build.bat` on Windows
For most intents and purposes you may simply execute `build_all.bat` on Windows
which bootstraps the build program and automatically calls the meta-build
program. With fast computers nowadays our default is to build all targets by
default (except web due to extra toolchain requirements).
@@ -57,7 +57,7 @@ then be done by
Tools\emsdk\emsdk.bat activate latest
# Build the game
build --web
build_all --web
```
This will produce at `Build\Terry_Cherry_Emscripten` a HTML and WASM file ready