Basic ScreenShaker

This commit is contained in:
alzeih
2010-02-27 14:51:03 +13:00
parent 3dc3e118fc
commit 9cecf8e8ab
3 changed files with 41 additions and 1 deletions

View File

@@ -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));
}
}
}