diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 4 | ||||
-rw-r--r-- | src/player.c | 14 | ||||
-rw-r--r-- | src/res/particles.ase | bin | 0 -> 288 bytes |
3 files changed, 13 insertions, 5 deletions
diff --git a/src/main.c b/src/main.c index d5f6504..fbbb371 100644 --- a/src/main.c +++ b/src/main.c @@ -282,7 +282,7 @@ int main(int const argc, char *const *const argv) { return EXIT_FAILURE; } SDL_StopTextInput(); - if (scale <= 0) { + if (scale <= 0) { // this looks very wrong SDL_DisplayMode dm; if (SDL_GetDesktopDisplayMode(0, &dm) != 0) { SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "couldnt get desktop size", SDL_GetError(), NULL); @@ -309,6 +309,8 @@ int main(int const argc, char *const *const argv) { if (window == NULL) { goto end; } + + SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"); // hack, i dont wanna deal with windows discarding render textures renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_TARGETTEXTURE | SDL_RENDERER_PRESENTVSYNC); if (renderer == NULL) { goto end; diff --git a/src/player.c b/src/player.c index a6fa86d..f36ae1a 100644 --- a/src/player.c +++ b/src/player.c @@ -13,6 +13,9 @@ #define GRAVITY 1 #define JUMP 30 +#define SLASH_REACH_X 8 +#define SLASH_REACH_Y 6 + enum { PLAYER_NONE, PLAYER_IDLE, @@ -49,6 +52,9 @@ static int slash_update(struct projectile *self) { self->x += self->velocity.x; self->y += self->velocity.y; self->hp--; + int x = from_fixed(self->x) + self->facing * sin(self->hp + 0) * SLASH_REACH_X; + int y = from_fixed(self->y) - cos(self->hp + 0) * SLASH_REACH_Y; + self->hitbox = (struct hitbox) {.left = x, .right = x, .top = y, .bottom = y}; #if 0 struct particle *part = entities.particle + entities.particles; part->x = self->x + to_fixed(self->facing >= 0? sin(self->hp): -sin(self->hp)) * 6; @@ -72,9 +78,9 @@ static int slash_draw(struct projectile *self, int camX, int camY) { //SDL_RenderFillRect(renderer, &(SDL_Rect) {from_fixed(self->x) - camX - 8, from_fixed(self->y) - camY - 12, 16, 16}); int const x = from_fixed(self->x) - camX, y = from_fixed(self->y) - camY; SDL_Vertex vertices[3] = { - {.position = {x + from_fixed(self->velocity.x) + ((self->facing >= 0)? sin(self->hp - 1): -sin(self->hp - 1)) * 8, y - cos(self->hp - 1) * 6}, .color = {255, 127, 0, 255}}, - {.position = {x + ((self->facing >= 0)? sin(self->hp + 0): -sin(self->hp + 0)) * 8, y - cos(self->hp + 0) * 6}, .color = {255, 127, 0, 255}}, - {.position = {x - from_fixed(self->velocity.x) + ((self->facing >= 0)? sin(self->hp + 1): -sin(self->hp + 1)) * 8, y - cos(self->hp + 1) * 6}, .color = {255, 127, 0, 255}}, + {.position = {x + from_fixed(self->velocity.x) + self->facing * sin(self->hp - 1) * SLASH_REACH_X, y - cos(self->hp - 1) * SLASH_REACH_Y}, .color = {255, 127, 0, 255}}, + {.position = {x + self->facing * sin(self->hp + 0) * SLASH_REACH_X, y - cos(self->hp + 0) * SLASH_REACH_Y}, .color = {255, 127, 0, 255}}, + {.position = {x - from_fixed(self->velocity.x) + self->facing * sin(self->hp + 1) * SLASH_REACH_X, y - cos(self->hp + 1) * SLASH_REACH_Y}, .color = {255, 127, 0, 255}}, }; SDL_RenderGeometry(renderer, NULL, vertices, 3, NULL, 0); return 0; @@ -287,7 +293,7 @@ static int player_hurt(struct entity *self, int damage) { part->x = self->x; part->y = self->y; part->velocity = (struct vec2) {to_fixed(x), to_fixed(y) - 8}; - part->rect = (SDL_Rect) {0, 0, 4, 4}; + part->rect = (SDL_Rect) {4, 0, 4, 4}; part->acceleration = (struct vec2) {0, 1}; part->hp = 30; entities.particles++; diff --git a/src/res/particles.ase b/src/res/particles.ase new file mode 100644 index 0000000..5e1762d --- /dev/null +++ b/src/res/particles.ase Binary files differ |