diff --git a/components/Scenes/World.tscn b/components/Scenes/World.tscn index 3ee3491..10019a5 100644 --- a/components/Scenes/World.tscn +++ b/components/Scenes/World.tscn @@ -25,3 +25,4 @@ offset = Vector2(0, -80) process_callback = 0 position_smoothing_enabled = true script = ExtResource("5_mk7bv") +shakeOffset = 100.0 diff --git a/resources/sounds/effect/BigLaser.wav b/resources/sounds/effect/BigLaser.wav index 3159e9a..ee67b59 100644 Binary files a/resources/sounds/effect/BigLaser.wav and b/resources/sounds/effect/BigLaser.wav differ diff --git a/scripts/Contents/Bullets/BigLaser.gd b/scripts/Contents/Bullets/BigLaser.gd index f91072c..3793d1f 100644 --- a/scripts/Contents/Bullets/BigLaser.gd +++ b/scripts/Contents/Bullets/BigLaser.gd @@ -1,6 +1,8 @@ extends BulletBase class_name BigLaser +func spawn(): + CameraManager.shake(5000) func ai(): rotation = lerp_angle(rotation, ((get_global_mouse_position() - position).angle()), 0.15) position = launcher.texture.global_position diff --git a/scripts/Tools/CameraManager.gd b/scripts/Tools/CameraManager.gd index a0057fc..96b355e 100644 --- a/scripts/Tools/CameraManager.gd +++ b/scripts/Tools/CameraManager.gd @@ -2,10 +2,23 @@ extends Camera2D class_name CameraManager -static var camera: Camera2D = null +@export var shakeOffset: float = 100 + +var shaking: bool = false + +static var instance: CameraManager = null func _ready(): - camera = self + instance = self func _physics_process(_delta): if is_instance_valid(UIState.player): position = UIState.player.position + if shaking: + position += MathTool.randv2_range(shakeOffset) + +static func shake(millseconds: int = 1000): + print("shake start") + instance.shaking = true + await TickTool.millseconds(millseconds) + instance.shaking = false + print("shake end")