From 1e9fa8e06de5da7fcc268e9cccb2d6b21c5f53a3 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sat, 20 Jul 2024 20:15:52 +0900 Subject: Rename graphics class nt* related files to equivalent tq* (part 2) Signed-off-by: Michele Calgaro --- doc/html/tutorial1-11.html | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'doc/html/tutorial1-11.html') diff --git a/doc/html/tutorial1-11.html b/doc/html/tutorial1-11.html index 5ea46d920..1385646c1 100644 --- a/doc/html/tutorial1-11.html +++ b/doc/html/tutorial1-11.html @@ -64,7 +64,7 @@ using a TQTimer. void paintShot( TQPainter * );

This private function paints the shot. -

        TQRect shotRect() const;
+

        TQRect shotRect() const;
 

This private function returns the shot's enclosing rectangle if one is in the air; otherwise the returned rectangle is undefined. @@ -116,15 +116,15 @@ is reset to zero. The shoot_ang and shoot_f are set to the cur cannon angle and force. Finally, we start the timer.

    void CannonField::moveShot()
     {
-        TQRegion r( shotRect() );
+        TQRegion r( shotRect() );
         timerCount++;
 
-        TQRect shotR = shotRect();
+        TQRect shotR = shotRect();
 
-        if ( shotR.x() > width() || shotR.y() > height() )
+        if ( shotR.x() > width() || shotR.y() > height() )
             autoShootTimer->stop();
         else
-            r = r.unite( TQRegion( shotR ) );
+            r = r.unite( TQRegion( shotR ) );
         repaint( r );
     }
 
@@ -132,7 +132,7 @@ cannon angle and force. Finally, we start the timer. milliseconds when the TQTimer fires.

Its tasks are to compute the new position, repaint the screen with the shot in the new position, and if necessary, stop the timer. -

First we make a TQRegion that holds the old shotRect(). A TQRegion +

First we make a TQRegion that holds the old shotRect(). A TQRegion is capable of holding any sort of region, and we'll use it here to simplify the painting. ShotRect() returns the rectangle where the shot is now - it is explained in detail later. @@ -145,13 +145,13 @@ stop the timer or we add the new shotRect() to the TQRegion. for just the one or two rectangles that need updating.

    void CannonField::paintEvent( TQPaintEvent *e )
     {
-        TQRect updateR = e->rect();
+        TQRect updateR = e->rect();
         TQPainter p( this );
 
-        if ( updateR.intersects( cannonRect() ) )
+        if ( updateR.intersects( cannonRect() ) )
             paintCannon( &p );
         if ( autoShootTimer->isActive() &&
-             updateR.intersects( shotRect() ) )
+             updateR.intersects( shotRect() ) )
             paintShot( &p );
     }
 
@@ -179,13 +179,13 @@ the paintEvent() from the previous chapter. double velx = velocity*cos( radians ); double vely = velocity*sin( radians ); - double x0 = ( barrelRect.right() + 5 )*cos(radians); - double y0 = ( barrelRect.right() + 5 )*sin(radians); + double x0 = ( barrelRect.right() + 5 )*cos(radians); + double y0 = ( barrelRect.right() + 5 )*sin(radians); double x = x0 + velx*time; double y = y0 + vely*time - 0.5*gravity*time*time; - TQRect r = TQRect( 0, 0, 6, 6 ); - r.moveCenter( TQPoint( tqRound(x), height() - 1 - tqRound(y) ) ); + TQRect r = TQRect( 0, 0, 6, 6 ); + r.moveCenter( TQPoint( tqRound(x), height() - 1 - tqRound(y) ) ); return r; }
@@ -197,7 +197,7 @@ movement in a gravity field. For simplicity, we've chosen to disregard any Einsteinian effects.

We calculate the center point in a coordinate system where y coordinates increase upward. After we have calculated the center -point, we construct a TQRect with size 6x6 and move its center point to +point, we construct a TQRect with size 6x6 and move its center point to the point calculated above. In the same operation we convert the point into the widget's coordinate system (see The Coordinate System). -- cgit v1.2.1