aboutsummaryrefslogtreecommitdiff
path: root/source/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/main.c')
-rw-r--r--source/main.c50
1 files changed, 33 insertions, 17 deletions
diff --git a/source/main.c b/source/main.c
index d1cb359..1cf3c55 100644
--- a/source/main.c
+++ b/source/main.c
@@ -1,45 +1,59 @@
-#include <stdio.h>
-
-#include <stdint.h>
#include <time.h>
#include <unistd.h>
-
-#include <raylib.h>
#include <rlgl.h>
+#include "all.h"
+
+/* I really like this in usage. */
+
+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);
+}
+
int main (int count, char ** arguments)
{
+ (void)count;
+ game_t game[1] = {0};
+ game->horizontal = 1920;
+ game->vertical = 1080;
/* :config */
- int horizontal = 1920, vertical = 1080;
-
+ 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(horizontal, vertical, arguments[0]);
+ InitWindow(game->horizontal, game->vertical, arguments[0]);
SetWindowState(FLAG_WINDOW_HIDDEN);
InitAudioDevice();
SetWindowPosition(0, 0);
}
+ game->font = GetFontDefault();
+
/* :todo ping me I'll update this to a u/f seperated game loop */
{ /* loop to end all loops */
- uint64_t frame = 0;
+ uint64_t fc = 0;
/* :config */
float fps = 30;
- double wait = wait = 1.0 / fps, Δ = wait;
+ double wait = wait = 1.0 / fps, delta = wait;
struct timespec start, end;
clock_gettime(CLOCK_MONOTONIC, &start);
ClearWindowState(FLAG_WINDOW_HIDDEN);
while (1) {
- if (Δ > wait) {
+ if (delta > wait) {
clock_gettime(CLOCK_MONOTONIC, &start);
{ /* update */
- ++frame;
+ ++fc;
PollInputEvents();
+ if (IsWindowResized()) {
+ game->horizontal = GetScreenWidth(), game->vertical = GetScreenHeight();
+ frame_reset(game);
+ }
/* physical keys */
switch (GetKeyPressed()) {
- case KEY_Q: goto stop;
+ /* case KEY_Q: goto stop; */
case KEY_ESCAPE: goto stop;
}
/* routed keys */
@@ -48,15 +62,17 @@ int main (int count, char ** arguments)
{ /* draw */
BeginDrawing();
ClearBackground(BLACK);
- DrawText(TextFormat("Delta (Δ): %d", Δ), 10, 10, 20, WHITE);
+ draw_square_grid(game, 0, 50, NULL, (int[]) {1,2,3, 4,5,6, 7,8,9}, 9);
+ 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);
- Δ = (end.tv_sec - start.tv_sec) + (end.tv_nsec - start.tv_nsec) / 1e9;
- if (Δ < wait) {
- double should = -(Δ - wait);
+ 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); }
}
}