From e0ac06e0dbbd2a69cf7efc6230f150faa6923f5c Mon Sep 17 00:00:00 2001 From: girst Date: Mon, 3 Sep 2018 15:39:14 +0200 Subject: [PATCH] more food items --- README.md | 4 ++-- schemes.h | 10 +++++++--- viiper.c | 25 ++++++++++++++++++------- viiper.h | 12 +++++++++--- 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index a7c2e4a..8aa0aaa 100644 --- a/README.md +++ b/README.md @@ -34,10 +34,10 @@ recommend: - DONE ~~score, increasing speed~~ - DONE ~~bonus/special items: slower snake, shorter snake, etc.~~ - DONE ~~wall-wrap-around mode?~~ + - NAH: predatory animals trying to eat the snake? (🐉, 🐊, 🐆, 🐅, 🦁, 🐗, 🦊, 🦅) --> - - TODO more food items (to shape points distribution) + - TODO even more food items (to shape points distribution), boni - TODO decaying points? (more points the faster you get the food) - - TODO predatory animals trying to eat the snake? (🐉, 🐊, 🐆, 🐅, 🦁, 🐗, 🦊, 🦅) - TODO fix all `grep -n 'TODO\|XXX\|\([^:]\|^\)//' *.[ch]` - TODO: find a better name diff --git a/schemes.h b/schemes.h index adaf299..732031c 100644 --- a/schemes.h +++ b/schemes.h @@ -78,9 +78,13 @@ struct scheme unic0de = { .color = {"32", "92", "92;1"}, .food = { - [FOOD_5] = "🍐", - [FOOD_10] = "🍎", - [FOOD_20] = "🥑", + [FOOD_PEAR] = "🍐", + [FOOD_WMELON] = "🍉", + [FOOD_BANANA] = "🍌", + [FOOD_KIWI] = "🥝", + [FOOD_APPLER] = "🍎", + [FOOD_CHERRY] = "🍒", + [FOOD_AVOCADO] = "🥑", }, .boni = { [BONUS_SNIP] = "✂️ ", diff --git a/viiper.c b/viiper.c index 1735b2c..31abf04 100644 --- a/viiper.c +++ b/viiper.c @@ -47,6 +47,7 @@ #define LINE_OFFSET 1 #define LINES_AFTER 1 #define CW op.sch->cell_width +#define DW op.sch->display_width #define SPEEDUP_AFTER 100 /* increment speed every n points */ #define BONUS_INTERVAL 90 /* how often a bonus item is spawned */ @@ -296,9 +297,19 @@ void consume_item (struct item* i) { switch (i->t) { case FOOD: switch (i->v) { - case FOOD_5: g.p += 5; break; - case FOOD_10: g.p += 10; break; - case FOOD_20: g.p += 20; break; + case FOOD_PEAR: + case FOOD_WMELON: + case FOOD_BANANA: + case FOOD_KIWI: + g.p += 5; + break; + case FOOD_APPLER: + case FOOD_CHERRY: + g.p += 10; + break; + case FOOD_AVOCADO: + g.p += 20; + break; } snake_append(&g.s, -1, -1); break; /* will be reused as the head before it is drawn */ @@ -446,13 +457,13 @@ void pause_game (void) { } #define MOVE_POPUP(WIDTH, LINE) \ - move_ph(g.h/2+LINE_OFFSET-1+LINE,(g.w*op.sch->display_width-WIDTH)/2) + move_ph(g.h/2+LINE_OFFSET-1+LINE,(g.w*DW-WIDTH)/2) //TODO: macro does not correctly centre in DEC mode int end_screen(char* message) { int msg_w = strlen(message); MOVE_POPUP(msg_w, -1); print(BORDER(T,L)); - printm ((msg_w+2)/op.sch->display_width, BORDER(T,C)); + printm ((msg_w+2)/DW, BORDER(T,C)); print (BORDER(T,R)); MOVE_POPUP(msg_w, 0); @@ -465,7 +476,7 @@ int end_screen(char* message) { MOVE_POPUP(msg_w, 3); print(BORDER(B,L)); - printm ((msg_w+2)/op.sch->display_width, BORDER(B,C)); + printm ((msg_w+2)/DW, BORDER(B,C)); print (BORDER(B,R)); fflush(stdout); @@ -598,7 +609,7 @@ void clamp_fieldsize (void) { if (g.h < 10) g.h = 10; if (COL_OFFSET + g.w*CW + COL_OFFSET > w.ws_col) - g.w = (w.ws_col - 2*COL_OFFSET) / op.sch->display_width; + g.w = (w.ws_col - 2*COL_OFFSET) / DW; if (LINE_OFFSET + g.h + LINES_AFTER > w.ws_row) g.h = w.ws_row - (LINE_OFFSET+LINES_AFTER); } diff --git a/viiper.h b/viiper.h index 366ee0b..4b33638 100644 --- a/viiper.h +++ b/viiper.h @@ -44,9 +44,15 @@ enum item_type { BONUS, }; enum food_value { - FOOD_5, - FOOD_10, - FOOD_20, + FOOD_PEAR, + FOOD_WMELON, + FOOD_BANANA, + FOOD_KIWI, + + FOOD_APPLER, + FOOD_CHERRY, + + FOOD_AVOCADO, NUM_FOODS, }; enum bonus_value { -- 2.39.3