Compare commits

..

No commits in common. '29f85887ac1e1ff0d6fdf1d1dec5236768672619' and '4065074e0eed3ef8ab851295a7b841aa2357f44d' have entirely different histories.

@ -18,7 +18,7 @@
<RunCommandWorkingDirectory></RunCommandWorkingDirectory> <RunCommandWorkingDirectory></RunCommandWorkingDirectory>
<DebugCommand>remedybg.exe start-debugging</DebugCommand> <DebugCommand>remedybg.exe start-debugging</DebugCommand>
<ExePathCommand></ExePathCommand> <ExePathCommand></ExePathCommand>
<DebugSln>main.sln</DebugSln> <DebugSln></DebugSln>
<UseVisualStudioEnvBat>true</UseVisualStudioEnvBat> <UseVisualStudioEnvBat>true</UseVisualStudioEnvBat>
<Configurations> <Configurations>
<Configuration>Debug</Configuration> <Configuration>Debug</Configuration>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -1,7 +1,5 @@
@echo off @echo off
pushd %~dp0%
rmdir /S /q build_web rmdir /S /q build_web
mkdir build_web mkdir build_web
@ -25,10 +23,8 @@ if "%1" == "NO_VALIDATION" (
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 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 :EOF
:error :error
echo Failed to build echo Failed to build
:success
popd
exit /B %ERRORLEVEL% exit /B %ERRORLEVEL%

@ -1,7 +1,5 @@
@echo off @echo off
pushd %~dp0%
rmdir /S /q build_web_release rmdir /S /q build_web_release
mkdir build_web_release mkdir build_web_release
@ -12,10 +10,8 @@ set OUTPUT_FOLDER=build_web_release
call build_web_common.bat || goto :error call build_web_common.bat || goto :error
goto :success goto :EOF
:error :error
echo Failed to build echo Failed to build
:success
popd
exit /B %ERRORLEVEL% exit /B %ERRORLEVEL%

204
main.c

@ -28,12 +28,6 @@
#define SOKOL_GLES2 #define SOKOL_GLES2
#endif #endif
#define DRWAV_ASSERT game_assert
#define SOKOL_ASSERT game_assert
#define STBDS_ASSERT game_assert
#define STBI_ASSERT game_assert
#define STBTT_assert game_assert
#include "utility.h" #include "utility.h"
#ifdef WINDOWS #ifdef WINDOWS
@ -73,14 +67,11 @@ __declspec(dllexport) uint32_t AmdPowerXpressRequestHighPerformance = 0x00000001
#pragma warning(pop) #pragma warning(pop)
#define STB_TRUETYPE_IMPLEMENTATION #define STB_TRUETYPE_IMPLEMENTATION
#include "stb_truetype.h" #include "stb_truetype.h"
#define STB_DS_IMPLEMENTATION
#include "stb_ds.h"
#include "HandmadeMath.h" #include "HandmadeMath.h"
#define DR_WAV_IMPLEMENTATION #define DR_WAV_IMPLEMENTATION
#include "dr_wav.h" #include "dr_wav.h"
#define STB_DS_IMPLEMENTATION
#include "stb_ds.h" // placed last because it includes <assert.h>
#undef assert
#define assert game_assert
#pragma warning(pop) #pragma warning(pop)
@ -188,8 +179,6 @@ void web_arena_set_auto_align(WebArena *arena, size_t align)
#define STBSP_ADD_TO_FUNCTIONS no_ubsan #define STBSP_ADD_TO_FUNCTIONS no_ubsan
#define MD_FUNCTION no_ubsan #define MD_FUNCTION no_ubsan
#include "md.h" #include "md.h"
#undef MD_Assert
#define MD_Assert assert
#include "md.c" #include "md.c"
#pragma warning(pop) #pragma warning(pop)
@ -289,12 +278,6 @@ typedef struct AABB
Vec2 lower_right; Vec2 lower_right;
} AABB; } AABB;
typedef struct Circle
{
Vec2 center;
float radius;
} Circle;
typedef struct Quad typedef struct Quad
{ {
union union
@ -329,7 +312,6 @@ typedef struct AudioSample
{ {
float *pcm_data; // allocated by loader, must be freed float *pcm_data; // allocated by loader, must be freed
uint64_t pcm_data_length; uint64_t pcm_data_length;
unsigned int num_channels;
} AudioSample; } AudioSample;
typedef struct AudioPlayer typedef struct AudioPlayer
@ -346,19 +328,18 @@ AudioPlayer playing_audio[128] = { 0 };
AudioSample load_wav_audio(const char *path) AudioSample load_wav_audio(const char *path)
{ {
unsigned int channels;
unsigned int sampleRate; unsigned int sampleRate;
AudioSample to_return = { 0 }; AudioSample to_return = { 0 };
to_return.pcm_data = drwav_open_file_and_read_pcm_frames_f32(path, &to_return.num_channels, &sampleRate, &to_return.pcm_data_length, 0); to_return.pcm_data = drwav_open_file_and_read_pcm_frames_f32(path, &channels, &sampleRate, &to_return.pcm_data_length, 0);
assert(to_return.num_channels == 1 || to_return.num_channels == 2); assert(channels == 1);
assert(sampleRate == SAMPLE_RATE); assert(sampleRate == SAMPLE_RATE);
return to_return; return to_return;
} }
void cursor_pcm(AudioPlayer *p, uint64_t *integer, float *fractional) uint64_t cursor_pcm(AudioPlayer *p)
{ {
double sample_time = p->cursor_time * SAMPLE_RATE; return (uint64_t)(p->cursor_time * SAMPLE_RATE);
*integer = (uint64_t)sample_time;
*fractional = (float)(sample_time - *integer);
} }
float float_rand(float min, float max) float float_rand(float min, float max)
{ {
@ -531,8 +512,6 @@ void generation_thread(void* my_request_voidptr)
WinAssertWithErrorCode(WinHttpQueryHeaders(hRequest, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, WINHTTP_HEADER_NAME_BY_INDEX, &status_code, &status_code_size, WINHTTP_NO_HEADER_INDEX)); WinAssertWithErrorCode(WinHttpQueryHeaders(hRequest, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, WINHTTP_HEADER_NAME_BY_INDEX, &status_code, &status_code_size, WINHTTP_NO_HEADER_INDEX));
Log("Status code: %lu\n", status_code); Log("Status code: %lu\n", status_code);
WinAssertWithErrorCode(status_code != 500);
DWORD dwSize = 0; DWORD dwSize = 0;
MD_String8List received_data_list = {0}; MD_String8List received_data_list = {0};
do do
@ -719,23 +698,6 @@ Vec2 entity_aabb_size(Entity *e)
} }
} }
float entity_radius(Entity *e)
{
if (e->is_character)
{
return 0.35f;
}
else if (e->is_npc)
{
return 0.5f;
}
else
{
assert(false);
return 0;
}
}
Vec2 rotate_counter_clockwise(Vec2 v) Vec2 rotate_counter_clockwise(Vec2 v)
{ {
return V2(-v.Y, v.X); return V2(-v.Y, v.X);
@ -1260,17 +1222,17 @@ Armature load_armature(MD_Arena *arena, MD_String8 binary_file, MD_String8 armat
return to_return; return to_return;
} }
typedef struct CollisionCylinder typedef struct CollisionCube
{ {
struct CollisionCylinder *next; struct CollisionCube *next;
Circle bounds; AABB bounds;
} CollisionCylinder; } CollisionCube;
typedef struct typedef struct
{ {
Mesh *mesh_list; Mesh *mesh_list;
PlacedMesh *placed_mesh_list; PlacedMesh *placed_mesh_list;
CollisionCylinder *collision_list; CollisionCube *collision_list;
PlacedEntity *placed_entity_list; PlacedEntity *placed_entity_list;
} ThreeDeeLevel; } ThreeDeeLevel;
@ -1373,14 +1335,13 @@ ThreeDeeLevel load_level(MD_Arena *arena, MD_String8 binary_file)
ser_MD_u64(&ser, &num_collision_cubes); ser_MD_u64(&ser, &num_collision_cubes);
for(MD_u64 i = 0; i < num_collision_cubes; i++) for(MD_u64 i = 0; i < num_collision_cubes; i++)
{ {
CollisionCylinder *new_cylinder = MD_PushArray(arena, CollisionCylinder, 1); CollisionCube *new_cube = MD_PushArray(arena, CollisionCube, 1);
Vec2 twodee_pos; Vec2 twodee_pos;
Vec2 size; Vec2 size;
ser_Vec2(&ser, &twodee_pos); ser_Vec2(&ser, &twodee_pos);
ser_Vec2(&ser, &size); ser_Vec2(&ser, &size);
new_cylinder->bounds.center = twodee_pos; new_cube->bounds = aabb_centered(twodee_pos, size);
new_cylinder->bounds.radius = (size.x + size.y) * 0.5f; // @TODO(Phillip): @Temporary MD_StackPush(out.collision_list, new_cube);
MD_StackPush(out.collision_list, new_cylinder);
} }
// placed entities // placed entities
@ -2782,7 +2743,7 @@ void create_screenspace_gfx_state()
state.threedee_pass_image = sg_make_image(&desc); state.threedee_pass_image = sg_make_image(&desc);
desc.label = "threedee-pass-depth-render-target"; desc.label = "threedee-pass-depth-render-target";
desc.pixel_format = sapp_depth_format(); desc.pixel_format = SG_PIXELFORMAT_DEPTH;
state.threedee_pass_depth_image = sg_make_image(&desc); state.threedee_pass_depth_image = sg_make_image(&desc);
state.threedee_pass = sg_make_pass(&(sg_pass_desc){ state.threedee_pass = sg_make_pass(&(sg_pass_desc){
@ -2917,51 +2878,29 @@ float decode_normalized_float32(PixelData encoded)
void audio_stream_callback(float *buffer, int num_frames, int num_channels) void audio_stream_callback(float *buffer, int num_frames, int num_channels)
{ {
assert(num_channels == 2); assert(num_channels == 1);
const int num_samples = num_frames * num_channels; const int num_samples = num_frames * num_channels;
double time_per_sample = 1.0 / (double)SAMPLE_RATE; double time_per_sample = 1.0 / (double)SAMPLE_RATE;
for (int i = 0; i < num_samples; i += num_channels) for (int i = 0; i < num_samples; i++)
{ {
float output_frames[2] = {0}; float output_frame = 0.0f;
for (int audio_i = 0; audio_i < ARRLEN(playing_audio); audio_i++) for (int audio_i = 0; audio_i < ARRLEN(playing_audio); audio_i++)
{ {
AudioPlayer *it = &playing_audio[audio_i]; AudioPlayer *it = &playing_audio[audio_i];
if (it->sample != 0) if (it->sample != 0)
{ {
uint64_t pcm_position_int; if (cursor_pcm(it) >= it->sample->pcm_data_length)
float pcm_position_frac;
cursor_pcm(it, &pcm_position_int, &pcm_position_frac);
if (pcm_position_int + 1 >= it->sample->pcm_data_length)
{ {
it->sample = 0; it->sample = 0;
} }
else else
{ {
const int source_num_channels = it->sample->num_channels; output_frame += it->sample->pcm_data[cursor_pcm(it)]*(float)(it->volume + 1.0);
float volume = (float)(it->volume + 1.0);
if (source_num_channels == 1) {
float src = Lerp(it->sample->pcm_data[pcm_position_int], pcm_position_frac, it->sample->pcm_data[pcm_position_int + 1]) * volume;
output_frames[0] += src;
output_frames[1] += src;
} else if (source_num_channels == 2) {
float src[2];
src[0] = Lerp(it->sample->pcm_data[pcm_position_int * 2 + 0], pcm_position_frac, it->sample->pcm_data[(pcm_position_int + 1) * 2 + 0]) * volume;
src[1] = Lerp(it->sample->pcm_data[pcm_position_int * 2 + 1], pcm_position_frac, it->sample->pcm_data[(pcm_position_int + 1) * 2 + 1]) * volume;
output_frames[0] += src[0];
output_frames[1] += src[1];
} else {
assert(false);
}
it->cursor_time += time_per_sample*(it->pitch + 1.0); it->cursor_time += time_per_sample*(it->pitch + 1.0);
} }
} }
} }
if (num_channels == 1) { buffer[i] = output_frame;
buffer[i] = (output_frames[0] + output_frames[1]) * 0.5f;
} else if (num_channels == 2) {
buffer[i + 0] = output_frames[0];
buffer[i + 1] = output_frames[1];
}
} }
} }
@ -3210,7 +3149,6 @@ void init(void)
saudio_setup(&(saudio_desc) { saudio_setup(&(saudio_desc) {
.stream_cb = audio_stream_callback, .stream_cb = audio_stream_callback,
.logger.func = slog_func, .logger.func = slog_func,
.num_channels = 2,
}); });
load_assets(); load_assets();
@ -3369,7 +3307,7 @@ void init(void)
[ATTR_threedee_vs_uv_in].format = SG_VERTEXFORMAT_FLOAT2, [ATTR_threedee_vs_uv_in].format = SG_VERTEXFORMAT_FLOAT2,
}}, }},
.depth = { .depth = {
.pixel_format = sapp_depth_format(), .pixel_format = SG_PIXELFORMAT_DEPTH,
.compare = SG_COMPAREFUNC_LESS_EQUAL, .compare = SG_COMPAREFUNC_LESS_EQUAL,
.write_enabled = true, .write_enabled = true,
}, },
@ -3394,7 +3332,7 @@ void init(void)
{ {
.shader = shd, .shader = shd,
.depth = { .depth = {
.pixel_format = sapp_depth_format(), .pixel_format = SG_PIXELFORMAT_DEPTH,
.compare = SG_COMPAREFUNC_LESS_EQUAL, .compare = SG_COMPAREFUNC_LESS_EQUAL,
.write_enabled = true .write_enabled = true
}, },
@ -3675,13 +3613,6 @@ bool overlapping(AABB a, AABB b)
return true; // both segments overlapping return true; // both segments overlapping
} }
bool overlapping_circle(Circle a, Circle b)
{
Vec2 disp = SubV2(b.center, a.center);
float dist = LenV2(disp);
return (dist < a.radius + b.radius);
}
bool has_point(AABB aabb, Vec2 point) bool has_point(AABB aabb, Vec2 point)
{ {
return return
@ -3932,7 +3863,7 @@ void colorquad(Quad q, Color col)
} }
Vec2 NozV2(Vec2 v) Vec2 NormV2_or_zero(Vec2 v)
{ {
if(v.x == 0.0f && v.y == 0.0f) if(v.x == 0.0f && v.y == 0.0f)
{ {
@ -3946,7 +3877,7 @@ Vec2 NozV2(Vec2 v)
Quad line_quad(Vec2 from, Vec2 to, float line_width) Quad line_quad(Vec2 from, Vec2 to, float line_width)
{ {
Vec2 normal = rotate_counter_clockwise(NozV2(SubV2(to, from))); Vec2 normal = rotate_counter_clockwise(NormV2_or_zero(SubV2(to, from)));
return (Quad){ return (Quad){
.points = { .points = {
@ -3995,7 +3926,7 @@ void dbgbigsquare(Vec2 at)
{ {
#ifdef DEVTOOLS #ifdef DEVTOOLS
if (!show_devtools) return; if (!show_devtools) return;
colorquad(quad_centered(at, V2(20.0, 20.0)), debug_color); colorquad(quad_centered(at, V2(20.0, 20.0)), BLUE);
#else #else
(void)at; (void)at;
#endif #endif
@ -4401,20 +4332,21 @@ Vec2 get_penetration_vector(AABB stable, AABB dynamic)
// returns new pos after moving and sliding against collidable things // returns new pos after moving and sliding against collidable things
Vec2 move_and_slide(MoveSlideParams p) Vec2 move_and_slide(MoveSlideParams p)
{ {
float collision_radius = entity_radius(p.from); Vec2 collision_aabb_size = entity_aabb_size(p.from);
Vec2 new_pos = AddV2(p.position, p.movement_this_frame); Vec2 new_pos = AddV2(p.position, p.movement_this_frame);
assert(collision_radius > 0.0f); assert(collision_aabb_size.x > 0.0f);
Circle at_new = {new_pos, collision_radius}; assert(collision_aabb_size.y > 0.0f);
AABB at_new = aabb_centered(new_pos, collision_aabb_size);
typedef struct typedef struct
{ {
Circle circle; AABB aabb;
Entity *e; // required Entity *e; // required
} CollisionObj; } CollisionObj;
BUFF(CollisionObj, 256) to_check = { 0 }; BUFF(CollisionObj, 256) to_check = { 0 };
// add world boxes // add world boxes
for(CollisionCylinder *cur = level_threedee.collision_list; cur; cur = cur->next) for(CollisionCube *cur = level_threedee.collision_list; cur; cur = cur->next)
{ {
BUFF_APPEND(&to_check, ((CollisionObj){cur->bounds, gs.world_entity})); BUFF_APPEND(&to_check, ((CollisionObj){cur->bounds, gs.world_entity}));
} }
@ -4426,7 +4358,7 @@ Vec2 move_and_slide(MoveSlideParams p)
{ {
if (it != p.from && !(it->is_npc && it->dead) && !it->is_world) if (it != p.from && !(it->is_npc && it->dead) && !it->is_world)
{ {
BUFF_APPEND(&to_check, ((CollisionObj){.circle.center = it->pos, .circle.radius = entity_radius(it), it})); BUFF_APPEND(&to_check, ((CollisionObj){aabb_centered(it->pos, entity_aabb_size(it)), it}));
} }
} }
} }
@ -4440,7 +4372,7 @@ Vec2 move_and_slide(MoveSlideParams p)
BUFF_ITER(CollisionObj, &to_check) BUFF_ITER(CollisionObj, &to_check)
{ {
if (overlapping_circle(at_new, it->circle)) if (overlapping(at_new, it->aabb))
{ {
BUFF_APPEND(&actually_overlapping, *it); BUFF_APPEND(&actually_overlapping, *it);
} }
@ -4448,14 +4380,14 @@ Vec2 move_and_slide(MoveSlideParams p)
float smallest_distance = FLT_MAX; float smallest_distance = FLT_MAX;
int smallest_circle_index = 0; int smallest_aabb_index = 0;
int i = 0; int i = 0;
BUFF_ITER(CollisionObj, &actually_overlapping) BUFF_ITER(CollisionObj, &actually_overlapping)
{ {
float cur_dist = LenV2(SubV2(at_new.center, it->circle.center)); float cur_dist = LenV2(SubV2(aabb_center(at_new), aabb_center(it->aabb)));
if (cur_dist < smallest_distance) { if (cur_dist < smallest_distance) {
smallest_distance = cur_dist; smallest_distance = cur_dist;
smallest_circle_index = i; smallest_aabb_index = i;
} }
i++; i++;
} }
@ -4464,11 +4396,11 @@ Vec2 move_and_slide(MoveSlideParams p)
OverlapBuff overlapping_smallest_first = { 0 }; OverlapBuff overlapping_smallest_first = { 0 };
if (actually_overlapping.cur_index > 0) if (actually_overlapping.cur_index > 0)
{ {
BUFF_APPEND(&overlapping_smallest_first, actually_overlapping.data[smallest_circle_index]); BUFF_APPEND(&overlapping_smallest_first, actually_overlapping.data[smallest_aabb_index]);
} }
BUFF_ITER_I(CollisionObj, &actually_overlapping, i) BUFF_ITER_I(CollisionObj, &actually_overlapping, i)
{ {
if (i == smallest_circle_index) if (i == smallest_aabb_index)
{ {
} }
else else
@ -4482,7 +4414,7 @@ Vec2 move_and_slide(MoveSlideParams p)
{ {
dbgcol(GREEN) dbgcol(GREEN)
{ {
dbgplanerect(aabb_centered(it->circle.center, (Vec2){it->circle.radius, it->circle.radius})); dbgplanerect(it->aabb);
} }
} }
@ -4491,20 +4423,21 @@ Vec2 move_and_slide(MoveSlideParams p)
BUFF_ITER(CollisionObj, &actually_overlapping) BUFF_ITER(CollisionObj, &actually_overlapping)
dbgcol(WHITE) dbgcol(WHITE)
dbgplanerect(aabb_centered(it->circle.center, (Vec2){it->circle.radius, it->circle.radius})); dbgplanerect(it->aabb);
BUFF_ITER(CollisionObj, &overlapping_smallest_first) BUFF_ITER(CollisionObj, &overlapping_smallest_first)
dbgcol(WHITE) dbgcol(WHITE)
dbgplanesquare(it->circle.center); dbgplanesquare(aabb_center(it->aabb));
CollisionInfo info = { 0 }; CollisionInfo info = { 0 };
for (int col_iter_i = 0; col_iter_i < 1; col_iter_i++) for (int col_iter_i = 0; col_iter_i < 1; col_iter_i++)
BUFF_ITER(CollisionObj, &overlapping_smallest_first) BUFF_ITER(CollisionObj, &overlapping_smallest_first)
{ {
Circle to_depenetrate_from = it->circle; AABB to_depenetrate_from = it->aabb;
Vec2 resolution_vector = NozV2(SubV2(at_new.center, to_depenetrate_from.center)); Vec2 resolution_vector = get_penetration_vector(to_depenetrate_from, at_new);
at_new.center = AddV2(to_depenetrate_from.center, MulV2F(resolution_vector, to_depenetrate_from.radius + at_new.radius)); at_new.upper_left = AddV2(at_new.upper_left , resolution_vector);
at_new.lower_right = AddV2(at_new.lower_right, resolution_vector);
bool happened_with_this_one = true; bool happened_with_this_one = true;
if(happened_with_this_one) if(happened_with_this_one)
@ -4537,7 +4470,7 @@ Vec2 move_and_slide(MoveSlideParams p)
if (p.col_info_out) *p.col_info_out = info; if (p.col_info_out) *p.col_info_out = info;
Vec2 result_pos = at_new.center; Vec2 result_pos = aabb_center(at_new);
return result_pos; return result_pos;
} }
@ -5942,7 +5875,7 @@ void frame(void)
if (it->is_npc || it->is_character) if (it->is_npc || it->is_character)
{ {
if(LenV2(it->last_moved) > 0.0f && !it->killed) if(LenV2(it->last_moved) > 0.0f && !it->killed)
it->rotation = lerp_angle(it->rotation, dt * (it->quick_turning_timer > 0 ? 12.0f : 8.0f), AngleOfV2(it->last_moved)); it->rotation = lerp_angle(it->rotation, dt * 8.0f, AngleOfV2(it->last_moved));
} }
if (it->is_npc) if (it->is_npc)
@ -6704,22 +6637,7 @@ ISANERROR("Don't know how to do this stuff on this platform.")
{ {
gs.player->last_moved = NormV2(movement); gs.player->last_moved = NormV2(movement);
Vec2 target_vel = MulV2F(movement, pixels_per_meter * speed); Vec2 target_vel = MulV2F(movement, pixels_per_meter * speed);
float player_speed = LenV2(gs.player->vel); gs.player->vel = LerpV2(gs.player->vel, dt * 15.0f, target_vel);
float target_speed = LenV2(target_vel);
bool quick_turn = (player_speed < target_speed / 2) || DotV2(gs.player->vel, target_vel) < -0.707f;
gs.player->quick_turning_timer -= dt;
if (quick_turn) {
gs.player->quick_turning_timer = 0.125f;
}
if (quick_turn) {
gs.player->vel = target_vel;
} else { // framerate-independent smoothly transition towards target (functions as friction when target is 0)
gs.player->vel = SubV2(gs.player->vel, target_vel);
gs.player->vel = MulV2F(gs.player->vel, powf(1e-8f, dt));
gs.player->vel = AddV2(gs.player->vel, target_vel);
}
// printf("%f%s\n", LenV2(gs.player->vel), gs.player->quick_turning_timer > 0 ? " QUICK TURN" : "");
gs.player->pos = move_and_slide((MoveSlideParams) { gs.player, gs.player->pos, MulV2F(gs.player->vel, dt) }); gs.player->pos = move_and_slide((MoveSlideParams) { gs.player, gs.player->pos, MulV2F(gs.player->vel, dt) });
bool should_append = false; bool should_append = false;
@ -6990,27 +6908,7 @@ ISANERROR("Don't know how to do this stuff on this platform.")
Vec2 pos = V2(0.0, screen_size().Y); Vec2 pos = V2(0.0, screen_size().Y);
int num_entities = 0; int num_entities = 0;
ENTITIES_ITER(gs.entities) num_entities++; ENTITIES_ITER(gs.entities) num_entities++;
MD_String8 stats = MD_String8 stats = tprint("Frametime: %.1f ms\nProcessing: %.1f ms\nGameplay processing: %.1f ms\nEntities: %d\nDraw calls: %d\nDrawn Vertices: %d\nProfiling: %s\nNumber gameplay processing loops: %d\nFlyecam: %s\nPlayer position: %f %f\n", dt*1000.0, last_frame_processing_time*1000.0, last_frame_gameplay_processing_time*1000.0, num_entities, num_draw_calls, num_vertices, profiling ? "yes" : "no", num_timestep_loops, flycam ? "yes" : "no", v2varg(gs.player->pos));
tprint("Frametime: %.1f ms\n"
"Processing: %.1f ms\n"
"Gameplay processing: %.1f ms\n"
"Entities: %d\n"
"Draw calls: %d\n"
"Drawn Vertices: %d\n"
"Profiling: %s\n"
"Number gameplay processing loops: %d\n"
"Flycam: %s\n"
"Player position: %f %f\n",
dt*1000.0,
last_frame_processing_time*1000.0,
last_frame_gameplay_processing_time*1000.0,
num_entities,
num_draw_calls,
num_vertices,
profiling ? "yes" : "no",
num_timestep_loops,
flycam ? "yes" : "no",
v2varg(gs.player->pos));
AABB bounds = draw_text((TextParams) { true, stats, pos, BLACK, 1.0f }); AABB bounds = draw_text((TextParams) { true, stats, pos, BLACK, 1.0f });
pos.Y -= bounds.upper_left.Y - screen_size().Y; pos.Y -= bounds.upper_left.Y - screen_size().Y;
bounds = draw_text((TextParams) { true, stats, pos, BLACK, 1.0f }); bounds = draw_text((TextParams) { true, stats, pos, BLACK, 1.0f });

@ -1,32 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.6.33723.286
MinimumVisualStudioVersion = 10.0.40219.1
Project("{911E67C6-3D85-4FCE-B560-20A9C3E3FF48}") = "main", "main.exe", "{AA54BC1E-3360-4F83-9947-C1A78675D72C}"
ProjectSection(DebuggerProjectSystem) = preProject
PortSupplier = 00000000-0000-0000-0000-000000000000
Executable = .\main.exe
StartingDirectory = .\
Environment = Default
LaunchingEngine = 00000000-0000-0000-0000-000000000000
UseLegacyDebugEngines = No
LaunchSQLEngine = No
AttachLaunchAction = No
IORedirection = Auto
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AA54BC1E-3360-4F83-9947-C1A78675D72C}.Release|x64.ActiveCfg = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8FA0C944-81FC-4BE6-A866-162F58D74D4F}
EndGlobalSection
EndGlobal

@ -219,7 +219,6 @@ typedef struct Entity
// fields for all gs.entities // fields for all gs.entities
Vec2 pos; Vec2 pos;
Vec2 last_moved; Vec2 last_moved;
float quick_turning_timer;
float rotation; float rotation;
Vec2 vel; // only used sometimes, like in old man and bullet Vec2 vel; // only used sometimes, like in old man and bullet
float damage; // at 1.0, dead! zero initialized float damage; // at 1.0, dead! zero initialized

@ -3,24 +3,13 @@ module github.com/creikey/rpgpt/server
go 1.19 go 1.19
require ( require (
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/glebarez/go-sqlite v1.21.2 // indirect
github.com/glebarez/sqlite v1.9.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect github.com/jinzhu/now v1.1.5 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-sqlite3 v1.14.16 // indirect github.com/mattn/go-sqlite3 v1.14.16 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/sashabaranov/go-gpt3 v1.2.1 // indirect github.com/sashabaranov/go-gpt3 v1.2.1 // indirect
github.com/sashabaranov/go-openai v1.5.8 // indirect github.com/sashabaranov/go-openai v1.5.8 // indirect
github.com/stripe/stripe-go/v72 v72.122.0 // indirect github.com/stripe/stripe-go/v72 v72.122.0 // indirect
github.com/stripe/stripe-go/v74 v74.13.0 // indirect github.com/stripe/stripe-go/v74 v74.13.0 // indirect
golang.org/x/sys v0.7.0 // indirect
gorm.io/driver/sqlite v1.4.4 // indirect gorm.io/driver/sqlite v1.4.4 // indirect
gorm.io/gorm v1.25.2 // indirect gorm.io/gorm v1.24.6 // indirect
modernc.org/libc v1.22.5 // indirect
modernc.org/mathutil v1.5.0 // indirect
modernc.org/memory v1.5.0 // indirect
modernc.org/sqlite v1.23.1 // indirect
) )

@ -1,27 +1,14 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/glebarez/go-sqlite v1.21.2 h1:3a6LFC4sKahUunAmynQKLZceZCOzUthkRkEAl9gAXWo=
github.com/glebarez/go-sqlite v1.21.2/go.mod h1:sfxdZyhQjTM2Wry3gVYWaW072Ri1WMdWJi0k6+3382k=
github.com/glebarez/sqlite v1.9.0 h1:Aj6bPA12ZEx5GbSF6XADmCkYXlljPNUY+Zf1EQxynXs=
github.com/glebarez/sqlite v1.9.0/go.mod h1:YBYCoyupOao60lzp1MVBLEjZfgkq0tdB1voAQ09K9zw=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI= github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI=
github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/sashabaranov/go-gpt3 v1.2.1 h1:kfU+vQ1ThI7p+xfwwJC8olEEEWjK3smgKZ3FcYbaLRQ= github.com/sashabaranov/go-gpt3 v1.2.1 h1:kfU+vQ1ThI7p+xfwwJC8olEEEWjK3smgKZ3FcYbaLRQ=
github.com/sashabaranov/go-gpt3 v1.2.1/go.mod h1:BIZdbwdzxZbCrcKGMGH6u2eyGe1xFuX9Anmh3tCP8lQ= github.com/sashabaranov/go-gpt3 v1.2.1/go.mod h1:BIZdbwdzxZbCrcKGMGH6u2eyGe1xFuX9Anmh3tCP8lQ=
github.com/sashabaranov/go-openai v1.5.8 h1:EfNEmc+Ue+CuRy7iSpNdxfHyiOv2vQsQ2Y0kZRA/z5w= github.com/sashabaranov/go-openai v1.5.8 h1:EfNEmc+Ue+CuRy7iSpNdxfHyiOv2vQsQ2Y0kZRA/z5w=
@ -40,9 +27,6 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
@ -55,13 +39,3 @@ gorm.io/driver/sqlite v1.4.4/go.mod h1:0Aq3iPO+v9ZKbcdiz8gLWRw5VOPcBOPUQJFLq5e2e
gorm.io/gorm v1.24.0/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA= gorm.io/gorm v1.24.0/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
gorm.io/gorm v1.24.6 h1:wy98aq9oFEetsc4CAbKD2SoBCdMzsbSIvSUUFJuHi5s= gorm.io/gorm v1.24.6 h1:wy98aq9oFEetsc4CAbKD2SoBCdMzsbSIvSUUFJuHi5s=
gorm.io/gorm v1.24.6/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= gorm.io/gorm v1.24.6/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
gorm.io/gorm v1.25.2 h1:gs1o6Vsa+oVKG/a9ElL3XgyGfghFfkKA2SInQaCyMho=
gorm.io/gorm v1.25.2/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
modernc.org/libc v1.22.5 h1:91BNch/e5B0uPbJFgqbxXuOnxBQjlS//icfQEGmvyjE=
modernc.org/libc v1.22.5/go.mod h1:jj+Z7dTNX8fBScMVNRAYZ/jF91K8fdT2hYMThc3YjBY=
modernc.org/mathutil v1.5.0 h1:rV0Ko/6SfM+8G+yKiyI830l3Wuz1zRutdslNoQ0kfiQ=
modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
modernc.org/memory v1.5.0 h1:N+/8c5rE6EqugZwHii4IFsaJ7MUhoWX07J5tC/iI5Ds=
modernc.org/memory v1.5.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU=
modernc.org/sqlite v1.23.1 h1:nrSBg4aRQQwq59JpvGEQ15tNxoO5pX/kUjcRNwSAGQM=
modernc.org/sqlite v1.23.1/go.mod h1:OrDj17Mggn6MhE+iPbBNf7RGKODDE9NFT0f3EwDzJqk=

@ -19,7 +19,7 @@ import (
"github.com/stripe/stripe-go/v74/checkout/session" "github.com/stripe/stripe-go/v74/checkout/session"
"gorm.io/gorm" "gorm.io/gorm"
"github.com/glebarez/sqlite" "gorm.io/driver/sqlite"
"github.com/creikey/rpgpt/server/codes" "github.com/creikey/rpgpt/server/codes"
) )

@ -11930,11 +11930,7 @@ SOKOL_API_IMPL int sapp_color_format(void) {
} }
SOKOL_API_IMPL int sapp_depth_format(void) { SOKOL_API_IMPL int sapp_depth_format(void) {
#ifdef SOKOL_GLES2
return _SAPP_PIXELFORMAT_DEPTH;
#else
return _SAPP_PIXELFORMAT_DEPTH_STENCIL; return _SAPP_PIXELFORMAT_DEPTH_STENCIL;
#endif
} }
SOKOL_API_IMPL int sapp_sample_count(void) { SOKOL_API_IMPL int sapp_sample_count(void) {

@ -4,43 +4,29 @@
#include <stdbool.h> #include <stdbool.h>
#ifdef WEB #ifdef WEB
//#include <assert.h>
#include <signal.h> #include <signal.h>
#define game_debugbreak() raise(SIGTRAP) #endif
#define game_assert_4127_push
#define game_assert_4127_pop
static void assert_impl(bool cond, const char *expression)
{
if(!cond)
{
fprintf(stderr, "Assertion failed: %s\n", expression);
#ifdef WEB
raise(SIGTRAP);
//assert(false);
#elif defined(DESKTOP) #elif defined(DESKTOP)
#define game_debugbreak() __debugbreak() __debugbreak();
#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
#define game_assert(cond) game_assert_4127_push do { (void)0; } while (0) game_assert_4127_pop
#else
#define game_assert(cond) game_assert_4127_push do { \
if (!(cond)) { \
assert_impl(__func__, __FILE__, __LINE__, #cond); \
game_debugbreak(); \
} \
} while (0) game_assert_4127_pop
#endif
#ifdef assert #ifdef assert
#undef assert #undef assert
#endif #endif
#define assert game_assert
#define Log(...) { printf("%s Log %d | ", __FILE__, __LINE__); printf(__VA_ARGS__); } #define assert(cond) assert_impl(cond, #cond)
#define Log(...) { printf("%s Log %d | ", __FILE__, __LINE__); printf(__VA_ARGS__); }
Loading…
Cancel
Save