Loading t14/cannon.cpp +13 −13 Original line number Original line Diff line number Diff line Loading @@ -21,12 +21,12 @@ CannonField::CannonField( QWidget *parent, const char *name ) { { ang = 45; ang = 45; f = 0; f = 0; shooting = FALSE; shooting = false; timerCount = 0; timerCount = 0; shoot_ang = 0; shoot_ang = 0; shoot_f = 0; shoot_f = 0; gameEnded = FALSE; gameEnded = false; barrelPressed = FALSE; barrelPressed = false; newTarget(); newTarget(); } } Loading @@ -39,7 +39,7 @@ void CannonField::setAngle( int degrees ) if ( ang == degrees ) if ( ang == degrees ) return; return; ang = degrees; ang = degrees; repaint( cannonRect(), FALSE ); repaint( cannonRect(), false ); emit angleChanged( ang ); emit angleChanged( ang ); } } Loading @@ -60,15 +60,15 @@ void CannonField::shoot() timerCount = 0; timerCount = 0; shoot_ang = ang; shoot_ang = ang; shoot_f = f; shoot_f = f; shooting = TRUE; shooting = true; startTimer( 50 ); startTimer( 50 ); } } void CannonField::newTarget() void CannonField::newTarget() { { static bool first_time = TRUE; static bool first_time = true; if ( first_time ) { if ( first_time ) { first_time = FALSE; first_time = false; QTime midnight( 0, 0, 0 ); QTime midnight( 0, 0, 0 ); srand( midnight.secsTo(QTime::currentTime()) ); srand( midnight.secsTo(QTime::currentTime()) ); } } Loading @@ -84,7 +84,7 @@ void CannonField::setGameOver() return; return; if ( shooting ) if ( shooting ) stopShooting(); stopShooting(); gameEnded = TRUE; gameEnded = true; repaint(); repaint(); } } Loading @@ -92,7 +92,7 @@ void CannonField::restartGame() { { if ( shooting ) if ( shooting ) stopShooting(); stopShooting(); gameEnded = FALSE; gameEnded = false; repaint(); repaint(); } } Loading @@ -114,7 +114,7 @@ void CannonField::timerEvent( QTimerEvent * ) emit missed(); emit missed(); return; return; } } repaint( shotR, FALSE ); repaint( shotR, false ); } } void CannonField::paintEvent( QPaintEvent *e ) void CannonField::paintEvent( QPaintEvent *e ) Loading Loading @@ -145,7 +145,7 @@ void CannonField::mousePressEvent( QMouseEvent *e ) if ( e->button() != LeftButton ) if ( e->button() != LeftButton ) return; return; if ( barrelHit( e->pos() ) ) if ( barrelHit( e->pos() ) ) barrelPressed = TRUE; barrelPressed = true; } } void CannonField::mouseMoveEvent( QMouseEvent *e ) void CannonField::mouseMoveEvent( QMouseEvent *e ) Loading @@ -164,12 +164,12 @@ void CannonField::mouseMoveEvent( QMouseEvent *e ) void CannonField::mouseReleaseEvent( QMouseEvent *e ) void CannonField::mouseReleaseEvent( QMouseEvent *e ) { { if ( e->button() == LeftButton ) if ( e->button() == LeftButton ) barrelPressed = FALSE; barrelPressed = false; } } void CannonField::stopShooting() void CannonField::stopShooting() { { shooting = FALSE; shooting = false; killTimers(); killTimers(); } } Loading Loading
t14/cannon.cpp +13 −13 Original line number Original line Diff line number Diff line Loading @@ -21,12 +21,12 @@ CannonField::CannonField( QWidget *parent, const char *name ) { { ang = 45; ang = 45; f = 0; f = 0; shooting = FALSE; shooting = false; timerCount = 0; timerCount = 0; shoot_ang = 0; shoot_ang = 0; shoot_f = 0; shoot_f = 0; gameEnded = FALSE; gameEnded = false; barrelPressed = FALSE; barrelPressed = false; newTarget(); newTarget(); } } Loading @@ -39,7 +39,7 @@ void CannonField::setAngle( int degrees ) if ( ang == degrees ) if ( ang == degrees ) return; return; ang = degrees; ang = degrees; repaint( cannonRect(), FALSE ); repaint( cannonRect(), false ); emit angleChanged( ang ); emit angleChanged( ang ); } } Loading @@ -60,15 +60,15 @@ void CannonField::shoot() timerCount = 0; timerCount = 0; shoot_ang = ang; shoot_ang = ang; shoot_f = f; shoot_f = f; shooting = TRUE; shooting = true; startTimer( 50 ); startTimer( 50 ); } } void CannonField::newTarget() void CannonField::newTarget() { { static bool first_time = TRUE; static bool first_time = true; if ( first_time ) { if ( first_time ) { first_time = FALSE; first_time = false; QTime midnight( 0, 0, 0 ); QTime midnight( 0, 0, 0 ); srand( midnight.secsTo(QTime::currentTime()) ); srand( midnight.secsTo(QTime::currentTime()) ); } } Loading @@ -84,7 +84,7 @@ void CannonField::setGameOver() return; return; if ( shooting ) if ( shooting ) stopShooting(); stopShooting(); gameEnded = TRUE; gameEnded = true; repaint(); repaint(); } } Loading @@ -92,7 +92,7 @@ void CannonField::restartGame() { { if ( shooting ) if ( shooting ) stopShooting(); stopShooting(); gameEnded = FALSE; gameEnded = false; repaint(); repaint(); } } Loading @@ -114,7 +114,7 @@ void CannonField::timerEvent( QTimerEvent * ) emit missed(); emit missed(); return; return; } } repaint( shotR, FALSE ); repaint( shotR, false ); } } void CannonField::paintEvent( QPaintEvent *e ) void CannonField::paintEvent( QPaintEvent *e ) Loading Loading @@ -145,7 +145,7 @@ void CannonField::mousePressEvent( QMouseEvent *e ) if ( e->button() != LeftButton ) if ( e->button() != LeftButton ) return; return; if ( barrelHit( e->pos() ) ) if ( barrelHit( e->pos() ) ) barrelPressed = TRUE; barrelPressed = true; } } void CannonField::mouseMoveEvent( QMouseEvent *e ) void CannonField::mouseMoveEvent( QMouseEvent *e ) Loading @@ -164,12 +164,12 @@ void CannonField::mouseMoveEvent( QMouseEvent *e ) void CannonField::mouseReleaseEvent( QMouseEvent *e ) void CannonField::mouseReleaseEvent( QMouseEvent *e ) { { if ( e->button() == LeftButton ) if ( e->button() == LeftButton ) barrelPressed = FALSE; barrelPressed = false; } } void CannonField::stopShooting() void CannonField::stopShooting() { { shooting = FALSE; shooting = false; killTimers(); killTimers(); } } Loading