Exemplo n.º 1
0
        public override System.Collections.ArrayList GeneratePoints(EPoint ptStart)
        {
            //Calculate curve's control and end anchor points:
            //Control point is the start point + offset to control
            EPoint ptControl = ptStart + this._ptControl;
            //End point is control point + offset to anchor:
            EPoint ptAnchor = ptControl + this._ptAnchor;

            //now calculate two bezier handles for the curve (Flash uses quadratic beziers, GDI+ uses cubic).
            //The two handles are 2/3rds from each endpoint to the control point.
            EPointF diff = (ptControl-ptStart).ToEPointF();
            EPointF ctrl1 = EPointF.FromLengthAndAngle(diff.Length*2/3, diff.Angle) + ptStart.ToEPointF();
            //EPointF ctrl1 = ptStart.ToEPointF() + diff/2f;
            //EPointF ctrl1 = new EPointF(ptStart.X + (1f * (ptControl.X - ptStart.X) / 2f), ptStart.Y + (1f * (ptControl.Y - ptStart.Y) / 2f));

            diff = (ptControl-ptAnchor).ToEPointF();
            EPointF ctrl2 = EPointF.FromLengthAndAngle(diff.Length*2/3, diff.Angle) + ptAnchor.ToEPointF();
            //diff = (ptAnchor-ptControl).ToEPointF();
            //EPointF ctrl2 = ptControl.ToEPointF() + diff/2f;
            //ctrl2 = new EPointF(ptControl.X + (1f * (ptAnchor.X - ptControl.X) / 2f), ptControl.Y + (1f * (ptAnchor.Y - ptControl.Y) / 2f));

            System.Collections.ArrayList pts = new System.Collections.ArrayList();
            pts.Add(ptStart.ToEPointF());
            pts.Add(ctrl1);
            pts.Add(ctrl2);
            pts.Add(ptAnchor.ToEPointF());
            return pts;
        }
Exemplo n.º 2
0
        public override System.Collections.ArrayList GeneratePoints(EPoint ptStart)
        {
            //Calculate curve's control and end anchor points:
            //Control point is the start point + offset to control
            EPoint ptControl = ptStart + this._ptControl;
            //End point is control point + offset to anchor:
            EPoint ptAnchor = ptControl + this._ptAnchor;

            //now calculate two bezier handles for the curve (Flash uses quadratic beziers, GDI+ uses cubic).
            //The two handles are 2/3rds from each endpoint to the control point.
            EPointF diff  = (ptControl - ptStart).ToEPointF();
            EPointF ctrl1 = EPointF.FromLengthAndAngle(diff.Length * 2 / 3, diff.Angle) + ptStart.ToEPointF();

            //EPointF ctrl1 = ptStart.ToEPointF() + diff/2f;
            //EPointF ctrl1 = new EPointF(ptStart.X + (1f * (ptControl.X - ptStart.X) / 2f), ptStart.Y + (1f * (ptControl.Y - ptStart.Y) / 2f));

            diff = (ptControl - ptAnchor).ToEPointF();
            EPointF ctrl2 = EPointF.FromLengthAndAngle(diff.Length * 2 / 3, diff.Angle) + ptAnchor.ToEPointF();

            //diff = (ptAnchor-ptControl).ToEPointF();
            //EPointF ctrl2 = ptControl.ToEPointF() + diff/2f;
            //ctrl2 = new EPointF(ptControl.X + (1f * (ptAnchor.X - ptControl.X) / 2f), ptControl.Y + (1f * (ptAnchor.Y - ptControl.Y) / 2f));

            System.Collections.ArrayList pts = new System.Collections.ArrayList();
            pts.Add(ptStart.ToEPointF());
            pts.Add(ctrl1);
            pts.Add(ctrl2);
            pts.Add(ptAnchor.ToEPointF());
            return(pts);
        }
Exemplo n.º 3
0
 private void m_resizeCorner_MouseEvent(Sprite sender, System.Windows.Forms.MouseEventArgs e, MouseEventType t)
 {
     if (t == Sprite.MouseEventType.StillDown)
     {
         EPoint pntDiff = new EPoint(e.X - m_resizeCorner.MouseLastLoc.X, e.Y - m_resizeCorner.MouseLastLoc.Y);
         Rect = new ERectangleF(Rect.Location, Rect.Size + pntDiff.ToEPointF());              //SizeF(Rect.Size.Width+pntDiff.X,Rect.Size.Height+pntDiff.Y));
     }
 }
Exemplo n.º 4
0
        private void moveSprite_MouseEvent(Sprite sender, System.Windows.Forms.MouseEventArgs e, Endogine.Sprite.MouseEventType t)
        {
            if (t == Endogine.Sprite.MouseEventType.StillDown)
            {
                EPointF pntNow      = new EPointF(e.X, e.Y);
                EPointF gridSpacing = new EPointF(30, 30);
                EPointF gridOffset  = new EPointF(0, 0);
                if (System.Windows.Forms.Control.ModifierKeys == System.Windows.Forms.Keys.Control) //Snap to grid
                {
                    pntNow -= _gridOffset.ToEPointF();
                    pntNow /= _gridSpacing.ToEPointF();
                    pntNow  = new EPointF((float)Math.Round(pntNow.X), (float)Math.Round(pntNow.Y)) * _gridSpacing.ToEPointF();
                    pntNow += _gridOffset.ToEPointF();
                }
                EPointF pntDiff = pntNow - sender.MouseDownLoc.ToEPointF();

                if (System.Windows.Forms.Control.ModifierKeys == System.Windows.Forms.Keys.Shift)                 //Force horizontal/vertical movement
                {
                    if ((pntDiff.Angle > (float)Math.PI / 4 && pntDiff.Angle < 3 * (float)Math.PI / 4) ||
                        (pntDiff.Angle < -(float)Math.PI / 4 && pntDiff.Angle > -3 * (float)Math.PI / 4))
                    {
                        pntDiff *= new EPointF(1, 0);
                    }
                    else
                    {
                        pntDiff *= new EPointF(0, 1);
                    }
                }
                this.m_sp.Loc = pntDiff + this.pntStartMove;
                this.Update();
            }
            else if (t == Endogine.Sprite.MouseEventType.Down)
            {
                this.pntStartMove = this.m_sp.Loc.Copy();
            }
        }
Exemplo n.º 5
0
 private void treeView1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (xmlNodeMouseDownOn != null)
     {
         EPoint pntDiff = this.mouseDownLoc - new EPoint(e.X, e.Y);
         if (!m_bStartedDragging && pntDiff.ToEPointF().Length > 5)
         {
             m_bStartedDragging = true;
             if (XmlNodeMouseStartDrag != null)
             {
                 XmlNodeMouseStartDrag(this, xmlNodeMouseDownOn);
             }
         }
     }
 }
Exemplo n.º 6
0
        public Matrix CreateMatrix(ERectangleF rctDrawTarget, float rotation, EPoint regPoint, EPoint sourceRectSize)
        {
            System.Drawing.Rectangle rctView = this._device.ScissorRectangle; //this._device.Viewport

            Matrix  m         = Matrix.Scaling(rctDrawTarget.Width, rctDrawTarget.Height, 1);
            EPointF pntRegOff = regPoint.ToEPointF() / new EPointF(sourceRectSize.X, sourceRectSize.Y) * new EPointF(rctDrawTarget.Width, rctDrawTarget.Height);

            m.Multiply(Matrix.Translation(-pntRegOff.X, pntRegOff.Y, 0));
            m.Multiply(Matrix.RotationZ(-rotation));
            m.Multiply(Matrix.Translation(pntRegOff.X, -pntRegOff.Y, 0));

            EPointF pntLoc = new EPointF(rctDrawTarget.X - rctView.Width / 2, rctDrawTarget.Y - rctView.Height / 2);

            m.Multiply(Matrix.Translation(pntLoc.X, -pntLoc.Y, 0f));
            m.M43 = 9000f;

            return(m);
        }
Exemplo n.º 7
0
        public GameMain()
        {
            m_starField  = new StarField();
            m_player     = new Player(this);
            m_aAsteroids = new ArrayList();

            //The aOKLocs is generated so no asteroids will appear close to the ship
            EPoint     pntStageSize     = EndogineHub.Instance.Stage.Size;
            ArrayList  aOKLocs          = new ArrayList();
            EPoint     pntNumPositions  = new EPoint(6, 6);
            ERectangle rctFreePositions = new ERectangle(2, 2, 2, 2);

            for (int y = 0; y < pntNumPositions.Y; y++)
            {
                if (y >= rctFreePositions.Y && y < rctFreePositions.Bottom)
                {
                    y += rctFreePositions.Height;
                }
                for (int x = 0; x < pntNumPositions.X; x++)
                {
                    if (x >= rctFreePositions.X && x < rctFreePositions.Right)
                    {
                        x += rctFreePositions.Width;
                    }
                    EPoint pnt = new EPoint(x, y) * pntStageSize / (pntNumPositions - new EPoint(1, 1)) - pntStageSize / 2;;
                    aOKLocs.Add(pnt);
                }
            }

            Random rnd = new Random();

            for (int i = 0; i < 4; i++)
            {
                Asteroid asteroid = new Asteroid(this, 3);
                asteroid.Velocity = new EPointF((float)rnd.NextDouble() - 0.5f, (float)rnd.NextDouble() - 0.5f);

                int    nRndPos = rnd.Next(aOKLocs.Count);
                EPoint pntLoc  = (EPoint)aOKLocs[nRndPos];
                aOKLocs.RemoveAt(nRndPos);
                asteroid.Loc = pntLoc.ToEPointF();
            }
        }
Exemplo n.º 8
0
        public Matrix CreateMatrix(ERectangleF rctDrawTarget, float rotation, EPoint regPoint, EPoint sourceRectSize)
        {
            System.Drawing.Rectangle rctView = this._device.ScissorRectangle; //this._device.Viewport

            Matrix m = Matrix.Scaling(rctDrawTarget.Width, rctDrawTarget.Height, 1);
            EPointF pntRegOff = regPoint.ToEPointF() / new EPointF(sourceRectSize.X, sourceRectSize.Y) * new EPointF(rctDrawTarget.Width, rctDrawTarget.Height);
            m.Multiply(Matrix.Translation(-pntRegOff.X, pntRegOff.Y, 0));
            m.Multiply(Matrix.RotationZ(-rotation));
            m.Multiply(Matrix.Translation(pntRegOff.X, -pntRegOff.Y, 0));

            EPointF pntLoc = new EPointF(rctDrawTarget.X - rctView.Width / 2, rctDrawTarget.Y - rctView.Height / 2);
            m.Multiply(Matrix.Translation(pntLoc.X, -pntLoc.Y, 0f));
            m.M43 = 9000f;

            return m;
        }
Exemplo n.º 9
0
        private EPoint GetPointBetween(EPoint pt1, EPoint pt2, float ratio)
        {
            EPointF ptMid = (pt2 - pt1).ToEPointF() * ratio + pt1.ToEPointF();

            return(ptMid.ToEPoint());
        }
Exemplo n.º 10
0
 private EPoint GetPointBetween(EPoint pt1, EPoint pt2, float ratio)
 {
     EPointF ptMid = (pt2-pt1).ToEPointF()*ratio + pt1.ToEPointF();
     return ptMid.ToEPoint();
 }