#include "game.h" /* These are good first things to change! Colors use numbers from 0 to 31. */ TEST_INTERNAL const u16 shirt = RGB(5, 14, 29); TEST_INTERNAL const char *const creature_art[] = { "..11........11..", ".1221......1221.", ".1231......1321.", "..123111111321..", "..123333333321..", ".12344444443321.", ".12341334143321.", ".12341534153321.", ".12643333443621.", "..123337733321..", "...1233333321...", "...1234444321...", "..123444444321..", "..123344443321..", "...1223113221...", "....111..111...." }; static void creature(void) { static const u16 palette[] = { 0, RGB(9, 8, 6), RGB(23, 15, 5), RGB(30, 23, 7), RGB(31, 28, 14), RGB(31, 31, 28), RGB(29, 13, 10), RGB(17, 8, 7) }; rectangle(175, 102, 14, 3, RGB(8, 16, 7)); sprite(174, 88, creature_art, 16, palette, 0); } void scaled_creature(int x, int y, int scale, const u16 *palette) { rectangle(x - 7 * scale, y, 14 * scale, 2 * scale, indoors() ? RGB(15, 11, 8) : RGB(8, 16, 7)); blit_sprite(x - 8 * scale, y - 16 * scale, creature_art, 16, 16, palette, scale, 0); } #include "wild_creatures.h" void draw_wild_creature(enum Species enemy, int x, int y) { const struct WildArt *art = &wild_art[enemy - FERNFOX]; rectangle(x - 20, y, 40, 3, RGB(8, 16, 7)); blit_sprite(x - 24, y - 48, art->rows, 24, 24, art->palette, 2, 0); } void draw_sprout(int x, int y, int scale) { static const u16 palette[] = { 0, RGB(5, 10, 7), RGB(6, 16, 8), RGB(12, 24, 10), RGB(24, 30, 14), RGB(31, 31, 28), RGB(30, 17, 12), RGB(12, 9, 7) }; scaled_creature(x, y, scale, palette); rectangle(x - scale, y - 16 * scale, 2 * scale, 3 * scale, RGB(5, 17, 8)); rectangle(x, y - 17 * scale, 4 * scale, 2 * scale, RGB(13, 24, 9)); rectangle(x + scale, y - 17 * scale, 2 * scale, scale, RGB(24, 30, 14)); } TEST_INTERNAL const char *const person_art[] = { ".....111111.....", "....12222221....", "...1223333221...", "...1233333321...", "...1222222221...", "..111111111111..", "...1444444441...", "...1466666641...", "....16166161....", "....16677661....", ".....166661.....", "....11888811....", "...1888998881...", "..161889988161..", "..161888888161..", "..166188881661..", "...1111111111...", "....1AA11AA1....", "....1AA11AA1....", "....111..111...." }; TEST_INTERNAL const char *const person_back_art[] = { ".....111111.....", "....12222221....", "...1223333221...", "...1233333321...", "...1233333321...", "...1222222221...", "...1444444441...", "....14444441....", "....14444441....", ".....166661.....", "....11888811....", "...1888888881...", "..1618BBBB8161..", "..1618BCCB8161..", "..1618BCCB8161..", "..1668BBBB8661..", "...1111111111...", "....1AA11AA1....", "....1AA11AA1....", "....111..111...." }; TEST_INTERNAL const char *const person_side_art[] = { "......11111.....", ".....1222221....", "....123333321...", "....123333321...", "....1222222221..", "....1111111111..", "....144466661...", "....144661661...", ".....14666661...", ".....1467761....", "......16661.....", ".....188881.....", "....1BB88881....", "....1BC81661....", "....1BB81661....", ".....188161.....", ".....111111.....", ".....1AA1A1.....", ".....1AA1A1.....", ".....111111....." }; static u16 lighter(u16 color) { int r = color & 31, g = (color >> 5) & 31, b = (color >> 10) & 31; return RGB(r + (31 - r) / 3, g + (31 - g) / 3, b + (31 - b) / 3); } static u16 darker(u16 color) { return RGB((color & 31) * 2 / 3, ((color >> 5) & 31) * 2 / 3, ((color >> 10) & 31) * 2 / 3); } /* x and y mark the feet. The art fits inside the original erase area. */ TEST_INTERNAL void person(int x, int y, int step, u16 clothes, u16 hat, enum Facing facing) { u16 palette[] = { 0, RGB(5, 7, 9), darker(hat), hat, RGB(11, 8, 7), RGB(24, 16, 12), RGB(31, 25, 19), RGB(25, 13, 12), clothes, lighter(clothes), RGB(9, 12, 17), RGB(24, 17, 8), RGB(30, 24, 12) }; rectangle(x - 7, y - 1, 15, 3, indoors() ? RGB(15, 11, 8) : RGB(8, 16, 7)); const char *const *art = facing == FACING_UP ? person_back_art : facing == FACING_DOWN ? person_art : person_side_art; sprite(x - 8, y - 19, art, 20, palette, facing == FACING_LEFT); rectangle(x - 4, y, 3, 2 - step, palette[1]); rectangle(x + 1, y, 3, 1 + step, palette[1]); } static void player(int x, int y, int step) { person(x, y, step, shirt, RGB(28, 8, 9), player_facing); } void actors(int x, int y, int step) { enum { HERO, SPROUT, MILA, GOLDEN, PROFESSOR, RANGER }; struct Actor { int x, y, kind; } list[4]; int count = 0; if (partner_owned && follower_ready) list[count++] = (struct Actor){follower_x, follower_y, SPROUT}; list[count++] = (struct Actor){x, y, HERO}; if (current_room == MELLON_HOUSE) { list[count++] = (struct Actor){PROF_X, PROF_Y, PROFESSOR}; } if (current_room == OUTSIDE) { list[count++] = (struct Actor){182, 104, GOLDEN}; list[count++] = (struct Actor){NPC_X, NPC_Y, MILA}; } if (current_room == ROUTE) list[count++] = (struct Actor){RANGER_X, RANGER_Y, RANGER}; /* Stable depth ordering keeps Sprout behind the hero on equal feet. */ for (int i = 1; i < count; ++i) { struct Actor actor = list[i]; int j = i; while (j > 0 && list[j - 1].y > actor.y) { list[j] = list[j - 1]; --j; } list[j] = actor; } for (int i = 0; i < count; ++i) { struct Actor actor = list[i]; if (actor.kind == HERO) player(actor.x, actor.y, step); else if (actor.kind == SPROUT) draw_sprout(actor.x, actor.y, 1); else if (actor.kind == GOLDEN) creature(); else if (actor.kind == MILA) person(actor.x, actor.y, 0, RGB(4, 21, 13), RGB(12, 7, 4), FACING_DOWN); else if (actor.kind == RANGER) person(actor.x, actor.y, 0, RGB(27, 16, 7), RGB(6, 15, 11), FACING_DOWN); else person(actor.x, actor.y, 0, RGB(29, 30, 27), RGB(20, 21, 19), FACING_DOWN); } }