Compare commits

..

No commits in common. "4ae6c3fdfbe00c170ca8c4b55ee393ed3fde5375" and "6e45a0ce118438f8c865c6cb25cb4876b640db10" have entirely different histories.

4 changed files with 10 additions and 30 deletions

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 297 B

After

Width:  |  Height:  |  Size: 400 B

BIN
data/shurkien.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 B

40
ninja.c
View File

@ -23,15 +23,14 @@ float ninja_radius()
return fmax(ninja_texture.width, ninja_texture.height)/2; return fmax(ninja_texture.width, ninja_texture.height)/2;
} }
int ninja_dash(Vector2 pos, Vector2 to, float sec, Vector2 *dash) Vector2 ninja_dash(Vector2 pos, Vector2 to, float sec)
{ {
static Vector2 target = {0}; static Vector2 target = {0};
static int attack_type = 0; Vector2 dash = {0};
if (sec <= EPSILON) if (sec <= EPSILON)
return attack_type; return dash;
if (main_attack_cooldown <= EPSILON && key_pressed(KC_SHOOT)) { if (main_attack_cooldown <= EPSILON && key_pressed(KC_SHOOT)) {
main_attack_cooldown = sec + 0.069; main_attack_cooldown = sec + 0.069;
attack_type = KC_SHOOT;
dash_time = sec; dash_time = sec;
Vector2 diff = Vector2Subtract(to, pos); Vector2 diff = Vector2Subtract(to, pos);
Vector2 scale = Vector2Normalize(diff); Vector2 scale = Vector2Normalize(diff);
@ -40,29 +39,15 @@ int ninja_dash(Vector2 pos, Vector2 to, float sec, Vector2 *dash)
scale.y *= dist; scale.y *= dist;
target = Vector2Add(pos, scale); target = Vector2Add(pos, scale);
} }
else if (main_attack_cooldown <= EPSILON && key_pressed(KC_ULTI)) {
sec *= 3;
main_attack_cooldown = sec + 0.069;
attack_type = KC_ULTI;
dash_time = sec;
Vector2 diff = Vector2Subtract(to, pos);
Vector2 scale = Vector2Normalize(diff);
int dist = 400;
scale.x *= dist;
scale.y *= dist;
target = Vector2Add(pos, scale);
}
if (dash_time > EPSILON) { if (dash_time > EPSILON) {
float dt = GetFrameTime(); float dt = GetFrameTime();
dash_time -= dt; dash_time -= dt;
dash->x = Lerp(pos.x, target.x, dt/sec) - pos.x; dash.x = Lerp(pos.x, target.x, dt/sec) - pos.x;
dash->y = Lerp(pos.y, target.y, dt/sec) - pos.y; dash.y = Lerp(pos.y, target.y, dt/sec) - pos.y;
} else {
attack_type = 0;
} }
if (main_attack_cooldown > EPSILON) if (main_attack_cooldown > EPSILON)
main_attack_cooldown -= GetFrameTime(); main_attack_cooldown -= GetFrameTime();
return attack_type; return dash;
} }
float ninja_dash_time() float ninja_dash_time()
@ -70,11 +55,10 @@ float ninja_dash_time()
return dash_time; return dash_time;
} }
void hit_hitbox(Vector2 pos, float angle, float multiplicator) void hit_hitbox(Vector2 pos, float angle)
{ {
if (dash_time >= EPSILON) { if (dash_time >= EPSILON) {
Vector2 range = {ninja_texture.width, ninja_texture.height}; Vector2 range = {ninja_texture.width, ninja_texture.height};
range = Vector2Scale(range, multiplicator);
Vector2 coll[] = { Vector2 coll[] = {
{ range.x/2, 0}, { range.x/2, 0},
{ range.x/2, -range.y}, { range.x/2, -range.y},
@ -98,13 +82,12 @@ void hit_hitbox(Vector2 pos, float angle, float multiplicator)
void draw_ninja(Vector2 pos, Camera2D *cam) void draw_ninja(Vector2 pos, Camera2D *cam)
{ {
Vector2 dash = {0}; Vector2 dash = ninja_dash(GetScreenToWorld2D(pos, *cam), GetScreenToWorld2D(GetMousePosition(), *cam), 0.12);
int is_attack = ninja_dash(GetScreenToWorld2D(pos, *cam), GetScreenToWorld2D(GetMousePosition(), *cam), 0.12, &dash);
cam->target = Vector2Add(cam->target, dash); cam->target = Vector2Add(cam->target, dash);
Texture n; Texture n;
if (dash_time >= EPSILON) if (dash_time >= EPSILON)
n = ninja_attack_texture; n= ninja_attack_texture;
else else
n = ninja_texture; n = ninja_texture;
@ -120,8 +103,5 @@ void draw_ninja(Vector2 pos, Camera2D *cam)
DrawTexturePro(n, source, dest, origin, angle, WHITE); DrawTexturePro(n, source, dest, origin, angle, WHITE);
if (is_attack == KC_SHOOT) // hit_hitbox(pos, angle);
hit_hitbox(pos, angle, 1);
else if (is_attack == KC_ULTI)
hit_hitbox(pos, angle, 2);
} }