Example #1
0
 public GfxStr(string font, string text, Point pos, int edge)
 {
     Texture = Game1.content.Load <SpriteFont>(font);
     Text    = text;
     Edge    = edge;
     Bound   = new Rectangle(pos, Method2D.VtP(Texture.MeasureString(Text)) + new Point(2 * Edge, 2 * Edge));
 }
Example #2
0
        public void MoveByVector(Point v, double speed) // 벡터 v의 방향으로 speed의 속도로 등속운동한다.
        {
            double N     = Method2D.Distance(new Point(0, 0), v);
            int    Dis_X = (int)(v.X * speed / N);
            int    Dis_Y = (int)(v.Y * speed / N);

            Pos = new Point(Bound.X + Dis_X, Bound.Y + Dis_Y);
        }
Example #3
0
        /// <summary>
        /// 만약 Gfx의 rotate값이 0이 아닐 경우, RContains 함수가 정확합니다. 다만, 보시다시피, 비싼 계산을 요구합니다.
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        public bool RContains(Point p)
        {
            Vector2 v  = Method2D.PtV(p);
            Point   RO = new Point(Pos.X + (ROrigin.X * Bound.Width) / Texture.Width, Pos.Y + (ROrigin.Y * Bound.Height) / Texture.Height); //실제 회전중심의 위치를 잡습니다.

            v = Vector2.Transform(v, Matrix2D.Rotate(RO, -Rotate));
            return(Bound.Contains(Method2D.VtP(v)));
        }
Example #4
0
        public void MoveByVector(Point p, double speed)
        {
            double N     = Method2D.Distance(new Point(0, 0), p);
            int    Dis_X = (int)(p.X * speed / N);
            int    Dis_Y = (int)(p.Y * speed / N);

            Pos = new Point(Pos.X + Dis_X, Pos.Y + Dis_Y);

            Align();
        }
Example #5
0
        public void MoveTo(int x, int y, double speed)          // (x,y)를 향해 등속운동.
        {
            double N = Method2D.Distance(new Point(x, y), Pos); //두 물체 사이의 거리

            if (N < speed)                                      //거리가 스피드보다 가까우면 도착.
            {
                Pos = new Point(x, y);
                return;
            }

            Vector2 v = new Vector2(x - Pos.X, y - Pos.Y);

            v.Normalize();
            v   = new Vector2((float)speed * v.X, (float)speed * v.Y);
            Pos = new Point(Bound.X + (int)(v.X), Bound.Y + (int)(v.Y));
        }
Example #6
0
 public static void Draw(Gfx2D gfx, Color c) => spriteBatch.Draw(gfx.Texture, new Rectangle(gfx.Pos.X + (gfx.ROrigin.X * gfx.Bound.Width) / gfx.Texture.Width, gfx.Pos.Y + (gfx.ROrigin.Y * gfx.Bound.Height) / gfx.Texture.Height, gfx.Bound.Width, gfx.Bound.Height), null, c, gfx.Rotate, Method2D.PtV(gfx.ROrigin), SpriteEffects.None, 0);