summaryrefslogtreecommitdiffstats
path: root/src/player.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/player.c')
-rw-r--r--src/player.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/player.c b/src/player.c
index f5d8f4c..1ec7795 100644
--- a/src/player.c
+++ b/src/player.c
@@ -184,6 +184,7 @@ mf_player_render(struct mf_player *p, SDL_Renderer *renderer)
int oy;
int fr;
int hy;
+ int ox;
cx = p->cur_x * p->cell_width + p->cell_width / 2;
cy = p->cur_y * p->cell_width + p->cell_width / 2;
@@ -275,6 +276,65 @@ mf_player_render(struct mf_player *p, SDL_Renderer *renderer)
#undef _mf_player_px
+ /*
+ * Eyes
+ */
+
+ if (SDL_SetRenderDrawColor(renderer,
+ MF_COLOR_PEYE_R, MF_COLOR_PEYE_G,
+ MF_COLOR_PEYE_B, MF_COLOR_PEYE_A) < 0) {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+ "Couldn't render player: %s",
+ SDL_GetError());
+ e = -1;
+ }
+
+ ox = r * MF_PLAYER_EYE_X;
+ oy = r * MF_PLAYER_EYE_Y;
+ fr = r * MF_PLAYER_EYE_R;
+
+#define _mf_player_px(X, Y) \
+ do { \
+ hy = round(sqrt((r-0.5)*(r-0.5) - \
+ (X+fx-ox-0.5)*(X+fx-ox-0.5)) + 0.5); \
+ if (Y - oy >= 0-hy || Y - oy <= hy) { \
+ if (SDL_RenderDrawPoint(renderer, \
+ cx + fx - ox + X, cy - oy + Y) \
+ < 0) { \
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, \
+ "Couldn't render widget: %s", \
+ SDL_GetError()); \
+ e = -1; \
+ } \
+ } \
+ hy = round(sqrt((r-0.5)*(r-0.5) - \
+ (X+fx+ox-0.5)*(X+fx+ox-0.5)) + 0.5); \
+ if (Y - oy >= 0-hy || Y - oy <= hy) { \
+ if (SDL_RenderDrawPoint(renderer, \
+ cx + fx + ox + X, cy - oy + Y) \
+ < 0) { \
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, \
+ "Couldn't render widget: %s", \
+ SDL_GetError()); \
+ e = -1; \
+ } \
+ } \
+ } while (0)
+
+ for (x = 0, y = fr; y > x; ++x) {
+ y = round(sqrt((fr-0.5)*(fr-0.5) - (x-0.5)*(x-0.5)) + 0.5);
+ for (i = 0; i <= y; ++i) _mf_player_px( x, i);
+ for (i = 0; i >= 0-y; --i) _mf_player_px( x, i);
+ for (i = 0; i <= y; ++i) _mf_player_px(0-x, i);
+ for (i = 0; i >= 0-y; --i) _mf_player_px(0-x, i);
+ for (i = 0; i <= y; ++i) _mf_player_px( i, x);
+ for (i = 0; i <= y; ++i) _mf_player_px( i, 0-x);
+ for (i = 0; i >= 0-y; --i) _mf_player_px( i, x);
+ for (i = 0; i >= 0-y; --i) _mf_player_px( i, 0-x);
+ }
+
+#undef _mf_player_px
+
return e;
}