97 lines
3.9 KiB
C
97 lines
3.9 KiB
C
#include "game.h"
|
|
|
|
int near_water(int x, int y)
|
|
{
|
|
return current_room == BEACH && x >= 17 && x <= 222 &&
|
|
y >= beach_shoreline(x) - 8 && y <= beach_shoreline(x) - 5;
|
|
}
|
|
|
|
int cast_rod(int x, int y)
|
|
{
|
|
if (!rod_owned || !near_water(x, y) || player_facing != FACING_DOWN) return 0;
|
|
return start_battle(TIDEFIN);
|
|
}
|
|
|
|
int beach_shoreline(int x)
|
|
{
|
|
return 104 + ((x / 24) % 3) * 2;
|
|
}
|
|
|
|
static u16 palm_pixel(int x, int y, int center, u16 ground)
|
|
{
|
|
int dx = x - center, dy = y - 48;
|
|
int distance = dx < 0 ? -dx : dx;
|
|
if (y >= 48 && y < 70) {
|
|
int lean = (y - 48) / 6;
|
|
if (dx >= lean - 1 && dx <= lean + 2)
|
|
ground = (dx == lean - 1 || y % 5 == 0) ? RGB(13, 9, 6) : RGB(25, 18, 10);
|
|
}
|
|
if (distance <= 15 && dy >= -5 + distance / 2 && dy <= -2 + distance / 2)
|
|
ground = dy == -2 + distance / 2 ? RGB(4, 13, 8) : RGB(8, 22, 10);
|
|
if (dy >= -12 && dy <= 1 && distance <= (dy + 13) / 4)
|
|
ground = dx < 0 ? RGB(5, 17, 9) : RGB(15, 27, 11);
|
|
if (dy >= -7 && dy <= 5 && distance >= 3 && distance <= 11 &&
|
|
dy >= distance - 11 && dy <= distance - 8)
|
|
ground = dy == distance - 11 ? RGB(17, 27, 11) : RGB(5, 18, 9);
|
|
if (dy >= -1 && dy <= 2 && (dx == -1 || dx == 2)) ground = RGB(15, 10, 6);
|
|
return ground;
|
|
}
|
|
|
|
u16 beach_scenery(int x, int y)
|
|
{
|
|
if (y < 18 || y >= 142) return RGB(29, 30, 25);
|
|
int shore = beach_shoreline(x);
|
|
u16 color = RGB(31, 28, 19);
|
|
if ((x * 3 + y * 7) % 59 < 2) color = RGB(28, 24, 15);
|
|
if ((x * 7 + y * 3) % 71 == 0) color = RGB(31, 31, 24);
|
|
/* A grassy bank separates the beach from Mellon's garden to the north. */
|
|
if (y < 36) {
|
|
color = RGB(9, 21, 10);
|
|
if ((x & 15) == 4 && (y & 7) >= 5) color = RGB(5, 15, 8);
|
|
if ((x & 15) == 10 && (y & 7) == 2) color = RGB(16, 27, 12);
|
|
if (y >= 32) color = RGB(5, 13, 8);
|
|
} else if (y < 46) {
|
|
color = (y == 36 || y == 43 || x % 16 == 0) ? RGB(18, 14, 9) : RGB(27, 21, 12);
|
|
if (y == 45) color = RGB(22, 18, 11);
|
|
}
|
|
if (x >= 97 && x < 120 && y < 70) {
|
|
color = RGB(29, 27, 18);
|
|
if (x == 97 || x == 119) color = RGB(24, 23, 14);
|
|
if ((x & 7) == 3 && (y & 7) == 5) color = RGB(26, 23, 15);
|
|
}
|
|
/* Wet sand, a foamy waterline, turquoise shallows, and deep blue sea. */
|
|
if (y >= shore - 4) color = RGB(26, 24, 17);
|
|
if (y >= shore) color = RGB(29, 31, 28);
|
|
if (y >= shore + 2) color = RGB(15, 28, 28);
|
|
if (y >= shore + 6) color = RGB(7, 23, 29);
|
|
if (y >= 128) color = RGB(5, 18, 27);
|
|
if (y >= shore + 7 && y % 11 == 0 && (x + y * 3) % 27 < 11)
|
|
color = RGB(24, 31, 30);
|
|
if (y >= shore + 8 && y % 11 == 1 && (x + y * 3) % 27 < 8)
|
|
color = RGB(12, 26, 30);
|
|
|
|
color = palm_pixel(x, y, 28, color);
|
|
color = palm_pixel(x, y, 210, color);
|
|
/* A blue-and-white towel beneath a striped sun umbrella. */
|
|
if (x >= 43 && x < 67 && y >= 89 && y < 96) {
|
|
color = y % 3 == 0 ? RGB(30, 31, 28) : RGB(8, 20, 27);
|
|
if (x == 43 || x == 66) color = RGB(23, 28, 27);
|
|
}
|
|
if (x >= 54 && x < 57 && y >= 75 && y < 94)
|
|
color = x == 54 ? RGB(15, 10, 7) : RGB(26, 20, 12);
|
|
int ux = x - 55, uy = y - 77;
|
|
if (uy <= 0 && uy >= -10 && ux * ux + uy * uy * 3 < 225) {
|
|
color = ((x / 5) & 1) ? RGB(31, 14, 12) : RGB(31, 29, 20);
|
|
if (ux * ux + uy * uy * 3 > 177 || uy == 0) color = RGB(20, 9, 9);
|
|
if (uy == -8) color = RGB(31, 24, 18);
|
|
}
|
|
/* Two tiny shells and an orange starfish, all safe to walk over. */
|
|
if (((x >= 89 && x < 95) || (x >= 172 && x < 178)) && y >= 87 && y < 91)
|
|
color = (x % 2 == 0 || y == 90) ? RGB(26, 17, 16) : RGB(31, 26, 23);
|
|
int sx = x - 142, sy = y - 94;
|
|
if ((sx >= -3 && sx <= 3 && sy == 0) || (sx == 0 && sy >= -3 && sy <= 3) ||
|
|
(sx == -2 && sy == 2) || (sx == 2 && sy == 2)) color = RGB(30, 16, 7);
|
|
if (sx == 0 && sy == 0) color = RGB(31, 24, 10);
|
|
return color;
|
|
}
|