diff options
-rw-r--r-- | include/isogfx/asset.h | 8 | ||||
-rw-r--r-- | src/gfx2d.c | 14 |
2 files changed, 11 insertions, 11 deletions
diff --git a/include/isogfx/asset.h b/include/isogfx/asset.h index 361ffcd..cc70ee3 100644 --- a/include/isogfx/asset.h +++ b/include/isogfx/asset.h | |||
@@ -154,7 +154,7 @@ static inline const Pixel* ts_tile_get_pixels( | |||
154 | } | 154 | } |
155 | 155 | ||
156 | /// Return the tile's pixel at (x,y). | 156 | /// Return the tile's pixel at (x,y). |
157 | static const Pixel* ts_tile_xy( | 157 | static inline const Pixel* ts_tile_xy( |
158 | const Pixel* tile_pixels, const Ts_Tile* tile, int x, int y) { | 158 | const Pixel* tile_pixels, const Ts_Tile* tile, int x, int y) { |
159 | assert(tile_pixels); | 159 | assert(tile_pixels); |
160 | assert(tile); | 160 | assert(tile); |
@@ -166,9 +166,9 @@ static const Pixel* ts_tile_xy( | |||
166 | } | 166 | } |
167 | 167 | ||
168 | /// Return the tile's pixel at (x,y). | 168 | /// Return the tile's pixel at (x,y). |
169 | static Pixel* ts_tile_xy_mut( | 169 | static inline Pixel* ts_tile_xy_mut( |
170 | const Pixel* pixels, const Ts_Tile* tile, int x, int y) { | 170 | Pixel* tile_pixels, const Ts_Tile* tile, int x, int y) { |
171 | return (Pixel*)ts_tile_xy(pixels, tile, x, y); | 171 | return (Pixel*)ts_tile_xy(tile_pixels, tile, x, y); |
172 | } | 172 | } |
173 | 173 | ||
174 | /// Return the ith layer in the tile map. | 174 | /// Return the ith layer in the tile map. |
diff --git a/src/gfx2d.c b/src/gfx2d.c index f1f26cb..8d78c2b 100644 --- a/src/gfx2d.c +++ b/src/gfx2d.c | |||
@@ -150,8 +150,8 @@ static inline vec2 cart2iso(vec2 cart, int s, int t, int w) { | |||
150 | const double one_over_s = 1. / (double)s; | 150 | const double one_over_s = 1. / (double)s; |
151 | const double one_over_t = 1. / (double)t; | 151 | const double one_over_t = 1. / (double)t; |
152 | const double x = cart.x - (double)(w / 2); | 152 | const double x = cart.x - (double)(w / 2); |
153 | return (vec2){.x = (one_over_s * x + one_over_t * cart.y), | 153 | return (vec2){.x = ((one_over_s * x) + (one_over_t * cart.y)), |
154 | .y = (-one_over_s * x + one_over_t * cart.y)}; | 154 | .y = ((-one_over_s * x) + (one_over_t * cart.y))}; |
155 | } | 155 | } |
156 | 156 | ||
157 | static inline const Pixel* screen_xy_const_ref( | 157 | static inline const Pixel* screen_xy_const_ref( |
@@ -161,10 +161,10 @@ static inline const Pixel* screen_xy_const_ref( | |||
161 | assert(y >= 0); | 161 | assert(y >= 0); |
162 | assert(x < screen->width); | 162 | assert(x < screen->width); |
163 | assert(y < screen->height); | 163 | assert(y < screen->height); |
164 | return &screen->pixels[y * screen->width + x]; | 164 | return &screen->pixels[(y * screen->width) + x]; |
165 | } | 165 | } |
166 | 166 | ||
167 | static inline Pixel screen_xy(Screen* screen, int x, int y) { | 167 | static inline Pixel screen_xy(const Screen* screen, int x, int y) { |
168 | return *screen_xy_const_ref(screen, x, y); | 168 | return *screen_xy_const_ref(screen, x, y); |
169 | } | 169 | } |
170 | 170 | ||
@@ -360,10 +360,10 @@ static void make_tile_from_colour( | |||
360 | const int height = tile->height; | 360 | const int height = tile->height; |
361 | const int r = width / height; | 361 | const int r = width / height; |
362 | for (int y = 0; y < height / 2; ++y) { | 362 | for (int y = 0; y < height / 2; ++y) { |
363 | const int mask_start = width / 2 - r * y - 1; | 363 | const int mask_start = (width / 2) - (r * y) - 1; |
364 | const int mask_end = width / 2 + r * y + 1; | 364 | const int mask_end = (width / 2) + (r * y) + 1; |
365 | for (int x = 0; x < width; ++x) { | 365 | for (int x = 0; x < width; ++x) { |
366 | const bool mask = (mask_start <= x) && (x <= mask_end); | 366 | const bool mask = ((mask_start <= x) && (x <= mask_end)) != 0; |
367 | const Pixel val = mask ? colour : (Pixel){.r = 0, .g = 0, .b = 0, .a = 0}; | 367 | const Pixel val = mask ? colour : (Pixel){.r = 0, .g = 0, .b = 0, .a = 0}; |
368 | 368 | ||
369 | // Top half. | 369 | // Top half. |