@@ -41,8 +41,7 @@ void Adder::InitializeGame() {
41
41
AdderDelayInterval, LV_TASK_PRIO_MID, this );
42
42
43
43
appReady = false ;
44
- vTaskDelay (5 );
45
- UpdateScore (0 );
44
+ vTaskDelay (20 );
46
45
}
47
46
48
47
void Adder::Cleanup () {
@@ -87,7 +86,7 @@ void Adder::ResetGame() {
87
86
GameOver ();
88
87
appReady = false ;
89
88
highScore = std::max (highScore, static_cast <unsigned int >(adderBody.size () - 2 ));
90
-
89
+ data. HighScore =highScore;
91
90
SaveGame ();
92
91
93
92
CreateLevel ();
@@ -213,11 +212,16 @@ void Adder::Refresh() {
213
212
if (!appReady) {
214
213
FullRedraw ();
215
214
CreateFood ();
215
+ vTaskDelay (1 ); // Required to let the OS draw the tile completely
216
+ UpdateScore (0 );
217
+ vTaskDelay (1 ); // Required to let the OS draw the tile completely
216
218
appReady = true ;
217
219
} else {
218
220
UpdatePosition ();
219
221
UpdateSingleTile (adderBody.front () % fieldWidth, adderBody.front () / fieldWidth, LV_COLOR_YELLOW);
222
+ vTaskDelay (1 ); // Required to let the OS draw the tile completely
220
223
UpdateSingleTile (adderBody.back () % fieldWidth, adderBody.back () / fieldWidth, LV_COLOR_BLACK);
224
+ vTaskDelay (1 ); // Required to let the OS draw the tile completely
221
225
}
222
226
}
223
227
@@ -240,6 +244,7 @@ void Adder::FullRedraw() {
240
244
break ;
241
245
}
242
246
UpdateSingleTile (x, y, color);
247
+ vTaskDelay (1 ); // Required to let the OS draw the tile completely
243
248
}
244
249
}
245
250
}
@@ -267,7 +272,7 @@ void Adder::GameOver() {
267
272
for (unsigned int i = 0 ; i < 4 ; i++) {
268
273
for (unsigned int j = 0 ; j < 64 ; j++) {
269
274
// Map font bits into the display buffer
270
- digitBuffer[63 - j] = (DigitFont[digits[i]][j / 8 ] & ( 1 << ( j % 8 ))) ? LV_COLOR_WHITE : LV_COLOR_BLACK;
275
+ digitBuffer[63 - j] = (DigitFont[digits[i]][j / 8 ] & 1 << j % 8 ) ? LV_COLOR_WHITE : LV_COLOR_BLACK; // Bitmagic to rotate the Digits to look like Letters
271
276
}
272
277
273
278
lv_area_t area;
@@ -278,6 +283,7 @@ void Adder::GameOver() {
278
283
279
284
lvgl.SetFullRefresh (Components::LittleVgl::FullRefreshDirections::None);
280
285
lvgl.FlushDisplay (&area, digitBuffer);
286
+ vTaskDelay (1 ); // Required to let the OS draw the tile completely
281
287
}
282
288
}
283
289
}
@@ -301,7 +307,7 @@ void Adder::UpdateScore(unsigned int score) {
301
307
302
308
lvgl.SetFullRefresh (Components::LittleVgl::FullRefreshDirections::None);
303
309
lvgl.FlushDisplay (&area, digitBuffer);
304
- vTaskDelay (1 ); // Small delay to allow display refresh
310
+ vTaskDelay (20 ); // Small delay to allow display refresh
305
311
}
306
312
307
313
// Update the high score if necessary
@@ -328,7 +334,7 @@ void Adder::UpdateScore(unsigned int score) {
328
334
329
335
lvgl.SetFullRefresh (Components::LittleVgl::FullRefreshDirections::None);
330
336
lvgl.FlushDisplay (&area, digitBuffer);
331
- vTaskDelay (1 ); // Small delay to allow display refresh
337
+ vTaskDelay (20 ); // Small delay to allow display refresh
332
338
}
333
339
334
340
// Save the high score if it has changed
0 commit comments