Skip to content

Commit

Permalink
add support for CapsLock letter
Browse files Browse the repository at this point in the history
  • Loading branch information
petrkucerak committed May 5, 2021
1 parent bda29b9 commit 39ef3f8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
10 changes: 6 additions & 4 deletions final_score.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
bool draw_final_score(int score, fb_data *frame_buff, unsigned char *lcd_mem_base, font_descriptor_t *font)
{
char c = ' ';
while (c != 's' && c != 't')
while (c != 's' && c != 't' && c != 'S' && c != 'T')
{
set_background(frame_buff, 0);
draw_text_center(frame_buff, "SKORE", frame_buff->width / 2, frame_buff->height / 10, 3, font, 0xffff);
char string_tmp[20];
snprintf(string_tmp, 20, "%d", score);
draw_text_center(frame_buff, string_tmp, frame_buff->width / 2, frame_buff->height / 2, 4, font, 0xffff);
draw_text_center(frame_buff, "ZNOVU [s] KONEC [t]", frame_buff->width / 2, frame_buff->height - frame_buff->height / 10, 2, font, 0xffff);
draw_text_center(frame_buff, "ZNOVU [S] KONEC [T]", frame_buff->width / 2, frame_buff->height - frame_buff->height / 10, 2, font, 0xffff);
// update display
lcd_from_fb(frame_buff, lcd_mem_base);
// scan input
Expand All @@ -36,6 +36,8 @@ bool draw_final_score(int score, fb_data *frame_buff, unsigned char *lcd_mem_bas
c = read_thread_data.last_read;
pthread_mutex_unlock(&mtx);
}
if(c == 's') return true;
else return false;
if (c == 's' || c == 'S')
return true;
else
return false;
}
36 changes: 18 additions & 18 deletions menu_utilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,30 @@ void run_init_game_menu(fb_data *frame_buff, unsigned char *lcd_mem_base,
lcd_from_fb(frame_buff, lcd_mem_base);
// listen symbol
char read = ' ';
while (read != 's' && read != 't')
while (read != 's' && read != 't' && read != 'S' && read != 'T')
{
// scan input
pthread_mutex_lock(&mtx);
pthread_cond_wait(&character_has_been_read, &mtx);
read = read_thread_data.last_read;
pthread_mutex_unlock(&mtx);
if (read == 'l')
if (read == 'l' || read == 'L')
{
game = sub_menu_lives(frame_buff, lcd_mem_base, font, game);
}
if (read == 'm')
if (read == 'm' || read == 'M')
{
game = sub_menu_map(frame_buff, lcd_mem_base, font, game);
}
if (read == 'g')
if (read == 'g' || read == 'G')
{
game = sub_menu_ghosts(frame_buff, lcd_mem_base, font, game);
}
// redraw menu
draw_menu(frame_buff, font, game);
lcd_from_fb(frame_buff, lcd_mem_base);
}
if (read != 't')
if (read != 't' || read != 'T')
{
// run game
int game_score = run_game(&game, &peripherals);
Expand All @@ -83,19 +83,19 @@ void draw_menu(fb_data *frame_buff, font_descriptor_t *font, game_init_data_t ga
set_background(frame_buff, 0);
draw_text_center(frame_buff, "HLAVNI MENU", frame_buff->width / 2, HEIGHT_M / 10, 3, font, 0xffff);
char string_tmp[40];
snprintf(string_tmp, 40, "pocet zivotu: %d [l]", game_data.pacman_lives);
snprintf(string_tmp, 40, "pocet zivotu: %d [L]", game_data.pacman_lives);
draw_text_center(frame_buff, string_tmp, frame_buff->width / 2, HEIGHT_M / 2 - HEIGHT_M / 7, 2, font, 0xffff);
snprintf(string_tmp, 40, "mapa: %s [m]", game_data.map->name);
snprintf(string_tmp, 40, "mapa: %s [M]", game_data.map->name);
draw_text_center(frame_buff, string_tmp, frame_buff->width / 2, HEIGHT_M / 2, 2, font, 0xffff);
snprintf(string_tmp, 40, "pocet duchu: %d [g]", game_data.ghost_nr);
snprintf(string_tmp, 40, "pocet duchu: %d [G]", game_data.ghost_nr);
draw_text_center(frame_buff, string_tmp, frame_buff->width / 2, HEIGHT_M / 2 + HEIGHT_M / 7, 2, font, 0xffff);
draw_text_center(frame_buff, "SPUSIT HRU: [s] KONEC HRY: [t]", frame_buff->width / 2, HEIGHT_M - HEIGHT_M / 10, 2, font, 0xffff);
draw_text_center(frame_buff, "SPUSIT HRU: [S] KONEC HRY: [T]", frame_buff->width / 2, HEIGHT_M - HEIGHT_M / 10, 2, font, 0xffff);
}

game_init_data_t sub_menu_lives(fb_data *frame_buff, unsigned char *lcd_mem_base, font_descriptor_t *font, game_init_data_t game_data)
{
char c = ' ';
while (c != 'c')
while (c != 'c' && c != 'C')
{
set_background(frame_buff, 0);
draw_text_center(frame_buff, "NASTAVENI ZIVOTU", frame_buff->width / 2, HEIGHT_M / 10, 3, font, 0xffff);
Expand All @@ -105,7 +105,7 @@ game_init_data_t sub_menu_lives(fb_data *frame_buff, unsigned char *lcd_mem_base
draw_text_center(frame_buff, string_tmp, frame_buff->width / 2, HEIGHT_M / 2, 3, font, 0xffff);
snprintf(string_tmp, 40, "zmackni cislo (max %c)", MAX_LIVES);
draw_text_center(frame_buff, string_tmp, frame_buff->width / 2, HEIGHT_M / 2 + HEIGHT_M / 7, 2, font, 0xffff);
draw_text_center(frame_buff, "POTVRDIT: [c]", frame_buff->width / 2, HEIGHT_M - HEIGHT_M / 10, 2, font, 0xffff);
draw_text_center(frame_buff, "POTVRDIT: [C]", frame_buff->width / 2, HEIGHT_M - HEIGHT_M / 10, 2, font, 0xffff);
// update display
lcd_from_fb(frame_buff, lcd_mem_base);
// scan input
Expand All @@ -132,16 +132,16 @@ game_init_data_t sub_menu_map(fb_data *frame_buff, unsigned char *lcd_mem_base,
++i;
}
char c = ' ';
while (c != 'c')
while (c != 'c' && c != 'C')
{
set_background(frame_buff, 0);
draw_text_center(frame_buff, "VOLBA MAPY", frame_buff->width / 2, HEIGHT_M / 10, 3, font, 0xffff);
draw_text_center(frame_buff, "aktualni mapa", frame_buff->width / 2, HEIGHT_M / 2 - HEIGHT_M / 7, 2, font, 0xffff);
char string_tmp[40];
snprintf(string_tmp, 40, "< %s >", game_data.map->name);
draw_text_center(frame_buff, string_tmp, frame_buff->width / 2, HEIGHT_M / 2, 3, font, 0xffff);
draw_text_center(frame_buff, "vybirej klavesami [a] [d]", frame_buff->width / 2, HEIGHT_M / 2 + HEIGHT_M / 7, 2, font, 0xffff);
draw_text_center(frame_buff, "POTVRDIT: [c]", frame_buff->width / 2, HEIGHT_M - HEIGHT_M / 10, 2, font, 0xffff);
draw_text_center(frame_buff, "vybirej klavesami [A] [D]", frame_buff->width / 2, HEIGHT_M / 2 + HEIGHT_M / 7, 2, font, 0xffff);
draw_text_center(frame_buff, "POTVRDIT: [C]", frame_buff->width / 2, HEIGHT_M - HEIGHT_M / 10, 2, font, 0xffff);
// update display
lcd_from_fb(frame_buff, lcd_mem_base);
// scan input
Expand All @@ -150,11 +150,11 @@ game_init_data_t sub_menu_map(fb_data *frame_buff, unsigned char *lcd_mem_base,
c = read_thread_data.last_read;
pthread_mutex_unlock(&mtx);
// listen orders
if (c == 'a')
if (c == 'a' || c == 'A')
{
i = (i - 1 + map_templates_len) % map_templates_len;
}
if (c == 'd')
if (c == 'd' || c == 'D')
{
i = (i + 1 + map_templates_len) % map_templates_len;
}
Expand All @@ -166,7 +166,7 @@ game_init_data_t sub_menu_map(fb_data *frame_buff, unsigned char *lcd_mem_base,
game_init_data_t sub_menu_ghosts(fb_data *frame_buff, unsigned char *lcd_mem_base, font_descriptor_t *font, game_init_data_t game_data)
{
char c = ' ';
while (c != 'c')
while (c != 'c' && c != 'C')
{
// set buffer
set_background(frame_buff, 0);
Expand All @@ -177,7 +177,7 @@ game_init_data_t sub_menu_ghosts(fb_data *frame_buff, unsigned char *lcd_mem_bas
draw_text_center(frame_buff, string_tmp, frame_buff->width / 2, HEIGHT_M / 2, 3, font, 0xffff);
snprintf(string_tmp, 40, "zmackni cislo (max %c)", MAX_GHOSTS);
draw_text_center(frame_buff, string_tmp, frame_buff->width / 2, HEIGHT_M / 2 + HEIGHT_M / 7, 2, font, 0xffff);
draw_text_center(frame_buff, "POTVRDIT: [c]", frame_buff->width / 2, HEIGHT_M - HEIGHT_M / 10, 2, font, 0xffff);
draw_text_center(frame_buff, "POTVRDIT: [C]", frame_buff->width / 2, HEIGHT_M - HEIGHT_M / 10, 2, font, 0xffff);
// update display
lcd_from_fb(frame_buff, lcd_mem_base);
// scan input
Expand Down

0 comments on commit 39ef3f8

Please sign in to comment.