From 9cecf8e8ab30cb46932d5179891e83fc0dee372b Mon Sep 17 00:00:00 2001 From: alzeih Date: Sat, 27 Feb 2010 14:51:03 +1300 Subject: [PATCH] Basic ScreenShaker --- OpenRa.Game/OpenRa.Game.csproj | 3 +- OpenRa.Game/Traits/World/ScreenShaker.cs | 38 ++++++++++++++++++++++++ mods/ra/rules.yaml | 1 + 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 OpenRa.Game/Traits/World/ScreenShaker.cs diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index ae74c3a932..9fa69e1eff 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -267,6 +267,7 @@ + @@ -302,4 +303,4 @@ --> - \ No newline at end of file + diff --git a/OpenRa.Game/Traits/World/ScreenShaker.cs b/OpenRa.Game/Traits/World/ScreenShaker.cs new file mode 100644 index 0000000000..485197d732 --- /dev/null +++ b/OpenRa.Game/Traits/World/ScreenShaker.cs @@ -0,0 +1,38 @@ + +using System; +using OpenRa.Traits; + +namespace OpenRa.Traits +{ + class ScreenShakerInfo : ITraitInfo + { + public object Create( Actor self ) { return new ScreenShaker( self ); } + } + + public class ScreenShaker : ITick + { + int ticks = 0; + + public ScreenShaker (Actor self){} + + public void Tick (Actor self) + { + Game.viewport.Scroll(getScrollOffset()); + ticks++; + } + + //public void registerShakeEffect(float2 position, int time) + //{ + //} + + public float2 getScrollOffset() + { + int xFreq = 4; + int yFreq = 5; + int intensity = 3; + + return intensity * new float2( (float) Math.Sin((ticks*2*Math.PI)/xFreq) , (float) Math.Cos((ticks*2*Math.PI)/yFreq)); + } + + } +} diff --git a/mods/ra/rules.yaml b/mods/ra/rules.yaml index 451f38acf4..545e69383f 100644 --- a/mods/ra/rules.yaml +++ b/mods/ra/rules.yaml @@ -61,6 +61,7 @@ Player: SpawnDefaultUnits: World: + ScreenShaker: WaterPaletteRotation: ChronoshiftPaletteEffect: LightPaletteRotator: