Cameron Murphy Reikes 9 months ago
commit 7605d37d72

@ -1,10 +1,10 @@
# rpgpt # [Dante's Cowboy - Wishlist now on Steam!](https://store.steampowered.com/app/2501370/Dantes_Cowboy)
RPG GPT. Short experience A fantasy western RPG with an immersive and natural dynamic dialogue system powered by GPT.
![Western Frontier](https://upload.wikimedia.org/wikipedia/commons/thumb/3/32/Distribution_of_US_Rural_Population_during_1900.pdf/page1-1280px-Distribution_of_US_Rural_Population_during_1900.pdf.jpg) ![Western Frontier](https://upload.wikimedia.org/wikipedia/commons/thumb/3/32/Distribution_of_US_Rural_Population_during_1900.pdf/page1-1280px-Distribution_of_US_Rural_Population_during_1900.pdf.jpg)
# Important Building Steps and Contribution Notes # Important Building Steps and Contribution Notes
Every time you checkin/clone the project, you have to unzip art.blend... If this is annoying to you, make a git hook Every time you checkin/clone the project, make sure to call `blender_export.bat` at least once! This will auto-extract `art\art.blend` and run `art\Exporter.py`, thereby baking, validating, and exporting all the assets and the level.
When editing Exporter.py in either the blender editor, or in a text editor in the repo, you have to continually make sure blender's internal version of the script doesn't go out of date with the actual script on disk, by either saving consistently from blender to disk if you're editing from blender, or by reloading from disk in the blend file before each commit. When editing Exporter.py in either the blender editor, or in a text editor in the repo, you have to continually make sure blender's internal version of the script doesn't go out of date with the actual script on disk, by either saving consistently from blender to disk if you're editing from blender, or by reloading from disk in the blend file before each commit.

@ -0,0 +1,33 @@
@echo off
pushd %~dp0%\art
if not exist "art.blend" (
powershell Expand-Archive -Path art.zip -DestinationPath . || goto :error
)
set "blender="
if exist "%ProgramFiles%\Blender Foundation\Blender 3.5\blender.exe" (
echo Using Blender 3.5 detected
set "blender=%ProgramFiles%\Blender Foundation\Blender 3.5\blender.exe"
)
if exist "%ProgramFiles%\Blender Foundation\Blender 3.6\blender.exe" (
echo Using Blender 3.6 detected
set "blender=%ProgramFiles%\Blender Foundation\Blender 3.6\blender.exe"
)
if "%blender%" neq "" (
call "%blender%" --background art.blend --python Exporter.py || goto :error
) else (
goto :error
)
goto :success
:error
echo Blender export failed
:success
set "returncode=%ERRORLEVEL%"
popd
exit /B %returncode%

@ -1,5 +1,5 @@
@echo off @echo off
START /B remedybg.exe stop-debugging START /B remedybg.exe stop-debugging
call build_desktop_debug.bat call build_desktop_debug.bat %*
remedybg.exe start-debugging remedybg.exe start-debugging

@ -0,0 +1,7 @@
@echo off
call build_web_debug.bat %* || goto :EOF
START "" "http://localhost:8000"
pushd %~dp0%\build_web
python -m http.server
popd

@ -2,10 +2,18 @@
@REM https://learn.microsoft.com/en-us/cpp/build/reference/compiler-options-listed-by-category?view=msvc-170 @REM https://learn.microsoft.com/en-us/cpp/build/reference/compiler-options-listed-by-category?view=msvc-170
setlocal enableDelayedExpansion
set "do_blender_export=0"
set "do_codegen=0"
for %%A in (%*) do (
if "%%~A"=="blender_export" ( set "do_blender_export=1" )
if "%%~A"=="codegen" ( set "do_codegen=1" )
)
if "%do_blender_export%"=="1" ( call blender_export.bat || goto :error )
if "%do_codegen%"=="1" ( call run_codegen.bat || goto :error )
if "%1" == "codegen" ( call run_codegen.bat || goto :error ) else ( echo NOT RUNNING CODEGEN )
@REM start /B zig cc -DDEVTOOLS -Igen -Ithirdparty -lDbghelp -lGdi32 -lD3D11 -lOle32 -lwinhttp -gfull -gcodeview -o main_zig.exe main.c @REM start /B zig cc -DDEVTOOLS -Igen -Ithirdparty -lDbghelp -lGdi32 -lD3D11 -lOle32 -lwinhttp -gfull -gcodeview -o main_zig.exe main.c
cl /diagnostics:caret /DDEVTOOLS /Igen /Ithirdparty /Wall /FC /Zi /WX Dbghelp.lib winhttp.lib main.c || goto :error cl /nologo /diagnostics:caret /DDEVTOOLS /Igen /Ithirdparty /Wall /FC /Zi /WX main.c /link /noimplib /noexp || goto :error
goto :EOF goto :EOF

@ -1,9 +1,17 @@
call run_codegen.bat || goto :error setlocal enableDelayedExpansion
set "do_blender_export=0"
set "do_codegen=0"
for %%A in (%*) do (
if "%%~A"=="blender_export" ( set "do_blender_export=1" )
if "%%~A"=="codegen" ( set "do_codegen=1" )
)
if "%do_blender_export%"=="1" ( call blender_export.bat || goto :error )
if "%do_codegen%"=="1" ( call run_codegen.bat || goto :error )
copy marketing_page\favicon.ico %OUTPUT_FOLDER%\favicon.ico copy marketing_page\favicon.ico %OUTPUT_FOLDER%\favicon.ico
@REM copy main.c %OUTPUT_FOLDER%\main.c || goto :error @REM copy main.c %OUTPUT_FOLDER%\main.c || goto :error
@echo on @echo off
emcc ^ emcc ^
-sEXPORTED_FUNCTIONS=_main,_end_text_input,_stop_controlling_input,_start_controlling_input,_read_from_save_data,_dump_save_data,_is_receiving_text_input^ -sEXPORTED_FUNCTIONS=_main,_end_text_input,_stop_controlling_input,_start_controlling_input,_read_from_save_data,_dump_save_data,_is_receiving_text_input^
-sEXPORTED_RUNTIME_METHODS=ccall,cwrap^ -sEXPORTED_RUNTIME_METHODS=ccall,cwrap^

@ -10,25 +10,16 @@ set FLAGS=-O0 -g -DDEVTOOLS
set OUTPUT_FOLDER=build_web set OUTPUT_FOLDER=build_web
if "%1" == "NO_VALIDATION" ( call build_web_common.bat %* || goto :error
echo Disabling graphics validation...
set FLAGS=%FLAGS% -DNDEBUG
)
call build_web_common.bat || goto :error
@echo off @echo off
if "%1" == "NO_VALIDATION" (
echo Validation turned off
) else (
echo If you want to turn graphics validation off to make web debug build faster, provide a command line argument called "NO_VALIDATION" to this build script
)
goto :success goto :success
:error :error
echo Failed to build echo Failed to build
:success :success
set "returncode=%ERRORLEVEL%"
popd popd
exit /B %ERRORLEVEL% exit /B %returncode%

@ -5,17 +5,17 @@ pushd %~dp0%
rmdir /S /q build_web_release rmdir /S /q build_web_release
mkdir build_web_release mkdir build_web_release
call run_codegen.bat || goto :error
set FLAGS=-O0 -DNDEBUG set FLAGS=-O0 -DNDEBUG
set OUTPUT_FOLDER=build_web_release set OUTPUT_FOLDER=build_web_release
call build_web_common.bat || goto :error call build_web_common.bat %* codegen || goto :error
goto :success goto :success
:error :error
echo Failed to build echo Failed to build
:success :success
set "returncode=%ERRORLEVEL%"
popd popd
exit /B %ERRORLEVEL% exit /B %returncode%

@ -21,11 +21,13 @@
#define DESKTOP #define DESKTOP
#define WINDOWS #define WINDOWS
#define SOKOL_GLCORE33 #define SOKOL_GLCORE33
#define SAMPLE_COUNT 4
#endif #endif
#if defined(__EMSCRIPTEN__) #if defined(__EMSCRIPTEN__)
#define WEB #define WEB
#define SOKOL_GLES2 #define SOKOL_GLES2
#define SAMPLE_COUNT 1 // bumping this back to 4 is troublesome for web, because there's a mismatch in sample counts. Perhaps we must upgrade to gles3, in doing so, we should upgrade to the newest sokol gfx.
#endif #endif
#define DRWAV_ASSERT game_assert #define DRWAV_ASSERT game_assert
@ -41,8 +43,6 @@
#pragma warning(push, 3) #pragma warning(push, 3)
#include <Windows.h> #include <Windows.h>
#include <processthreadsapi.h>
#include <dbghelp.h>
#include <stdint.h> #include <stdint.h>
// https://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf // https://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf
@ -53,13 +53,19 @@ __declspec(dllexport) uint32_t AmdPowerXpressRequestHighPerformance = 0x00000001
#endif #endif
#define STRINGIZE(x) STRINGIZE2(x)
#define STRINGIZE2(x) #x
#include "buff.h" #include "buff.h"
#include "sokol_app.h" #include "sokol_app.h"
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4191) // unsafe function calling #pragma warning(disable : 4191) // unsafe function calling
#ifdef WEB
# ifndef GL_EXT_PROTOTYPES
# define GL_GLEXT_PROTOTYPES
# endif
# include <GLES2/gl2.h>
# include <GLES2/gl2ext.h>
# undef glGetError
# define glGetError() (GL_NO_ERROR)
#endif
#include "sokol_gfx.h" #include "sokol_gfx.h"
#pragma warning(pop) #pragma warning(pop)
#include "sokol_time.h" #include "sokol_time.h"
@ -467,6 +473,7 @@ LPCWSTR windows_string(MD_String8 s)
#ifdef DESKTOP #ifdef DESKTOP
#ifdef WINDOWS #ifdef WINDOWS
#pragma warning(push, 3) #pragma warning(push, 3)
#pragma comment(lib, "WinHttp")
#include <WinHttp.h> #include <WinHttp.h>
#include <process.h> #include <process.h>
#pragma warning(pop) #pragma warning(pop)
@ -2703,7 +2710,7 @@ void create_screenspace_gfx_state()
.depth = { .depth = {
0 0
}, },
.sample_count = 1, .sample_count = SAMPLE_COUNT,
.layout = { .layout = {
.attrs = .attrs =
{ {
@ -2733,7 +2740,7 @@ void create_screenspace_gfx_state()
.depth = { .depth = {
.pixel_format = SG_PIXELFORMAT_NONE, .pixel_format = SG_PIXELFORMAT_NONE,
}, },
.sample_count = 1, .sample_count = SAMPLE_COUNT,
.layout = { .layout = {
.attrs = .attrs =
{ {
@ -2765,7 +2772,7 @@ void create_screenspace_gfx_state()
.wrap_u = SG_WRAP_CLAMP_TO_BORDER, .wrap_u = SG_WRAP_CLAMP_TO_BORDER,
.wrap_v = SG_WRAP_CLAMP_TO_BORDER, .wrap_v = SG_WRAP_CLAMP_TO_BORDER,
.border_color = SG_BORDERCOLOR_OPAQUE_WHITE, .border_color = SG_BORDERCOLOR_OPAQUE_WHITE,
.sample_count = 1, .sample_count = SAMPLE_COUNT,
.label = "outline-pass-render-target", .label = "outline-pass-render-target",
}; };
state.outline_pass_image = sg_make_image(&desc); state.outline_pass_image = sg_make_image(&desc);
@ -2777,7 +2784,7 @@ void create_screenspace_gfx_state()
.label = "outline-pass", .label = "outline-pass",
}); });
desc.sample_count = 1; desc.sample_count = SAMPLE_COUNT;
desc.label = "threedee-pass-render-target"; desc.label = "threedee-pass-render-target";
state.threedee_pass_image = sg_make_image(&desc); state.threedee_pass_image = sg_make_image(&desc);
@ -3750,9 +3757,11 @@ typedef enum
typedef BUFF(char, 200) StacktraceElem; typedef BUFF(char, 200) StacktraceElem;
typedef BUFF(StacktraceElem, 16) StacktraceInfo; typedef BUFF(StacktraceElem, 16) StacktraceInfo;
#if 0 // #ifdef WINDOWS
#include <dbghelp.h>
#pragma comment(lib, "DbgHelp")
StacktraceInfo get_stacktrace() StacktraceInfo get_stacktrace()
{ {
#ifdef WINDOWS
StacktraceInfo to_return = {0}; StacktraceInfo to_return = {0};
void *stack[ARRLEN(to_return.data)] = {0}; void *stack[ARRLEN(to_return.data)] = {0};
int captured = CaptureStackBackTrace(0, ARRLEN(to_return.data), stack, 0); int captured = CaptureStackBackTrace(0, ARRLEN(to_return.data), stack, 0);
@ -3786,10 +3795,13 @@ StacktraceInfo get_stacktrace()
free(symbol); free(symbol);
} }
return to_return; return to_return;
}
#else #else
StacktraceInfo get_stacktrace()
{
return (StacktraceInfo){0}; return (StacktraceInfo){0};
#endif
} }
#endif
typedef struct DrawParams typedef struct DrawParams
{ {
@ -4850,7 +4862,7 @@ Shadow_State init_shadow_state() {
.wrap_u = SG_WRAP_CLAMP_TO_BORDER, .wrap_u = SG_WRAP_CLAMP_TO_BORDER,
.wrap_v = SG_WRAP_CLAMP_TO_BORDER, .wrap_v = SG_WRAP_CLAMP_TO_BORDER,
.border_color = SG_BORDERCOLOR_OPAQUE_WHITE, .border_color = SG_BORDERCOLOR_OPAQUE_WHITE,
.sample_count = 1, .sample_count = SAMPLE_COUNT,
.label = "shadow-map-color-image" .label = "shadow-map-color-image"
}; };
shadows.color_img = sg_make_image(&img_desc); shadows.color_img = sg_make_image(&img_desc);
@ -4874,7 +4886,7 @@ Shadow_State init_shadow_state() {
.shader = sg_make_shader(threedee_mesh_shadow_mapping_shader_desc(sg_query_backend())), .shader = sg_make_shader(threedee_mesh_shadow_mapping_shader_desc(sg_query_backend())),
// Cull front faces in the shadow map pass // Cull front faces in the shadow map pass
// .cull_mode = SG_CULLMODE_BACK, // .cull_mode = SG_CULLMODE_BACK,
.sample_count = 1, .sample_count = SAMPLE_COUNT,
.depth = { .depth = {
.pixel_format = SG_PIXELFORMAT_DEPTH, .pixel_format = SG_PIXELFORMAT_DEPTH,
.compare = SG_COMPAREFUNC_LESS_EQUAL, .compare = SG_COMPAREFUNC_LESS_EQUAL,
@ -7303,9 +7315,31 @@ void event(const sapp_event *e)
} }
#endif #endif
if (e->type == SAPP_EVENTTYPE_KEY_DOWN && e->key_code == SAPP_KEYCODE_F11) if (e->type == SAPP_EVENTTYPE_KEY_DOWN &&
(e->key_code == SAPP_KEYCODE_F11 ||
e->key_code == SAPP_KEYCODE_ENTER && ((e->modifiers & SAPP_MODIFIER_ALT) || (e->modifiers & SAPP_MODIFIER_SHIFT))))
{ {
#ifdef DESKTOP
sapp_toggle_fullscreen(); sapp_toggle_fullscreen();
#else
EM_ASM({
var elem = document.documentElement;
if (document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement)
{
if (document.exitFullscreen) document.exitFullscreen();
else if (document.webkitExitFullscreen) document.webkitExitFullscreen();
else if (document.mozCancelFullScreen) document.mozCancelFullScreen();
else if (document.msExitFullscreen) document.msExitFullscreen();
}
else
{
if (elem.requestFullscreen) elem.requestFullscreen();
else if (elem.webkitRequestFullscreen) elem.webkitRequestFullscreen();
else if (elem.mozRequestFullScreen) elem.mozRequestFullScreen();
else if (elem.msRequestFullscreen) elem.msRequestFullscreen();
}
});
#endif
} }
#ifdef DEVTOOLS #ifdef DEVTOOLS
@ -7529,11 +7563,11 @@ sapp_desc sokol_main(int argc, char* argv[])
.frame_cb = frame, .frame_cb = frame,
.cleanup_cb = cleanup, .cleanup_cb = cleanup,
.event_cb = event, .event_cb = event,
.sample_count = 1, // bumping this back to 4 is troublesome for web, because there's a mismatch in sample counts. Perhaps we must upgrade to gles3, in doing so, we should upgrade to the newest sokol gfx. .sample_count = SAMPLE_COUNT,
.width = 800, .width = 800,
.height = 600, .height = 600,
//.gl_force_gles2 = true, not sure why this was here in example, look into //.gl_force_gles2 = true, not sure why this was here in example, look into
.window_title = "RPGPT", .window_title = "Dante's Cowboy",
.win32_console_attach = true, .win32_console_attach = true,
.win32_console_create = true, .win32_console_create = true,
.icon.sokol_default = true, .icon.sokol_default = true,

@ -1,9 +1,9 @@
@echo on @echo off
echo Running codegen... @REM echo Running codegen...
if exist gen\ ( if exist gen\ (
echo "Codegen folder already exists, not deleting because that messes with vscode intellisense..." @REM echo "Codegen folder already exists, not deleting because that messes with vscode intellisense..."
) else ( ) else (
mkdir gen mkdir gen
) )
@ -12,11 +12,11 @@ if exist gen\ (
thirdparty\sokol-shdc.exe --input threedee.glsl --output gen\threedee.glsl.h --slang glsl100:hlsl5:metal_macos:glsl330 || goto :error thirdparty\sokol-shdc.exe --input threedee.glsl --output gen\threedee.glsl.h --slang glsl100:hlsl5:metal_macos:glsl330 || goto :error
@REM metadesk codegen @REM metadesk codegen
cl /Ithirdparty /W3 /Zi /WX codegen.c || goto :error cl /nologo /diagnostics:caret /Ithirdparty /W3 /Zi /WX codegen.c || goto :error
@REM zig cc -Ithirdparty -gfull -gcodeview codegen.c -o codegen.exe || goto error @REM zig cc -Ithirdparty -gfull -gcodeview codegen.c -o codegen.exe || goto error
codegen || goto :error codegen || goto :error
@REM cl /Ithirdparty /Igen /W3 /Zi /WX maketraining.c || goto :error @REM cl /nologo /diagnostics:caret /Ithirdparty /Igen /W3 /Zi /WX maketraining.c || goto :error
@REM maketraining || goto :error @REM maketraining || goto :error
goto :EOF goto :EOF

@ -1,43 +1,24 @@
#pragma once #pragma once
#include <stdio.h> #include <stdio.h>
#include <stdbool.h>
#ifdef WEB #define STRINGIZE(x) STRINGIZE2(x)
#include <signal.h> #define STRINGIZE2(x) #x
#define game_debugbreak() raise(SIGTRAP)
#define game_assert_4127_push
#define game_assert_4127_pop
#ifdef WEB
#define assert_impl(cond, str) ((cond) || (EM_ASM({ assert(0, UTF8ToString($0) + UTF8ToString($1)); }, (__func__), (str)), 0))
#elif defined(DESKTOP) #elif defined(DESKTOP)
#define game_debugbreak() __debugbreak() #define assert_impl(cond, str) ((cond) || (fputs("Assertion failed: " __FUNCTION__ str "\n", stderr), __debugbreak(), 0))
#define game_assert_4127_push __pragma(warning(push)) __pragma(warning(disable:4127))
#define game_assert_4127_pop __pragma(warning(pop))
#else #else
#error "Don't know how to assert for current platform configuration" #error "Don't know how to assert for current platform configuration"
#define game_debugbreak() (void)(0)
#endif #endif
static void assert_impl(const char *func, const char *file, long line, const char *expression)
{
fprintf(stderr, "Assert fail in %s(%s:%ld):\n \"%s\"\n", func, file, line, expression);
}
#ifdef NDEBUG #ifdef NDEBUG
#define game_assert(cond) game_assert_4127_push do { (void)0; } while (0) game_assert_4127_pop #define game_assert(cond) ((void)0)
#else #else
#define game_assert(cond) game_assert_4127_push do { \ #define game_assert(cond) assert_impl(cond, "(" __FILE__ ":" STRINGIZE(__LINE__) "): \"" #cond "\"")
if (!(cond)) { \
assert_impl(__func__, __FILE__, __LINE__, #cond); \
game_debugbreak(); \
} \
} while (0) game_assert_4127_pop
#endif #endif
#ifdef assert #ifdef assert
#undef assert #undef assert
#endif #endif

@ -3,7 +3,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>AI RPG</title> <title>Dante's Cowboy</title>
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style type="text/css"> <style type="text/css">

Loading…
Cancel
Save