コード例 #1
0
ファイル: Calculator.cs プロジェクト: Lukasy14/game-Alliance
        public static GsVector ComputeProjectileDirection(float angle)
        {
            GsVector v         = new GsVector(1, 0);
            GsMatrix rotMatrix = GsMatrix.CreateRotationZ(angle);

            return(GsVector.Transform(v, rotMatrix));
        }
コード例 #2
0
ファイル: Sprite.cs プロジェクト: Lukasy14/game-Alliance
 /// <summary></summary>
 public GsPolygon GetHull(GsVector offset)
 {
     GsVector[] polygon = GetImageHull();
     if (hullCache == null || Bounds != previousBounds)
     {
         GsMatrix transform = CreateTransform(GetTextureDrawData(offset));
         hullCache      = new GsPolygon(polygon, transform);
         previousBounds = Bounds;
     }
     return(hullCache);
 }
コード例 #3
0
ファイル: Sprite.cs プロジェクト: Lukasy14/game-Alliance
        /// <summary></summary>
        protected virtual GsMatrix CreateTransform(ImageParams data)
        {
            // create the matrix for transforming the center
            GsMatrix transform =
                GsMatrix.CreateTranslation(-data.Origin.X, -data.Origin.Y, 0) *
                GsMatrix.CreateRotationZ(Orientation) *
                GsMatrix.CreateScale(data.Scale.X, data.Scale.Y, 1f) *
                GsMatrix.CreateTranslation(data.Position.X, data.Position.Y, 0);

            // return the transform
            return(transform);
        }
コード例 #4
0
ファイル: Sprite.cs プロジェクト: Lukasy14/game-Alliance
        /// <summary></summary>
        protected virtual GsVector GetCenter(GsVector offset)
        {
            // get the drawing data
            ImageParams data = GetTextureDrawData(offset);

            // get the center of the image
            GsVector center = data.ImageSize.ToVector() / 2f;

            // compute the transform
            GsMatrix transform = CreateTransform(data);

            // return the center transformated
            return(GsVector.Transform(center, transform));
        }