From ef3844bf2128fa82f20c5995d1fca66fadba2ce3 Mon Sep 17 00:00:00 2001 From: scratko Date: Wed, 17 Apr 2024 17:00:48 +0300 Subject: Added colors Changed the number of pacman's lives. Fixed clear_or_revert_symbol(). Target hit display. Changed ghost initialization. Clearing ghost positions is moved to the function. Added flag in struct ghost_type (reached_pacman). Changed catching stage. Now eating an energizer resets the counter. --- color_palette.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 color_palette.c (limited to 'color_palette.c') diff --git a/color_palette.c b/color_palette.c new file mode 100644 index 0000000..e839e8b --- /dev/null +++ b/color_palette.c @@ -0,0 +1,69 @@ +#include "color_palette.h" +#include + +void set_pairs() +{ + init_pair(2, COLOR_BLUE, COLOR_BLUE); + init_pair(3, COLOR_YELLOW, COLOR_BLACK); + init_pair(4, COLOR_MAGENTA, COLOR_MAGENTA); + init_pair(5, COLOR_YELLOW, COLOR_BLACK); + init_pair(6, COLOR_RED, COLOR_BLACK); + init_pair(7, COLOR_BLUE, COLOR_BLACK); + init_pair(8, COLOR_MAGENTA, COLOR_BLACK); +} + +void paint_field_element(int element) +{ + int color; + switch(element) { + case block: + color = COLOR_PAIR(2); + break; + case coin: + color = COLOR_PAIR(3) | A_BOLD; + break; + case door: + color = COLOR_PAIR(4); + break; + } + attrset(color); +} + +void paint_stats() +{ + attrset(COLOR_PAIR(5)); +} + +void paint_ghost(enum ghost_color color, int blink) +{ + int attr; + switch(color) { + case red: + attr = COLOR_PAIR(6); + break; + case pink: + attr = COLOR_PAIR(8); + break; + case blue: + attr = COLOR_PAIR(7); + break; + case orange: + attr = COLOR_PAIR(3); + } + attrset(attr); +} + +void paint_pac() +{ + attrset(COLOR_PAIR(3) | A_BOLD); +} + +void paint_hit() +{ + attrset(COLOR_PAIR(6)); +} + +void reset_attr() +{ + attrset(A_NORMAL); +} -- cgit v1.2.3