Make screen shake only happen on score.
This commit is contained in:
@@ -120,6 +120,7 @@ check_ball_paddle_collision :: proc(ball: ^Entity, paddle: Entity) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
increment_score :: proc(score_side: ^int, max_score: int, player: bool, ball: ^Entity) {
|
increment_score :: proc(score_side: ^int, max_score: int, player: bool, ball: ^Entity) {
|
||||||
|
emit_event(.Score_Change)
|
||||||
score_side^ += 1
|
score_side^ += 1
|
||||||
if score_side^ == max_score {
|
if score_side^ == max_score {
|
||||||
emit_event(Game_Over_Data{player})
|
emit_event(Game_Over_Data{player})
|
||||||
|
|||||||
@@ -58,14 +58,6 @@ process_events :: proc(game: ^Game) {
|
|||||||
push_scene(game, make_game_over_overlay(e.winner_is_player))
|
push_scene(game, make_game_over_overlay(e.winner_is_player))
|
||||||
|
|
||||||
case Ball_Collision_Data:
|
case Ball_Collision_Data:
|
||||||
// normalize the speed between 0.0 -> 1.0
|
|
||||||
// map that value to the camera displacement
|
|
||||||
min_speed: f32 = 200.0
|
|
||||||
max_speed: f32 = 550.0
|
|
||||||
speed_factor := clamp((e.speed - min_speed) / (max_speed - min_speed), 0, 1.0)
|
|
||||||
|
|
||||||
intensity := 0.5 + (speed_factor * 4.5)
|
|
||||||
game_trigger_shake(game, intensity, duration = 0.15)
|
|
||||||
audio_play_sfx(&game.audio, .Ball_Collision)
|
audio_play_sfx(&game.audio, .Ball_Collision)
|
||||||
|
|
||||||
case Simple_Event:
|
case Simple_Event:
|
||||||
@@ -81,6 +73,9 @@ process_events :: proc(game: ^Game) {
|
|||||||
case .Game_Resume:
|
case .Game_Resume:
|
||||||
pop_scene(game)
|
pop_scene(game)
|
||||||
|
|
||||||
|
case .Score_Change:
|
||||||
|
game_trigger_shake(game, 10, duration = 0.20)
|
||||||
|
|
||||||
case .Game_Settings:
|
case .Game_Settings:
|
||||||
parent: Maybe(Scene_Type) = nil
|
parent: Maybe(Scene_Type) = nil
|
||||||
if active := get_active_scene(game); active != nil {
|
if active := get_active_scene(game); active != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user