diff options
-rw-r--r-- | main.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -33,14 +33,14 @@ SDL_Texture *CreateTiledTexture(SDL_Renderer *context, const char *filename, int return texture; } -void PaintMask(float *mask, float x, float y, float color, float size) { +void PaintMask(float *mask, int width, int height, float x, float y, float color, float size) { for (int j = y - size; j < y + size; j++) { for (int i = x - size; i < x + size; i++) { float dj = y - j; float di = x - i; - if (i > 0 && i < WINDOW_W && j > 0 && j < WINDOW_H + if (i > 0 && i < width && j > 0 && j < height && dj * dj + di * di <= size * size / 2) { - size_t index = i + j * WINDOW_W; + size_t index = i + j * width; mask[index] = color; } } @@ -92,9 +92,9 @@ void GameMain(SDL_Renderer *context) { Uint32 mouse_state = SDL_GetMouseState(&mouse_x, &mouse_y); float size = 20; if (mouse_state & SDL_BUTTON_LMASK) { - PaintMask(mask, mouse_x, WINDOW_H - mouse_y, 1.0, size); + PaintMask(mask, WINDOW_W, WINDOW_H, mouse_x, WINDOW_H - mouse_y, 1.0, size); } else if (mouse_state & SDL_BUTTON_RMASK) { - PaintMask(mask, mouse_x, WINDOW_H - mouse_y, 0.0, size); + PaintMask(mask, WINDOW_W, WINDOW_H, mouse_x, WINDOW_H - mouse_y, 0.0, size); } const Uint8 *keys = SDL_GetKeyboardState(0); |