@@ -44,19 +44,24 @@ typedef struct {
4444} Game ;
4545
4646// Precomputed color table for rendering optimization
47+ const Color PUFF_BACKGROUND = (Color ){6 , 24 , 24 , 255 };
48+ const Color PUFF_WHITE = (Color ){241 , 241 , 241 , 241 };
49+ const Color PUFF_RED = (Color ){187 , 0 , 0 , 255 };
50+ const Color PUFF_CYAN = (Color ){0 , 187 , 187 , 255 };
51+
4752static Color tile_colors [12 ] = {
48- {205 , 193 , 180 , 255 }, // Empty/background
49- {238 , 228 , 218 , 255 }, // 2
50- {237 , 224 , 200 , 255 }, // 4
51- {242 , 177 , 121 , 255 }, // 8
52- {245 , 149 , 99 , 255 }, // 16
53- {246 , 124 , 95 , 255 }, // 32
54- {246 , 94 , 59 , 255 }, // 64
55- {237 , 207 , 114 , 255 }, // 128
56- {237 , 204 , 97 , 255 }, // 256
57- {237 , 200 , 80 , 255 }, // 512
58- {237 , 197 , 63 , 255 }, // 1024
59- {237 , 194 , 46 , 255 } // 2048+
53+ {6 , 24 , 24 , 255 }, // Empty/background
54+ {187 , 187 , 187 , 255 }, // 2
55+ {170 , 187 , 187 , 255 }, // 4
56+ {150 , 187 , 187 , 255 }, // 8
57+ {130 , 187 , 187 , 255 }, // 16
58+ {110 , 187 , 187 , 255 }, // 32
59+ {90 , 187 , 187 , 255 }, // 64
60+ {70 , 187 , 187 , 255 }, // 128
61+ {50 , 187 , 187 , 255 }, // 256
62+ {30 , 187 , 187 , 255 }, // 512
63+ {10 , 187 , 187 , 255 }, // 1024
64+ {0 , 187 , 187 , 255 } // 2048+
6065};
6166
6267// --- Logging ---
@@ -326,7 +331,7 @@ void c_render(Game* game) {
326331
327332 if (!window_initialized ) {
328333 InitWindow (px * SIZE , px * SIZE + 50 , "2048" );
329- SetTargetFPS (10 ); // Increased for smoother rendering
334+ SetTargetFPS (30 ); // Increased for smoother rendering
330335 window_initialized = true;
331336 }
332337
@@ -336,7 +341,7 @@ void c_render(Game* game) {
336341 }
337342
338343 BeginDrawing ();
339- ClearBackground (RAYWHITE );
344+ ClearBackground (PUFF_BACKGROUND );
340345
341346 // Draw grid
342347 for (int i = 0 ; i < SIZE ; i ++ ) {
@@ -354,14 +359,18 @@ void c_render(Game* game) {
354359 int display_val = 1 << val ; // Power of 2
355360 // Pre-format text to avoid repeated formatting
356361 snprintf (score_text , sizeof (score_text ), "%d" , display_val );
357- DrawText (score_text , j * px + 30 , i * px + 40 , 32 , BLACK );
362+ if (display_val < 1000 ) {
363+ DrawText (score_text , j * px + 30 , i * px + 40 , 32 , PUFF_WHITE );
364+ } else {
365+ DrawText (score_text , j * px + 20 , i * px + 40 , 32 , PUFF_WHITE );
366+ }
358367 }
359368 }
360369 }
361370
362371 // Draw score (format once per frame)
363372 snprintf (score_text , sizeof (score_text ), "Score: %d" , 1 << game -> score );
364- DrawText (score_text , 10 , px * SIZE + 10 , 24 , DARKGRAY );
373+ DrawText (score_text , 10 , px * SIZE + 10 , 24 , PUFF_WHITE );
365374
366375 EndDrawing ();
367376}
@@ -370,4 +379,4 @@ void c_close(Game* game) {
370379 if (IsWindowReady ()) {
371380 CloseWindow ();
372381 }
373- }
382+ }
0 commit comments