diff --git a/game/build_client.sh b/game/build_client.sh index 16f9f01..5b8fecc 100755 --- a/game/build_client.sh +++ b/game/build_client.sh @@ -24,5 +24,5 @@ echo "Linking..." gcc main.o suic_math.o suic_terrain.o suic_lighting.o suic_net.o suic_ui.o suic_game_client.o \ $RAYLIB_LIBS -lm -o game_client -echo "✓ Successfully built: game_client" -echo " Run with: ./game_client" +echo "Successfully built: game_client" +echo "Run with: ./game_client" diff --git a/game/client b/game/client deleted file mode 100755 index 989692a..0000000 Binary files a/game/client and /dev/null differ diff --git a/game/client.c b/game/client.c index 9ad3971..65835e2 100644 --- a/game/client.c +++ b/game/client.c @@ -1,15 +1,60 @@ -#include "suic_app.h" -#include "runtime.h" +#include "libsuicmez/libsuicmez.h" +#include +#include +#include +#include + +void* gc_alloc(const TypeInfo* type, size_t size); +void gc_init(void); +void gc_shutdown(void); + +// Helper for allocating arrays +static void* suic_alloc_array(const TypeInfo* type, size_t elem_size, size_t len, void* init_data) { + void* ptr = gc_alloc(type, elem_size * len); + if (init_data) memcpy(ptr, init_data, elem_size * len); + return ptr; +} + +// Helper for allocating structs +static void* suic_alloc_struct(const TypeInfo* type, size_t size, void* init_data) { + void* ptr = gc_alloc(type, size); + if (init_data) memcpy(ptr, init_data, size); + return ptr; +} + + +; +; + + + + +int suic_main(void); + int suic_main(void) { - suic_app_init(1280, 720, "Voxel Shooter - Client"); - - while (!suic_app_should_close()) { - suic_app_frame_begin(); - suic_draw_hello(); // gameplay / UI call - suic_app_frame_end(); + suic_init_window(1280, 720, suic_alloc_array(NULL, sizeof(char), 21, "Voxel Shooter Client")); + suic_set_target_fps(120); + suic_disable_cursor(); + while ((suic_window_should_close() == false)) { + float dt = suic_get_frame_time(); + suic_begin_drawing(); + suic_clear_background(135, 206, 235, 255); + DrawFPS(10, 10); + suic_end_drawing(); } - - suic_app_shutdown(); + suic_close_window(); return 0; -} \ No newline at end of file +} + +int main(int argc, char* argv[]) { + // Initialize GC + gc_init(); + // init globals + // init event loop + int result = suic_main(); + // Shutdown GC + gc_shutdown(); + return result; +} + diff --git a/game/client.o b/game/client.o deleted file mode 100644 index c6e1085..0000000 Binary files a/game/client.o and /dev/null differ diff --git a/game/client.sui b/game/client.sui index e69de29..7f90f69 100644 --- a/game/client.sui +++ b/game/client.sui @@ -0,0 +1,22 @@ +fn main() -> int do + init_window(1280, 720, "Voxel Shooter Client") + defer close_window() + set_target_fps(120) + disable_cursor() + + # Main loop + while window_should_close() == false do + let dt = get_frame_time() + + # Rendering + begin_drawing() + clear_background(135, 206, 235, 255) + + # Draw FPS + draw_fps(10, 10) + + end_drawing() + end + + 0 +end \ No newline at end of file diff --git a/soup/server.c b/soup/server.c index b341dca..b9e24ad 100644 --- a/soup/server.c +++ b/soup/server.c @@ -4,9 +4,6 @@ #include #include -void* gc_alloc(const TypeInfo* type, size_t size); -void gc_init(void); -void gc_shutdown(void); // Helper for allocating arrays static void* suic_alloc_array(const TypeInfo* type, size_t elem_size, size_t len, void* init_data) { @@ -22,12 +19,12 @@ static void* suic_alloc_struct(const TypeInfo* type, size_t size, void* init_dat return ptr; } - - +void* gc_alloc(const TypeInfo* type, size_t size); +void gc_init(void); +void gc_shutdown(void); int suic_main(void); - int suic_main(void) { char* SERVER_HOST = suic_alloc_array(NULL, sizeof(char), 10, "127.0.0.1"); int SERVER_PORT = 8888; diff --git a/tests/arrays.c b/tests/arrays.c index 7e33cc5..644f914 100644 --- a/tests/arrays.c +++ b/tests/arrays.c @@ -51,7 +51,7 @@ int suic_main(void); int suic_main(void) { int* arr = suic_alloc_array(NULL, sizeof(int), 4, (int[]){1, 2, 3, 4}); - int x = arr[0]; + int x = arr[2]; return x; } diff --git a/tests/arrays.o b/tests/arrays.o index ec5d2dd..6366f74 100755 Binary files a/tests/arrays.o and b/tests/arrays.o differ diff --git a/tests/arrays.sui b/tests/arrays.sui index 85d4c46..566c859 100644 --- a/tests/arrays.sui +++ b/tests/arrays.sui @@ -2,6 +2,6 @@ fn main() -> int do let arr = [1, 2, 3, 4]; # let empty = []; - let x = arr[0]; + let x = arr[1]; x end