feat: add lives from graphics

This commit is contained in:
valvin 2024-02-19 22:06:19 +01:00
parent 8474863782
commit 1c40ff7081
3 changed files with 21 additions and 4 deletions

View File

@ -11,3 +11,7 @@ PROGMEM const unsigned char fish_reverse[] {
0x00, 0x00, 0x00, 0x04, 0x00, 0x06, 0xc0, 0x07, 0xe0, 0x07, 0xf8, 0x67, 0x00, 0x00, 0x00, 0x04, 0x00, 0x06, 0xc0, 0x07, 0xe0, 0x07, 0xf8, 0x67,
0xec, 0x7f, 0xfe, 0x3f, 0xfc, 0x3f, 0xf8, 0x77, 0xf0, 0x67, 0xe0, 0x07, 0xec, 0x7f, 0xfe, 0x3f, 0xfc, 0x3f, 0xf8, 0x77, 0xf0, 0x67, 0xe0, 0x07,
0x00, 0x0e, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00 }; 0x00, 0x0e, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00 };
PROGMEM const unsigned char heart[]{
0x1b,0x1b,0x1f,0x1f,0x0e
};

View File

@ -107,7 +107,7 @@ void display_welcome_page() {
void display_game() { void display_game() {
u8g2.setFont(u8g2_font_4x6_tf); u8g2.setFont(u8g2_font_4x6_tf);
u8g2.drawStr(108, 50, "SCORE:"); u8g2.drawStr(108, 50, "SCORE:");
u8g2.drawStr(108, 30, "LIVES:"); //u8g2.drawStr(108, 30, "LIVES:");
u8g2.drawStr(108, 10, "MAX:"); u8g2.drawStr(108, 10, "MAX:");
//draw score //draw score
u8g2.setFont(u8g2_font_5x7_mf); u8g2.setFont(u8g2_font_5x7_mf);
@ -116,8 +116,17 @@ void display_game() {
u8g2.drawStr(110, 62, num_str); u8g2.drawStr(110, 62, num_str);
sprintf(num_str, "%03d", max_score); sprintf(num_str, "%03d", max_score);
u8g2.drawStr(110, 20, num_str); u8g2.drawStr(110, 20, num_str);
sprintf(num_str, "%03d", lives); short y = 0;
u8g2.drawStr(110, 40, num_str); short x = 0;
for(int i = 0; i < lives; i++){
if (i % 3 == 0){
y = y +1;
x = 0;
}
u8g2.drawXBMP(110 + 6 * x, 20 + 6 * y, 5, 5, heart);
x = x + 1;
}
//draw fishes //draw fishes
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
if(fishes[i][0] != NULL){ if(fishes[i][0] != NULL){

4
resources/heart.xbm Normal file
View File

@ -0,0 +1,4 @@
#define _width 5
#define _height 5
static char _bits[] = {
0x1b,0x1b,0x1f,0x1f,0x0e };