git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1329 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
@@ -13,6 +13,6 @@ namespace OpenRa.Game
|
||||
public abstract float2 RenderLocation { get; }
|
||||
public int palette;
|
||||
public abstract Sprite[] CurrentImages { get; }
|
||||
public virtual void Tick(Game game, double t) { }
|
||||
public virtual void Tick(Game game, int t) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,10 +59,10 @@ namespace OpenRa.Game
|
||||
};
|
||||
}
|
||||
|
||||
double timeUntilNextFrame;
|
||||
int timeUntilNextFrame;
|
||||
|
||||
Action<double> tickFunc;
|
||||
public void Tick( double t )
|
||||
Action<int> tickFunc;
|
||||
public void Tick( int t )
|
||||
{
|
||||
if( tickAlways )
|
||||
tickFunc( t );
|
||||
@@ -71,8 +71,8 @@ namespace OpenRa.Game
|
||||
timeUntilNextFrame -= t;
|
||||
while( timeUntilNextFrame <= 0 )
|
||||
{
|
||||
tickFunc( 40.0 / 1000.0 );
|
||||
timeUntilNextFrame += ( 40.0 / 1000.0 ); // 25 fps == 40 ms
|
||||
tickFunc( 40 );
|
||||
timeUntilNextFrame += 40; // 25 fps == 40 ms
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace OpenRa.Game
|
||||
animation.PlayThen( "make", delegate { animation.Play( "idle" ); } );
|
||||
}
|
||||
|
||||
public override void Tick( Game game, double t )
|
||||
public override void Tick( Game game, int t )
|
||||
{
|
||||
animation.Tick( t );
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ namespace OpenRa.Game
|
||||
{
|
||||
public readonly World world;
|
||||
public readonly Map map;
|
||||
public readonly SpriteRenderer SpriteRenderer;
|
||||
public readonly TreeCache treeCache;
|
||||
public readonly TerrainRenderer terrain;
|
||||
public readonly Viewport viewport;
|
||||
@@ -18,7 +17,6 @@ namespace OpenRa.Game
|
||||
|
||||
public Game( string mapName, Renderer renderer, int2 clientSize )
|
||||
{
|
||||
SheetBuilder.Initialize( renderer.Device );
|
||||
map = new Map( new IniFile( FileSystem.Open( mapName ) ) );
|
||||
FileSystem.Mount( new Package( "../../../" + map.Theater + ".mix" ) );
|
||||
|
||||
@@ -35,5 +33,15 @@ namespace OpenRa.Game
|
||||
|
||||
network = new Network();
|
||||
}
|
||||
|
||||
public void Tick()
|
||||
{
|
||||
viewport.DrawRegions( this );
|
||||
}
|
||||
|
||||
public void Issue( IOrder order )
|
||||
{
|
||||
order.Apply();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ namespace OpenRa.Game
|
||||
|
||||
bool windowed = !settings.GetValue("fullscreeen", false);
|
||||
renderer = new Renderer(this, GetResolution(settings), windowed);
|
||||
SheetBuilder.Initialize( renderer.Device );
|
||||
|
||||
game = new Game( settings.GetValue( "map", "scm12ea.ini" ), renderer, new int2( ClientSize ) );
|
||||
|
||||
@@ -60,7 +61,7 @@ namespace OpenRa.Game
|
||||
{
|
||||
while (Created && Visible)
|
||||
{
|
||||
game.viewport.DrawRegions( game );
|
||||
game.Tick();
|
||||
Application.DoEvents();
|
||||
}
|
||||
}
|
||||
@@ -75,7 +76,8 @@ namespace OpenRa.Game
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
float2 xy = ( 1 / 24.0f ) * ( new float2( e.Location ) + game.viewport.Location );
|
||||
game.world.myUnit.Order( new int2( (int)xy.X, (int)xy.Y ) ).Apply();
|
||||
IOrder order = game.world.myUnit.Order( new int2( (int)xy.X, (int)xy.Y ) );
|
||||
game.Issue( order );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace OpenRa.Game
|
||||
|
||||
public void AcceptDeployOrder()
|
||||
{
|
||||
nextOrder = delegate( Game game, double t )
|
||||
nextOrder = delegate( Game game, int t )
|
||||
{
|
||||
if( Turn( 12 ) )
|
||||
return;
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace OpenRa.Game
|
||||
protected int2 fromCell, toCell;
|
||||
protected int moveFraction, moveFractionTotal;
|
||||
|
||||
protected delegate void TickFunc( Game game, double t );
|
||||
protected delegate void TickFunc( Game game, int t );
|
||||
protected TickFunc currentOrder = null;
|
||||
protected TickFunc nextOrder = null;
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace OpenRa.Game
|
||||
|
||||
const int Speed = 6;
|
||||
|
||||
public override void Tick( Game game, double t )
|
||||
public override void Tick( Game game, int t )
|
||||
{
|
||||
animation.Tick( t );
|
||||
if( currentOrder == null && nextOrder != null )
|
||||
@@ -69,7 +69,7 @@ namespace OpenRa.Game
|
||||
|
||||
public void AcceptMoveOrder( int2 destination )
|
||||
{
|
||||
nextOrder = delegate( Game game, double t )
|
||||
nextOrder = delegate( Game game, int t )
|
||||
{
|
||||
if( nextOrder != null )
|
||||
destination = toCell;
|
||||
@@ -77,7 +77,7 @@ namespace OpenRa.Game
|
||||
if( Turn( GetFacing( toCell - fromCell ) ) )
|
||||
return;
|
||||
|
||||
moveFraction += (int)( t * ( Speed * 100 ) );
|
||||
moveFraction += t * Speed;
|
||||
if( moveFraction < moveFractionTotal )
|
||||
return;
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace OpenRa.Game
|
||||
toCell = res[ res.Count - 1 ];
|
||||
|
||||
int2 dir = toCell - fromCell;
|
||||
moveFractionTotal = ( dir.X != 0 && dir.Y != 0 ) ? 250 : 200;
|
||||
moveFractionTotal = ( dir.X != 0 && dir.Y != 0 ) ? 2500 : 2000;
|
||||
}
|
||||
else
|
||||
destination = toCell;
|
||||
|
||||
@@ -27,12 +27,12 @@ namespace OpenRa.Game
|
||||
public void Remove( Actor a ) { actors.Remove( a ); }
|
||||
public void AddFrameEndTask( Action<World> a ) { frameEndActions.Add( a ); }
|
||||
|
||||
double lastTime = Environment.TickCount / 1000.0;
|
||||
int lastTime = Environment.TickCount;
|
||||
|
||||
void Draw( Game game )
|
||||
{
|
||||
double t = Environment.TickCount / 1000.0;
|
||||
double dt = t - lastTime;
|
||||
int t = Environment.TickCount;
|
||||
int dt = t - lastTime;
|
||||
lastTime = t;
|
||||
|
||||
Range<float2> range = new Range<float2>(viewport.Location, viewport.Location + viewport.Size);
|
||||
|
||||
Reference in New Issue
Block a user