コード例 #1
0
ファイル: cannonfield.cs プロジェクト: KDE/qyoto
 private QRect targetRect()
 {
     QRect result = new QRect(0, 0, 20, 10);
     result.MoveCenter(new QPoint(target.X(), Height() - 1 - target.Y()));
     return result;
 }
コード例 #2
0
ファイル: cannonfield.cs プロジェクト: KDE/qyoto
    private QRect shotRect()
    {
        const double gravity = 4;

        double time = timerCount / 20.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;
    }