Game code is now loaded dynamically.

This commit is contained in:
2026-03-18 00:02:50 -07:00
parent 5b4f3e2218
commit aef23bd6cd
5 changed files with 68 additions and 18 deletions
+6 -5
View File
@@ -1,4 +1,5 @@
#include "handmade.h"
#include "sdl_handmade.h"
#include <math.h>
@@ -37,7 +38,7 @@ static void RenderWeirdGradient(game_offscreen_buffer *Buffer, S32 XOffset, S32
}
}
static void GameUpdateAndRender(game_memory *Memory, game_input *Input, game_offscreen_buffer *Buffer, game_sound_output_buffer *SoundBuffer)
void UpdateAndRender(game_memory *Memory, game_input *Input, game_offscreen_buffer *Buffer, game_sound_output_buffer *SoundBuffer)
{
Assert((&Input->Controllers[0].Terminator - &Input->Controllers[0].Buttons[0]) == ARRAY_SIZE(Input->Controllers[0].Buttons));
Assert(sizeof(game_state) <= Memory->PermanentStorageSize);
@@ -45,10 +46,10 @@ static void GameUpdateAndRender(game_memory *Memory, game_input *Input, game_off
game_state *GameState = (game_state *)Memory->PermanentStorage;
if(!Memory->IsInitialized) {
char FileName[] = "/Users/igor/Developer/handmade_hero_course/handmade/code/sdl_handmade.cpp";
debug_read_file_result BitmapMemory = DEBUGPlatformReadEntireFile(FileName);
debug_read_file_result BitmapMemory = Memory->DEBUGPlatformReadEntireFile(FileName);
if(BitmapMemory.Contents) {
DEBUGPlatformWriteEntireFile("test.out", BitmapMemory.ContentsSize, BitmapMemory.Contents);
DEBUGPlatformFreeFileMemory(BitmapMemory.Contents);
Memory->DEBUGPlatformWriteEntireFile("test.out", BitmapMemory.ContentsSize, BitmapMemory.Contents);
Memory->DEBUGPlatformFreeFileMemory(BitmapMemory.Contents);
}
GameState->ToneHz = 256;
@@ -71,7 +72,7 @@ static void GameUpdateAndRender(game_memory *Memory, game_input *Input, game_off
GameState->GreenOffset -= 1;
}
if(Controller->MoveDown.EndedDown) {
GameState->GreenOffset += 1;
GameState->GreenOffset += 2;
}
if(Controller->MoveLeft.EndedDown) {
GameState->BlueOffset -= 1;