diff --git a/data/ninja.aseprite b/data/ninja.aseprite index ace4059..4c26fb6 100644 Binary files a/data/ninja.aseprite and b/data/ninja.aseprite differ diff --git a/data/ninja_attaque.png b/data/ninja_attaque.png new file mode 100644 index 0000000..df5c63b Binary files /dev/null and b/data/ninja_attaque.png differ diff --git a/ninja.c b/ninja.c index 20dd201..2a0659e 100644 --- a/ninja.c +++ b/ninja.c @@ -5,12 +5,14 @@ #include "keys.h" Texture ninja_texture; +Texture ninja_attack_texture; float dash_time = 0; void load_ninja() { ninja_texture = LoadTexture("data/ninja.png"); + ninja_attack_texture = LoadTexture("data/ninja_attaque.png"); } float ninja_radius() @@ -64,11 +66,11 @@ void hit_hitbox(Vector2 pos, float angle) coll[i] = Vector2Rotate(coll[i], angle * PI/180); } DrawTriangle((Vector2){ pos.x + coll[0].x, pos.y + coll[0].y }, - (Vector2){ pos.x + coll[1].x, pos.y + coll[1].y }, - (Vector2){ pos.x + coll[2].x, pos.y + coll[2].y }, VIOLET); + (Vector2){ pos.x + coll[1].x, pos.y + coll[1].y }, + (Vector2){ pos.x + coll[2].x, pos.y + coll[2].y }, VIOLET); DrawTriangle((Vector2){ pos.x + coll[3].x, pos.y + coll[3].y }, - (Vector2){ pos.x + coll[4].x, pos.y + coll[4].y }, - (Vector2){ pos.x + coll[5].x, pos.y + coll[5].y }, VIOLET); + (Vector2){ pos.x + coll[4].x, pos.y + coll[4].y }, + (Vector2){ pos.x + coll[5].x, pos.y + coll[5].y }, VIOLET); } } @@ -77,7 +79,12 @@ void draw_ninja(Vector2 pos, Camera2D *cam) Vector2 dash = ninja_dash(GetScreenToWorld2D(pos, *cam), GetScreenToWorld2D(GetMousePosition(), *cam), 0.12); cam->target = Vector2Add(cam->target, dash); - Texture n = ninja_texture; + Texture n; + if (dash_time >= EPSILON) + n= ninja_attack_texture; + else + n = ninja_texture; + Rectangle source = {0, 0, n.width, n.height}; Rectangle dest = {pos.x, pos.y, n.width, n.height}; Vector2 origin = {n.width/2, n.height/2}; @@ -86,5 +93,5 @@ void draw_ninja(Vector2 pos, Camera2D *cam) angle += 90; DrawTexturePro(n, source, dest, origin, angle, WHITE); - hit_hitbox(pos, angle); + // hit_hitbox(pos, angle); }