back to scratko.xyz
aboutsummaryrefslogtreecommitdiff
path: root/color_palette.c
diff options
context:
space:
mode:
authorscratko <m@scratko.xyz>2024-04-17 17:00:48 +0300
committerscratko <m@scratko.xyz>2024-04-17 18:33:03 +0300
commitef3844bf2128fa82f20c5995d1fca66fadba2ce3 (patch)
tree905048a285a8cd8fd6a070ce3b6c075e9681e59a /color_palette.c
parent194f71c150eb9ee696acca17176092e8b0ce6e4f (diff)
downloadpacman-ef3844bf2128fa82f20c5995d1fca66fadba2ce3.tar.gz
pacman-ef3844bf2128fa82f20c5995d1fca66fadba2ce3.tar.bz2
pacman-ef3844bf2128fa82f20c5995d1fca66fadba2ce3.zip
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.
Diffstat (limited to 'color_palette.c')
-rw-r--r--color_palette.c69
1 files changed, 69 insertions, 0 deletions
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 <ncurses.h>
+
+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);
+}