music player, credits
[carveJwlIkooP6JGAAIwe30JlM.git] / player_common.c
index c9cf3b7388e1bee9d7966764d4920b0dc760682f..0c76d8df5496117dedfcde8e235279d1c35c10b1 100644 (file)
@@ -6,6 +6,7 @@
 #include "conf.h"
 #include "input.h"
 #include "menu.h"
+#include "vg/vg_perlin.h"
 
 VG_STATIC void player_vector_angles( v3f angles, v3f v, float C, float k )
 {
@@ -208,6 +209,15 @@ VG_STATIC void player__cam_iterate( player_instance *player )
    v3_lerp( tpv_pos, fpv_pos, player->camera_type_blend, player->cam.pos );
    v3_copy( player->angles, player->cam.angles );
 
+   /* Camera shake */
+   f32 speed = v3_length(player->rb.v),
+       strength = k_cam_shake_strength * speed;
+   player->cam_trackshake += speed*k_cam_shake_trackspeed*vg.time_frame_delta;
+
+   v2f rnd = {perlin1d( player->cam_trackshake, 1.0f, 4, 20 ),
+              perlin1d( player->cam_trackshake, 1.0f, 4, 63 ) };
+   v2_muladds( player->cam.angles, rnd, strength, player->cam.angles );
+
    v3f Fd, Fs, F;
    v3_muls( player->cam_land_punch_v, -k_cam_damp, Fd );
    v3_muls( player->cam_land_punch, -k_cam_spring, Fs );