Compare commits
No commits in common. "4ae6c3fdfbe00c170ca8c4b55ee393ed3fde5375" and "6e45a0ce118438f8c865c6cb25cb4876b640db10" have entirely different histories.
4ae6c3fdfb
...
6e45a0ce11
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 297 B After Width: | Height: | Size: 400 B |
Binary file not shown.
After Width: | Height: | Size: 400 B |
38
ninja.c
38
ninja.c
|
@ -23,15 +23,14 @@ float ninja_radius()
|
|||
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 int attack_type = 0;
|
||||
Vector2 dash = {0};
|
||||
if (sec <= EPSILON)
|
||||
return attack_type;
|
||||
return dash;
|
||||
if (main_attack_cooldown <= EPSILON && key_pressed(KC_SHOOT)) {
|
||||
main_attack_cooldown = sec + 0.069;
|
||||
attack_type = KC_SHOOT;
|
||||
dash_time = sec;
|
||||
Vector2 diff = Vector2Subtract(to, pos);
|
||||
Vector2 scale = Vector2Normalize(diff);
|
||||
|
@ -40,29 +39,15 @@ int ninja_dash(Vector2 pos, Vector2 to, float sec, Vector2 *dash)
|
|||
scale.y *= dist;
|
||||
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) {
|
||||
float dt = GetFrameTime();
|
||||
dash_time -= dt;
|
||||
dash->x = Lerp(pos.x, target.x, dt/sec) - pos.x;
|
||||
dash->y = Lerp(pos.y, target.y, dt/sec) - pos.y;
|
||||
} else {
|
||||
attack_type = 0;
|
||||
dash.x = Lerp(pos.x, target.x, dt/sec) - pos.x;
|
||||
dash.y = Lerp(pos.y, target.y, dt/sec) - pos.y;
|
||||
}
|
||||
if (main_attack_cooldown > EPSILON)
|
||||
main_attack_cooldown -= GetFrameTime();
|
||||
return attack_type;
|
||||
return dash;
|
||||
}
|
||||
|
||||
float ninja_dash_time()
|
||||
|
@ -70,11 +55,10 @@ float ninja_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) {
|
||||
Vector2 range = {ninja_texture.width, ninja_texture.height};
|
||||
range = Vector2Scale(range, multiplicator);
|
||||
Vector2 coll[] = {
|
||||
{ range.x/2, 0},
|
||||
{ range.x/2, -range.y},
|
||||
|
@ -98,8 +82,7 @@ void hit_hitbox(Vector2 pos, float angle, float multiplicator)
|
|||
|
||||
void draw_ninja(Vector2 pos, Camera2D *cam)
|
||||
{
|
||||
Vector2 dash = {0};
|
||||
int is_attack = ninja_dash(GetScreenToWorld2D(pos, *cam), GetScreenToWorld2D(GetMousePosition(), *cam), 0.12, &dash);
|
||||
Vector2 dash = ninja_dash(GetScreenToWorld2D(pos, *cam), GetScreenToWorld2D(GetMousePosition(), *cam), 0.12);
|
||||
cam->target = Vector2Add(cam->target, dash);
|
||||
|
||||
Texture n;
|
||||
|
@ -120,8 +103,5 @@ void draw_ninja(Vector2 pos, Camera2D *cam)
|
|||
|
||||
DrawTexturePro(n, source, dest, origin, angle, WHITE);
|
||||
|
||||
if (is_attack == KC_SHOOT)
|
||||
hit_hitbox(pos, angle, 1);
|
||||
else if (is_attack == KC_ULTI)
|
||||
hit_hitbox(pos, angle, 2);
|
||||
// hit_hitbox(pos, angle);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue