diff options
Diffstat (limited to 'src/player.c')
-rw-r--r-- | src/player.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/player.c b/src/player.c index 3605a6d..a28a6c9 100644 --- a/src/player.c +++ b/src/player.c @@ -78,10 +78,10 @@ static int slash_update(struct projectile *self) { } else { self->hp++; } - int x = from_fixed(self->x) + self->facing * sin(self->hp / 2) * SLASH_REACH_X; - int y = from_fixed(self->y) - cos(self->hp / 2) * SLASH_REACH_Y; - int xx = from_fixed(self->x) + self->facing * sin(self->hp / 2 + 1) * SLASH_REACH_X; - int yy = from_fixed(self->y) - cos(self->hp / 2 + 1) * SLASH_REACH_Y; + int x = from_fixed(self->x) + self->facing * sin(self->hp / 2.0) * SLASH_REACH_X; + int y = from_fixed(self->y) - cos(self->hp / 2.0) * SLASH_REACH_Y; + int xx = from_fixed(self->x) + self->facing * sin(self->hp / 2.0 + 1) * SLASH_REACH_X; + int yy = from_fixed(self->y) - cos(self->hp / 2.0 + 1) * SLASH_REACH_Y; self->hitbox = (struct hitbox) {.left = x - 2, .right = x + 2, .top = y - 2, .bottom = y + 2}; for (int i = 0, e = entities.enemies; i < 64 && e; i++) { if (entities.enemy[i].state) { @@ -118,18 +118,18 @@ static int slash_draw(struct projectile *self, int camX, int camY) { int const x = from_fixed(self->x) - camX, y = from_fixed(self->y) - camY; if (self->hp >= 0) { SDL_Vertex vertices[4] = { - {.position = {x + from_fixed(self->velocity.x) + self->facing * sin(self->hp / 2 - 1) * SLASH_REACH_X, y - cos(self->hp / 2 - 1) * SLASH_REACH_Y}, .color = {255, 191, 63, 255}}, - {.position = {x + self->facing * sin(self->hp / 2 + 0) * SLASH_REACH_X, y - cos(self->hp / 2 + 0) * SLASH_REACH_Y}, .color = {255, 127, 0, 255}}, - {.position = {x - from_fixed(self->velocity.x) + self->facing * sin(self->hp / 2 + 1) * SLASH_REACH_X, y - cos(self->hp / 2 + 1) * SLASH_REACH_Y}, .color = {255, 127, 0, 255}}, - {.position = {x - from_fixed(self->velocity.x * 2) + self->facing * sin(self->hp / 2 + 2) * SLASH_REACH_X, y - cos(self->hp / 2 + 2) * SLASH_REACH_Y}, .color = {255, 127, 0, 0}}, + {.position = {x + from_fixed(self->velocity.x) + self->facing * sin(self->hp / 2.0 - 1) * SLASH_REACH_X, y - cos(self->hp / 2.0 - 1) * SLASH_REACH_Y}, .color = {255, 191, 63, 255}}, + {.position = {x + self->facing * sin(self->hp / 2.0 + 0) * SLASH_REACH_X, y - cos(self->hp / 2.0 + 0) * SLASH_REACH_Y}, .color = {255, 127, 0, 255}}, + {.position = {x - from_fixed(self->velocity.x) + self->facing * sin(self->hp / 2.0 + 1) * SLASH_REACH_X, y - cos(self->hp / 2.0 + 1) * SLASH_REACH_Y}, .color = {255, 127, 0, 255}}, + {.position = {x - from_fixed(self->velocity.x * 2) + self->facing * sin(self->hp / 2.0 + 2) * SLASH_REACH_X, y - cos(self->hp / 2.0 + 2) * SLASH_REACH_Y}, .color = {255, 127, 0, 0}}, }; SDL_RenderGeometry(renderer, NULL, vertices, 4, (int []) {0, 1, 2, 0, 2, 3}, 6); } else { SDL_Vertex vertices[4] = { - {.position = {x - from_fixed(self->velocity.x) + self->facing * sin(self->hp / 2 + 1) * SLASH_REACH_X, y - cos(self->hp / 2 + 1) * SLASH_REACH_Y}, .color = {255, 191, 63, 255}}, - {.position = {x + + self->facing * sin(self->hp / 2 + 0) * SLASH_REACH_X, y - cos(self->hp / 2 + 0) * SLASH_REACH_Y}, .color = {255, 127, 0, 255}}, - {.position = {x + from_fixed(self->velocity.x) + self->facing * sin(self->hp / 2 - 1) * SLASH_REACH_X, y - cos(self->hp / 2 - 1) * SLASH_REACH_Y}, .color = {255, 127, 0, 255}}, - {.position = {x + from_fixed(self->velocity.x * 2) + self->facing * sin(self->hp / 2 - 2) * SLASH_REACH_X, y - cos(self->hp / 2 - 2) * SLASH_REACH_Y}, .color = {255, 127, 0, 0}}, + {.position = {x - from_fixed(self->velocity.x) + self->facing * sin(self->hp / 2.0 + 1) * SLASH_REACH_X, y - cos(self->hp / 2.0 + 1) * SLASH_REACH_Y}, .color = {255, 191, 63, 255}}, + {.position = {x + + self->facing * sin(self->hp / 2.0 + 0) * SLASH_REACH_X, y - cos(self->hp / 2.0 + 0) * SLASH_REACH_Y}, .color = {255, 127, 0, 255}}, + {.position = {x + from_fixed(self->velocity.x) + self->facing * sin(self->hp / 2.0 - 1) * SLASH_REACH_X, y - cos(self->hp / 2.0 - 1) * SLASH_REACH_Y}, .color = {255, 127, 0, 255}}, + {.position = {x + from_fixed(self->velocity.x * 2) + self->facing * sin(self->hp / 2.0 - 2) * SLASH_REACH_X, y - cos(self->hp / 2.0 - 2) * SLASH_REACH_Y}, .color = {255, 127, 0, 0}}, }; SDL_RenderGeometry(renderer, NULL, vertices, 4, (int []) {0, 1, 2, 0, 2, 3}, 6); } |