Пример #1
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);
    }