fix default back speed

fix default back speed
This commit is contained in:
nemo 2024-10-11 11:56:08 +02:00
parent c642aff92f
commit 5b2c7e729d
1 changed files with 12 additions and 4 deletions

View File

@ -6,6 +6,9 @@
Texture minigun_texture;
#define DEFAULT_BACK_SPEED 5
float back_speed = DEFAULT_BACK_SPEED;
void load_minigun()
{
minigun_texture = LoadTexture("data/minigun.png");
@ -24,15 +27,20 @@ void process_minigun(Vector2 pos, Camera2D *real_cam, Camera2D *effect_cam)
effect_cam->offset.y += GetRandomValue(-force/2, force/2);
}
else if (key_down(KC_SHOOT)) {
int speed = 5;
back_speed += GetFrameTime() * 1.2;
if (back_speed >= 25)
back_speed = 25;
float angle = -Vector2LineAngle(pos, GetMousePosition());
angle *= 180/PI;
Vector2 world = GetScreenToWorld2D(pos, *real_cam);
Vector2 toward = Vector2Normalize((Vector2) {cos(angle * PI/180), sin(angle * PI/180)});
real_cam->target = Vector2Subtract(world, Vector2Scale(toward, speed));
real_cam->target = Vector2Subtract(world, Vector2Scale(toward, back_speed));
bullet_spawn(BULLET_MINIGUN, Vector2Subtract(world, Vector2Scale(toward, speed*1.0)), angle);
bullet_spawn(BULLET_MINIGUN, Vector2Subtract(world, Vector2Scale(toward, speed*6.0)), angle);
bullet_spawn(BULLET_MINIGUN, Vector2Subtract(world, Vector2Scale(toward, 5*1.0)), angle);
bullet_spawn(BULLET_MINIGUN, Vector2Subtract(world, Vector2Scale(toward, 5*6.0)), angle);
}
if (key_down(KC_SPECIAL) || !key_down(KC_SHOOT)) {
back_speed = DEFAULT_BACK_SPEED;
}
}