diff options
Diffstat (limited to 'PerlQt/tutorials/t14/CannonField.pm')
-rw-r--r-- | PerlQt/tutorials/t14/CannonField.pm | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/PerlQt/tutorials/t14/CannonField.pm b/PerlQt/tutorials/t14/CannonField.pm index 05fdbce..cbf675d 100644 --- a/PerlQt/tutorials/t14/CannonField.pm +++ b/PerlQt/tutorials/t14/CannonField.pm @@ -1,14 +1,14 @@ package CannonField; use strict; -use Qt; -use Qt::isa qw(Qt::Widget); -use Qt::signals +use TQt; +use TQt::isa qw(TQt::Widget); +use TQt::signals hit => [], missed => [], angleChanged => ['int'], forceChanged => ['int'], canShoot => ['bool']; -use Qt::slots +use TQt::slots setAngle => ['int'], setForce => ['int'], shoot => [], @@ -16,7 +16,7 @@ use Qt::slots newTarget => [], setGameOver => [], restartGame => []; -use Qt::attributes qw( +use TQt::attributes qw( ang f @@ -42,14 +42,14 @@ sub NEW { ang = 45; f = 0; timerCount = 0; - autoShootTimer = Qt::Timer(this, "movement handler"); - this->connect(autoShootTimer, SIGNAL('timeout()'), SLOT('moveShot()')); + autoShootTimer = TQt::Timer(this, "movement handler"); + this->connect(autoShootTimer, TQT_SIGNAL('timeout()'), TQT_SLOT('moveShot()')); shoot_ang = 0; shoot_f = 0; - target = Qt::Point(0, 0); + target = TQt::Point(0, 0); gameEnded = 0; barrelPressed = 0; - setPalette(Qt::Palette(Qt::Color(250, 250, 200))); + setPalette(TQt::Palette(TQt::Color(250, 250, 200))); newTarget(); } @@ -81,10 +81,10 @@ sub shoot { } sub newTarget { - my $r = Qt::Region(targetRect()); - target = Qt::Point(200 + int(rand(190)), + my $r = TQt::Region(targetRect()); + target = TQt::Point(200 + int(rand(190)), 10 + int(rand(255))); - repaint($r->unite(Qt::Region(targetRect()))); + repaint($r->unite(TQt::Region(targetRect()))); } sub setGameOver { @@ -102,7 +102,7 @@ sub restartGame { } sub moveShot { - my $r = Qt::Region(shotRect()); + my $r = TQt::Region(shotRect()); timerCount++; my $shotR = shotRect(); @@ -117,7 +117,7 @@ sub moveShot { emit missed(); emit canShoot(1); } else { - $r = $r->unite(Qt::Region($shotR)); + $r = $r->unite(TQt::Region($shotR)); } repaint($r); } @@ -146,11 +146,11 @@ sub mouseReleaseEvent { sub paintEvent { my $e = shift; my $updateR = $e->rect; - my $p = Qt::Painter(this); + my $p = TQt::Painter(this); if(gameEnded) { $p->setPen(&black); - $p->setFont(Qt::Font("Courier", 48, &Qt::Font::Bold)); + $p->setFont(TQt::Font("Courier", 48, &TQt::Font::Bold)); $p->drawText(rect(), &AlignCenter, "Game Over"); } paintCannon($p) if $updateR->intersects(cannonRect()); @@ -180,20 +180,20 @@ sub paintBarrier { $p->drawRect(barrierRect()); } -my $barrelRect = Qt::Rect(33, -4, 15, 8); +my $barrelRect = TQt::Rect(33, -4, 15, 8); sub paintCannon { my $p = shift; my $cr = cannonRect(); - my $pix = Qt::Pixmap($cr->size); + my $pix = TQt::Pixmap($cr->size); $pix->fill(this, $cr->topLeft); - my $tmp = Qt::Painter($pix); + my $tmp = TQt::Painter($pix); $tmp->setBrush(&blue); $tmp->setPen(&NoPen); $tmp->translate(0, $pix->height - 1); - $tmp->drawPie(Qt::Rect(-35, -35, 70, 70), 0, 90*16); + $tmp->drawPie(TQt::Rect(-35, -35, 70, 70), 0, 90*16); $tmp->rotate(- ang); $tmp->drawRect($barrelRect); $tmp->end; @@ -202,7 +202,7 @@ sub paintCannon { } sub cannonRect { - my $r = Qt::Rect(0, 0, 50, 50); + my $r = TQt::Rect(0, 0, 50, 50); $r->moveBottomLeft(rect()->bottomLeft); return $r; } @@ -221,24 +221,24 @@ sub shotRect { my $x = $x0 + $velx*$time; my $y = $y0 + $vely*$time - 0.5*$gravity*$time**2; - my $r = Qt::Rect(0, 0, 6, 6); - $r->moveCenter(Qt::Point(int($x), height() - 1 - int($y))); + my $r = TQt::Rect(0, 0, 6, 6); + $r->moveCenter(TQt::Point(int($x), height() - 1 - int($y))); return $r; } sub targetRect { - my $r = Qt::Rect(0, 0, 20, 10); - $r->moveCenter(Qt::Point(target->x, height() - 1 - target->y)); + my $r = TQt::Rect(0, 0, 20, 10); + $r->moveCenter(TQt::Point(target->x, height() - 1 - target->y)); return $r; } sub barrierRect { - return Qt::Rect(145, height() - 100, 15, 100); + return TQt::Rect(145, height() - 100, 15, 100); } sub barrelHit { my $p = shift; - my $mtx = Qt::WMatrix; + my $mtx = TQt::WMatrix; $mtx->translate(0, height() - 1); $mtx->rotate(- ang); $mtx = $mtx->invert; @@ -247,10 +247,10 @@ sub barrelHit { sub isShooting { autoShootTimer->isActive } -sub sizeHint { Qt::Size(400, 300) } +sub sizeHint { TQt::Size(400, 300) } sub sizePolicy { - Qt::SizePolicy(&Qt::SizePolicy::Expanding, &Qt::SizePolicy::Expanding); + TQt::SizePolicy(&TQt::SizePolicy::Expanding, &TQt::SizePolicy::Expanding); } 1; |