diff options
| author | Emil Williams | 2026-02-05 09:29:51 +0000 |
|---|---|---|
| committer | Emil Williams | 2026-02-05 09:29:51 +0000 |
| commit | 45570024a49b80359d848329f2c363d5bf9af44a (patch) | |
| tree | 31243e117a965569ecbc745eba88b25536b7fc99 /source/main.c | |
| parent | a5209153cf8df1cd58c2f70f9eabb0bf5dd071f8 (diff) | |
| download | EUROPAXI-8e8m.tar.xz EUROPAXI-8e8m.tar.zst | |
assets & core8e8m
Diffstat (limited to 'source/main.c')
| -rw-r--r-- | source/main.c | 116 |
1 files changed, 41 insertions, 75 deletions
diff --git a/source/main.c b/source/main.c index c775851..4bcaac8 100644 --- a/source/main.c +++ b/source/main.c @@ -1,89 +1,55 @@ #include <time.h> +#include "time.h" #include <unistd.h> +#include <stdlib.h> +#include <string.h> +#include <limits.h> #include <rlgl.h> #include "all.h" -/* I really like this in usage. */ +void Root(char * filename) { + char path[PATH_MAX], * terminator; + if (!realpath(filename, path)) { return; } + if ((terminator = strrchr(path, '/'))) { + *terminator = '\0'; + if(chdir(path)) { abort(); } + } +} + +int Update(game_t * game, struct timespec now) { + (void) now; + PollInputEvents(); + if (IsWindowResized()) { + game->horizontal = GetScreenWidth(), game->vertical = GetScreenHeight(); + GameFrameReset(game); + } + switch (GetKeyPressed()) { + case KEY_ESCAPE: return 1; + } + return 0; +} -static inline void frame_reset(game_t * game) { - game_frame(game, 0, game->horizontal/12, game->vertical/12); - game_frame(game, 1, game->horizontal/3, game->vertical - game->vertical/8); - game_frame(game, 2, game->horizontal - game->horizontal/4, game->vertical/12); +void Frame(game_t * game, double interpolation) { + (void)interpolation; + BeginDrawing(); + ClearBackground(BLACK); + DrawCenteredText(game, 0, 20, WHITE, "Snails are now preparing! %d", rand()); + rlDrawRenderBatchActive(); + SwapScreenBuffer(); } -int main (int count, char ** arguments) +int Main(int count, char ** arguments) { (void)count; game_t game[1] = {0}; - game->horizontal = 1920; - game->vertical = 1080; - /* :config */ - frame_reset(game); - { /* this idented (DENTED) style is autistic and dumb but I like it visually */ - SetConfigFlags(FLAG_WINDOW_RESIZABLE); - /* tell raylib to shut up */ - /* SetTraceLogLevel(LOG_NONE); */ - InitWindow(game->horizontal, game->vertical, arguments[0]); - SetWindowState(FLAG_WINDOW_HIDDEN); - InitAudioDevice(); - SetWindowPosition(0, 0); - } - game->font = LoadFont("fonts/Atkinson/mono/AtkinsonHyperlegibleMono-Bold.otf"); - if (!IsFontValid(game->font)) { game->font = GetFontDefault(); } - - /* :todo ping me I'll update this to a u/f seperated game loop */ - { /* loop to end all loops */ - uint64_t fc = 0; - /* :config */ - float fps = 30; - double wait = wait = 1.0 / fps, delta = wait; - struct timespec start, end; - - clock_gettime(CLOCK_MONOTONIC, &start); - ClearWindowState(FLAG_WINDOW_HIDDEN); - int test[200*200] = {0}; - for (int i = 0; i < 200*200; i++) { test[i] = i;} - while (1) { - if (delta > wait) { - clock_gettime(CLOCK_MONOTONIC, &start); - { /* update */ - ++fc; - PollInputEvents(); - if (IsWindowResized()) { - game->horizontal = GetScreenWidth(), game->vertical = GetScreenHeight(); - frame_reset(game); - } - /* physical keys */ - switch (GetKeyPressed()) { - /* case KEY_Q: goto stop; */ - case KEY_ESCAPE: goto stop; - } - /* routed keys */ - /* switch (GetCharPressed()) { case 'q': goto stop; } */ - } - { /* draw */ - BeginDrawing(); - ClearBackground(BLACK); - draw_square_grid(game, 0, MIN(game->vertical/20, game->horizontal/25), NULL, test, 200); - draw_centered_text(game, 1, 20, WHITE, "Snails are now preparing!"); - draw_centered_text(game, 2, 20, WHITE, "Gambling here"); - rlDrawRenderBatchActive(); - SwapScreenBuffer(); - } - } - clock_gettime(CLOCK_MONOTONIC, &end); - delta = (end.tv_sec - start.tv_sec) + (end.tv_nsec - start.tv_nsec) / 1e9; - if (delta < wait) { - double should = -(delta - wait); - if (should > 0) { usleep(1e6 * should); } - } - } - } -stop: - SetWindowState(FLAG_WINDOW_HIDDEN); - UnloadFont(game->font); - CloseAudioDevice(); - CloseWindow(); + char * program_name = arguments[0]; + srand(time(NULL)); + Root(program_name); + GameInitialize(game, program_name); + GameLoop(game); + GameDeinitialize(game); return 0; } + +int main (int count, char ** arguments) __attribute__((alias("Main"))); |
