示例#1
0
 public static void angleMove(GameObject gameObject)
 {
     float vx = 0;
     float vy = 0;
     if (gameObject.Body.LinearVelocity.X > gameObject.MaxSpeed * -1 && gameObject.Body.LinearVelocity.X < gameObject.MaxSpeed)
         vx = (float)(gameObject.Acceleration * Math.Sin(gameObject.Body.Rotation));
     if (gameObject.Body.LinearVelocity.Y > gameObject.MaxSpeed * -1 && gameObject.Body.LinearVelocity.Y < gameObject.MaxSpeed)
         vy = (float)(gameObject.Acceleration * Math.Cos(gameObject.Body.Rotation)) * -1;
     gameObject.Body.LinearVelocity += new Vector2(vx, vy);
 }
示例#2
0
        public static void convertToPolygon(GameObject gameObject)
        {
            uint[] data = new uint[gameObject.Texture.Width * gameObject.Texture.Height];
            gameObject.Texture.GetData(data);
            Vertices verts = PolygonTools.CreatePolygon(data, gameObject.Texture.Width, false);

            Vector2 centroid = -verts.GetCentroid();
            verts.Translate(ref centroid);
            gameObject.Origin = -centroid;

            verts = SimplifyTools.ReduceByDistance(verts, 4f);

            List<Vertices> list = BayazitDecomposer.ConvexPartition(verts);
            gameObject.Body = BodyFactory.CreateCompoundPolygon(GameControl.world, list, 1f);
        }
示例#3
0
 public static void twoAxisMove(GameObject gameObject)
 {
     gameObject.Body.Position += gameObject.Speed;
 }