public void Update( GameTime gameTime, Camera camera ) { movementTime += (float)gameTime.ElapsedGameTime.TotalSeconds; if( movementTime >= movementDuration ) ChooseTargetPosition(); float fraction = movementTime / movementDuration; float currentXZ = camera.CurrentXZ + MathHelper.SmoothStep( previousXZ, targetXZ, fraction ); float currentY = camera.CurrentY + MathHelper.SmoothStep( previousY, targetY, fraction ); position.X = (float)Math.Sin( currentXZ ); position.Y = (float)Math.Sin( currentY ); position.Z = (float)Math.Cos( currentXZ ); position *= LightDistance; }
public Board( int sizeX, int sizeY, bool twoSided ) { this.twoSided = twoSided; this.width = sizeX; this.height = sizeY; camera = new Camera( (float)Math.Max( sizeX, sizeY ) * 400.0f / 5.0f ); nextPictureSet = PictureDatabase.GetNextPictureSet( twoSided ? 2 : 1 ); this.layout = new Chip[ Width, Height ]; this.boardPositionMatrices = new Matrix[ Width, Height ]; for( int y = 0; y < Height; y++ ) { for( int x = 0; x < Width; x++ ) { Chip chip = new Chip(); chips.Add( chip ); chip.XPosition = x; chip.YPosition = y; layout[ x, y ] = chip; Vector2 chipTexCoordFactor = new Vector2( 1.0f / Width, 1.0f / Height ); chip.TexCoordScale = chipTexCoordFactor; chip.TexCoordTranslationFront = new Vector2( ( x * chipTexCoordFactor.X ), ( ( Height - 1 ) - y ) * chipTexCoordFactor.Y ); chip.TexCoordTranslationBack = new Vector2( ( ( Width - 1 ) - x ) * chipTexCoordFactor.X, ( ( Height - 1 ) - y ) * chipTexCoordFactor.Y ); } } emptyX = RandomHelper.Random.Next( 0, Width ); emptyY = RandomHelper.Random.Next( 0, Height ); Chip removed = layout[ emptyX, emptyY ]; chips.Remove( removed ); layout[ emptyX, emptyY ] = null; }