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/t14-cannon-cpp.html | 80 ++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 40 deletions(-) (limited to 'doc/html/t14-cannon-cpp.html') diff --git a/doc/html/t14-cannon-cpp.html b/doc/html/t14-cannon-cpp.html index f9849a2d6..03fdc8fb6 100644 --- a/doc/html/t14-cannon-cpp.html +++ b/doc/html/t14-cannon-cpp.html @@ -41,7 +41,7 @@ body { background: #ffffff; color: black; } #include "cannon.h" #include <tqtimer.h> #include <tqpainter.h> -#include <ntqpixmap.h> +#include <tqpixmap.h> #include <tqdatetime.h> #include <math.h> @@ -112,10 +112,10 @@ void CannonField::newTarget() TQTime midnight( 0, 0, 0 ); srand( midnight.secsTo(TQTime::currentTime()) ); } - TQRegion r( targetRect() ); + TQRegion r( targetRect() ); target = TQPoint( 200 + rand() % 190, 10 + rand() % 255 ); - repaint( r.unite( targetRect() ) ); + repaint( r.unite( targetRect() ) ); } void CannonField::setGameOver() @@ -139,22 +139,22 @@ void CannonField::restartGame() void CannonField::moveShot() { - TQRegion r( shotRect() ); + TQRegion r( shotRect() ); timerCount++; - TQRect shotR = shotRect(); + TQRect shotR = shotRect(); - if ( shotR.intersects( targetRect() ) ) { + if ( shotR.intersects( targetRect() ) ) { autoShootTimer->stop(); emit hit(); emit canShoot( TRUE ); - } else if ( shotR.x() > width() || shotR.y() > height() || - shotR.intersects(barrierRect()) ) { + } else if ( shotR.x() > width() || shotR.y() > height() || + shotR.intersects(barrierRect()) ) { autoShootTimer->stop(); emit missed(); emit canShoot( TRUE ); } else { - r = r.unite( TQRegion( shotR ) ); + r = r.unite( TQRegion( shotR ) ); } repaint( r ); @@ -174,12 +174,12 @@ void CannonField::mouseMoveEvent( TQPoint pnt = e->pos(); - if ( pnt.x() <= 0 ) - pnt.setX( 1 ); - if ( pnt.y() >= height() ) - pnt.setY( height() - 1 ); - double rad = atan(((double)rect().bottom()-pnt.y())/pnt.x()); + TQPoint pnt = e->pos(); + if ( pnt.x() <= 0 ) + pnt.setX( 1 ); + if ( pnt.y() >= height() ) + pnt.setY( height() - 1 ); + double rad = atan(((double)rect().bottom()-pnt.y())/pnt.x()); setAngle( tqRound ( rad*180/3.14159265 ) ); } @@ -193,7 +193,7 @@ void CannonField::mouseReleaseEventpaintEvent( TQPaintEvent *e ) { - TQRect updateR = e->rect(); + TQRect updateR = e->rect(); TQPainter p( this ); if ( gameEnded ) { @@ -201,13 +201,13 @@ void CannonField::paintEvent( setFont( TQFont( "Courier", 48, TQFont::Bold ) ); p.drawText( rect(), AlignCenter, "Game Over" ); } - if ( updateR.intersects( cannonRect() ) ) + if ( updateR.intersects( cannonRect() ) ) paintCannon( &p ); - if ( updateR.intersects( barrierRect() ) ) + if ( updateR.intersects( barrierRect() ) ) paintBarrier( &p ); - if ( isShooting() && updateR.intersects( shotRect() ) ) + if ( isShooting() && updateR.intersects( shotRect() ) ) paintShot( &p ); - if ( !gameEnded && updateR.intersects( targetRect() ) ) + if ( !gameEnded && updateR.intersects( targetRect() ) ) paintTarget( &p ); } @@ -233,32 +233,32 @@ void CannonField::paintBarrier( TQPa p->drawRect( barrierRect() ); } -const TQRect barrelRect(33, -4, 15, 8); +const TQRect barrelRect(33, -4, 15, 8); void CannonField::paintCannon( TQPainter *p ) { - TQRect cr = cannonRect(); - TQPixmap pix( cr.size() ); - pix.fill( this, cr.topLeft() ); + TQRect cr = cannonRect(); + TQPixmap pix( cr.size() ); + pix.fill( this, cr.topLeft() ); TQPainter tmp( &pix ); tmp.setBrush( blue ); tmp.setPen( NoPen ); - tmp.translate( 0, pix.height() - 1 ); + tmp.translate( 0, pix.height() - 1 ); tmp.drawPie( TQRect( -35,-35, 70, 70 ), 0, 90*16 ); tmp.rotate( -ang ); tmp.drawRect( barrelRect ); tmp.end(); - p->drawPixmap( cr.topLeft(), pix ); + p->drawPixmap( cr.topLeft(), pix ); } TQRect CannonField::cannonRect() const { - TQRect r( 0, 0, 50, 50 ); - r.moveBottomLeft( rect().bottomLeft() ); + TQRect r( 0, 0, 50, 50 ); + r.moveBottomLeft( rect().bottomLeft() ); return r; } @@ -273,21 +273,21 @@ TQRect CannonField::shotRect() const 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; } TQRect CannonField::targetRect() const { - TQRect r( 0, 0, 20, 10 ); - r.moveCenter( TQPoint(target.x(),height() - 1 - target.y()) ); + TQRect r( 0, 0, 20, 10 ); + r.moveCenter( TQPoint(target.x(),height() - 1 - target.y()) ); return r; } @@ -298,13 +298,13 @@ TQRect CannonField::barrierRect() const } -bool CannonField::barrelHit( const TQPoint &p ) const +bool CannonField::barrelHit( const TQPoint &p ) const { - TQWMatrix mtx; - mtx.translate( 0, height() - 1 ); - mtx.rotate( -ang ); - mtx = mtx.invert(); - return barrelRect.contains( mtx.map(p) ); + TQWMatrix mtx; + mtx.translate( 0, height() - 1 ); + mtx.rotate( -ang ); + mtx = mtx.invert(); + return barrelRect.contains( mtx.map(p) ); } -- cgit v1.2.1