Exemple #1
0
    private QRect TargetRect()
    {
        QRect result = new QRect(0, 0, 20, 10);

        result.MoveCenter(new QPoint(target.X(), Height() - 1 - target.Y()));
        return(result);
    }
Exemple #2
0
        public void TestMoveCenter()
        {
            var s = new QRect();

            s.X      = 50;
            s.Y      = 100;
            s.Width  = 500;
            s.Height = 600;

            s.MoveCenter(new QPoint(600, 600));

            Assert.AreEqual(500, s.Width);
            Assert.AreEqual(600, s.Height);
            Assert.AreEqual(600 - 250 + 1, s.X);
            Assert.AreEqual(600 - 300 + 1, s.Y);
        }
Exemple #3
0
    private QRect ShotRect()
    {
        const double gravity = 4;

        double time     = timerCount / 4.0;
        double velocity = shootForce;
        double radians  = shootAngle * 3.14159265 / 180;

        double velx = velocity * Math.Cos(radians);
        double vely = velocity * Math.Sin(radians);
        double x0   = (barrelRect.Right() + 5) * Math.Cos(radians);
        double y0   = (barrelRect.Right() + 5) * Math.Sin(radians);
        double x    = x0 + velx * time;
        double y    = y0 + vely * time - 0.5 * gravity * time * time;

        QRect result = new QRect(0, 0, 6, 6);

        result.MoveCenter(new QPoint((int)Math.Round(x), Height() - 1 - (int)Math.Round(y)));
        return(result);
    }
Exemple #4
0
        public void TestMoveCenter()
        {
            var s = new QRect();
            s.X = 50;
            s.Y = 100;
            s.Width = 500;
            s.Height = 600;

            s.MoveCenter(new QPoint(600, 600));

            Assert.AreEqual(500, s.Width);
            Assert.AreEqual(600, s.Height);
            Assert.AreEqual(600 - 250 + 1, s.X);
            Assert.AreEqual(600 - 300 + 1, s.Y);
        }