#include <view.h>
Inheritance diagram for KAsteroidsView:


Definition at line 47 of file view.h.
| KAsteroidsView::KAsteroidsView | ( | QWidget * | parent = 0, |
|
| const char * | name = 0 | |||
| ) |
Definition at line 96 of file view.cpp.
References bits, QGraphicsTextItem::boundingRect(), QGraphicsView::CacheBackground, can_destroy_powerups, QObject::connect(), exhaust, FALSE, field, QWidget::font(), QRectF::height(), QGraphicsScene::height(), hideShield(), IMG_BACKGROUND, initialized, MAX_POWER_LEVEL, missiles, mPaused, mTimerId, powerups, readSprites(), REFRESH_DELAY, refreshRate, rocks, Qt::ScrollBarAlwaysOff, Q3PtrCollection::setAutoDelete(), QGraphicsScene::setBackgroundBrush(), QGraphicsView::setCacheMode(), QWidget::setFocusProxy(), QGraphicsTextItem::setFont(), QAbstractScrollArea::setHorizontalScrollBarPolicy(), QGraphicsTextItem::setHtml(), QGraphicsItem::setPos(), QAbstractScrollArea::setVerticalScrollBarPolicy(), shield, shieldOn, shieldTimer, shipPower, SIGNAL, SLOT, textSprite, TRUE, view, QAbstractScrollArea::viewport(), vitalsChanged, QRectF::width(), and QGraphicsScene::width().
00097 : QWidget( parent, name ), 00098 field(0, 0, 640, 440), 00099 view(&field,this) 00100 { 00101 view.setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); 00102 view.setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); 00103 view.setCacheMode(QGraphicsView::CacheBackground); 00104 view.viewport()->setFocusProxy( this ); 00105 rocks.setAutoDelete( TRUE ); 00106 missiles.setAutoDelete( TRUE ); 00107 bits.setAutoDelete( TRUE ); 00108 powerups.setAutoDelete( TRUE ); 00109 exhaust.setAutoDelete( TRUE ); 00110 00111 QPixmap pm( IMG_BACKGROUND ); 00112 field.setBackgroundBrush( pm ); 00113 00114 textSprite = new QGraphicsTextItem( 0, &field ); 00115 QFont font( "helvetica", 18 ); 00116 textSprite->setFont( font ); 00117 00118 shield = 0; 00119 shieldOn = FALSE; 00120 refreshRate = REFRESH_DELAY; 00121 00122 initialized = readSprites(); 00123 00124 shieldTimer = new QTimer( this ); 00125 connect( shieldTimer, SIGNAL(timeout()), this, SLOT(hideShield()) ); 00126 mTimerId = -1; 00127 00128 shipPower = MAX_POWER_LEVEL; 00129 vitalsChanged = TRUE; 00130 can_destroy_powerups = FALSE; 00131 00132 mPaused = TRUE; 00133 00134 if ( !initialized ) { 00135 textSprite->setHtml( tr("<font color=red>Error: Cannot read sprite images</font>") ); 00136 textSprite->setPos( (field.width()-textSprite->boundingRect().width()) / 2, 00137 (field.height()-textSprite->boundingRect().height()) / 2 ); 00138 } 00139 }
Here is the call graph for this function:

| KAsteroidsView::~KAsteroidsView | ( | ) | [virtual] |
| void KAsteroidsView::reset | ( | ) |
Definition at line 149 of file view.cpp.
References bits, Q3PtrList< type >::clear(), exhaust, FALSE, QGraphicsItem::hide(), initialized, mFrameNum, missiles, mPaused, powerups, powerupSpeed, rocks, rockSpeed, shield, ship, shotsFired, and shotsHit.
Referenced by newGame().
00150 { 00151 if ( !initialized ) 00152 return; 00153 rocks.clear(); 00154 missiles.clear(); 00155 bits.clear(); 00156 powerups.clear(); 00157 exhaust.clear(); 00158 00159 shotsFired = 0; 00160 shotsHit = 0; 00161 00162 rockSpeed = 1.0; 00163 powerupSpeed = 1.0; 00164 mFrameNum = 0; 00165 mPaused = FALSE; 00166 00167 ship->hide(); 00168 shield->hide(); 00169 /* 00170 if ( mTimerId >= 0 ) { 00171 killTimer( mTimerId ); 00172 mTimerId = -1; 00173 } 00174 */ 00175 }
Here is the call graph for this function:

| void KAsteroidsView::setRockSpeed | ( | double | rs | ) | [inline] |
Definition at line 57 of file view.h.
References rockSpeed.
Referenced by KAstTopLevel::slotNewGame(), and KAstTopLevel::slotRocksRemoved().
00057 { rockSpeed = rs; }
| void KAsteroidsView::addRocks | ( | int | num | ) |
Definition at line 310 of file view.cpp.
References animation, Q3PtrList< type >::append(), field, QGraphicsScene::height(), i, ID_ROCK_LARGE, initialized, randDouble(), randInt(), rocks, rockSpeed, and QGraphicsScene::width().
Referenced by KAstTopLevel::slotNewGame(), and KAstTopLevel::slotRocksRemoved().
00311 { 00312 if ( !initialized ) 00313 return; 00314 for ( int i = 0; i < num; i++ ) 00315 { 00316 KRock *rock = new KRock( animation[ID_ROCK_LARGE], &field, 00317 ID_ROCK_LARGE, randInt(2), randInt(2) ? -1 : 1 ); 00318 double dx = (2.0 - randDouble()*4.0) * rockSpeed; 00319 double dy = (2.0 - randDouble()*4.0) * rockSpeed; 00320 rock->setVelocity( dx, dy ); 00321 rock->setFrame( randInt( rock->frameCount() ) ); 00322 if ( dx > 0 ) 00323 { 00324 if ( dy > 0 ) 00325 rock->setPos( 5, 5 ); 00326 else 00327 rock->setPos( 5, field.height() - 25 ); 00328 rock->setFrame( 0 ); 00329 } 00330 else 00331 { 00332 if ( dy > 0 ) 00333 rock->setPos( field.width() - 25, 5 ); 00334 else 00335 rock->setPos( field.width() - 25, field.height() - 25 ); 00336 rock->setFrame( 0 ); 00337 } 00338 rock->show(); 00339 rocks.append( rock ); 00340 } 00341 }
Here is the call graph for this function:

| void KAsteroidsView::newGame | ( | ) |
Definition at line 179 of file view.cpp.
References emit, FALSE, QGraphicsItem::hide(), initialized, mTimerId, REFRESH_DELAY, reset(), shield, shieldOn, QObject::startTimer(), and updateVitals().
Referenced by KAstTopLevel::slotNewGame().
00180 { 00181 if ( !initialized ) 00182 return; 00183 if ( shieldOn ) 00184 { 00185 shield->hide(); 00186 shieldOn = FALSE; 00187 } 00188 reset(); 00189 if ( mTimerId < 0 ) 00190 mTimerId = startTimer( REFRESH_DELAY ); 00191 emit updateVitals(); 00192 }
Here is the call graph for this function:

| void KAsteroidsView::endGame | ( | ) |
| void KAsteroidsView::newShip | ( | ) |
Definition at line 216 of file view.cpp.
References brakeShip, FALSE, QWidget::height(), initialized, MAX_POWER_LEVEL, mBrakeCount, mShieldCount, mShootCount, mTeleportCount, ROTATE_RATE, rotateL, rotateR, rotateRate, rotateSlow, AnimatedPixmapItem::setFrame(), QGraphicsItem::setPos(), AnimatedPixmapItem::setVelocity(), shield, shieldOn, shieldTimer, ship, shipAngle, shipDx, shipDy, shipPower, shootDelay, shootShip, QGraphicsItem::show(), QTimer::start(), teleportShip, thrustShip, TRUE, and QWidget::width().
Referenced by KAstTopLevel::keyReleaseEvent(), and KAstTopLevel::slotNewGame().
00217 { 00218 if ( !initialized ) 00219 return; 00220 ship->setPos( width()/2, height()/2 ); 00221 ship->setFrame( 0 ); 00222 shield->setPos( width()/2, height()/2 ); 00223 shield->setFrame( 0 ); 00224 ship->setVelocity( 0.0, 0.0 ); 00225 shipDx = 0; 00226 shipDy = 0; 00227 shipAngle = 0; 00228 rotateL = FALSE; 00229 rotateR = FALSE; 00230 thrustShip = FALSE; 00231 shootShip = FALSE; 00232 brakeShip = FALSE; 00233 teleportShip = FALSE; 00234 shieldOn = TRUE; 00235 shootDelay = 0; 00236 shipPower = MAX_POWER_LEVEL; 00237 rotateRate = ROTATE_RATE; 00238 rotateSlow = 0; 00239 00240 mBrakeCount = 0; 00241 mTeleportCount = 0; 00242 mShootCount = 0; 00243 00244 ship->show(); 00245 shield->show(); 00246 mShieldCount = 1; // just in case the ship appears on a rock. 00247 shieldTimer->start( 1000, TRUE ); 00248 }
Here is the call graph for this function:

| void KAsteroidsView::rotateLeft | ( | bool | r | ) | [inline] |
Definition at line 63 of file view.h.
References rotateL, and rotateSlow.
Referenced by KAstTopLevel::keyPressEvent(), and KAstTopLevel::keyReleaseEvent().
00063 { rotateL = r; rotateSlow = 5; }
| void KAsteroidsView::rotateRight | ( | bool | r | ) | [inline] |
Definition at line 64 of file view.h.
References rotateR, and rotateSlow.
Referenced by KAstTopLevel::keyPressEvent(), and KAstTopLevel::keyReleaseEvent().
00064 { rotateR = r; rotateSlow = 5; }
| void KAsteroidsView::thrust | ( | bool | t | ) | [inline] |
Definition at line 65 of file view.h.
References shipPower, and thrustShip.
Referenced by KAstTopLevel::keyPressEvent(), and KAstTopLevel::keyReleaseEvent().
00065 { thrustShip = t && shipPower > 0; }
| void KAsteroidsView::shoot | ( | bool | s | ) | [inline] |
Definition at line 66 of file view.h.
References shootDelay, and shootShip.
Referenced by KAstTopLevel::keyPressEvent(), and KAstTopLevel::keyReleaseEvent().
00066 { shootShip = s; shootDelay = 0; }
| void KAsteroidsView::setShield | ( | bool | s | ) |
Definition at line 250 of file view.cpp.
References hideShield(), initialized, QTimer::isActive(), mShieldCount, shieldOn, shieldTimer, and QTimer::stop().
Referenced by KAstTopLevel::keyPressEvent(), and KAstTopLevel::keyReleaseEvent().
00251 { 00252 if ( !initialized ) 00253 return; 00254 if ( shieldTimer->isActive() && !s ) { 00255 shieldTimer->stop(); 00256 hideShield(); 00257 } else { 00258 shieldOn = s && mShieldCount; 00259 } 00260 }
Here is the call graph for this function:

| void KAsteroidsView::teleport | ( | bool | te | ) | [inline] |
Definition at line 68 of file view.h.
References mTeleportCount, and teleportShip.
Referenced by KAstTopLevel::keyPressEvent(), and KAstTopLevel::keyReleaseEvent().
00068 { teleportShip = te && mTeleportCount; }
| void KAsteroidsView::brake | ( | bool | b | ) |
Definition at line 262 of file view.cpp.
References brakeShip, FALSE, initialized, mBrakeCount, ROTATE_RATE, rotateL, rotateR, rotateRate, and thrustShip.
Referenced by KAstTopLevel::keyPressEvent(), and KAstTopLevel::keyReleaseEvent().
00263 { 00264 if ( !initialized ) 00265 return; 00266 if ( mBrakeCount ) 00267 { 00268 if ( brakeShip && !b ) 00269 { 00270 rotateL = FALSE; 00271 rotateR = FALSE; 00272 thrustShip = FALSE; 00273 rotateRate = ROTATE_RATE; 00274 } 00275 00276 brakeShip = b; 00277 } 00278 }
| void KAsteroidsView::pause | ( | bool | p | ) |
Definition at line 200 of file view.cpp.
References initialized, QObject::killTimer(), mPaused, mTimerId, REFRESH_DELAY, and QObject::startTimer().
Referenced by KAstTopLevel::hideEvent(), and KAstTopLevel::showEvent().
00201 { 00202 if ( !initialized ) 00203 return; 00204 if ( !mPaused && p ) { 00205 if ( mTimerId >= 0 ) { 00206 killTimer( mTimerId ); 00207 mTimerId = -1; 00208 } 00209 } else if ( mPaused && !p ) 00210 mTimerId = startTimer( REFRESH_DELAY ); 00211 mPaused = p; 00212 }
Here is the call graph for this function:

Definition at line 345 of file view.cpp.
References QColor::blue, QGraphicsTextItem::boundingRect(), field, QColor::green, QRectF::height(), QGraphicsScene::height(), initialized, QColor::red, QGraphicsTextItem::setHtml(), QGraphicsItem::setPos(), QGraphicsItem::show(), TEXT_SPEED, textDy, textSprite, QRectF::width(), and QGraphicsScene::width().
Referenced by KAstTopLevel::doStats(), KAstTopLevel::KAstTopLevel(), and KAstTopLevel::slotShipKilled().
00346 { 00347 if ( !initialized ) 00348 return; 00349 textSprite->setHtml( QString("<font color=#%1%2%3>%4</font>") 00350 .arg(color.red(), 2, 16, QLatin1Char('0')) 00351 .arg(color.green(), 2, 16, QLatin1Char('0')) 00352 .arg(color.blue(), 2, 16, QLatin1Char('0')) 00353 .arg(text) ); 00354 Q_UNUSED(color); 00355 // ### Porting: no such thing textSprite->setColor( color ); 00356 00357 if ( scroll ) { 00358 textSprite->setPos( (field.width()-textSprite->boundingRect().width()) / 2, 00359 -textSprite->boundingRect().height() ); 00360 textDy = TEXT_SPEED; 00361 } else { 00362 textSprite->setPos( (field.width()-textSprite->boundingRect().width()) / 2, 00363 (field.height()-textSprite->boundingRect().height()) / 2 ); 00364 textDy = 0; 00365 } 00366 textSprite->show(); 00367 }
Here is the call graph for this function:

| void KAsteroidsView::hideText | ( | ) |
Definition at line 371 of file view.cpp.
References TEXT_SPEED, and textDy.
Referenced by KAstTopLevel::keyReleaseEvent(), and KAstTopLevel::slotNewGame().
00372 { 00373 textDy = -TEXT_SPEED; 00374 }
| int KAsteroidsView::shots | ( | ) | const [inline] |
Definition at line 75 of file view.h.
References shotsFired.
Referenced by KAstTopLevel::doStats().
00075 { return shotsFired; }
| int KAsteroidsView::hits | ( | ) | const [inline] |
Definition at line 76 of file view.h.
References shotsHit.
Referenced by KAstTopLevel::doStats(), processMissiles(), processPowerups(), and processShip().
00076 { return shotsHit; }
| int KAsteroidsView::power | ( | ) | const [inline] |
Definition at line 77 of file view.h.
References shipPower.
Referenced by KAstTopLevel::slotUpdateVitals().
00077 { return shipPower; }
| int KAsteroidsView::teleportCount | ( | ) | const [inline] |
| int KAsteroidsView::brakeCount | ( | ) | const [inline] |
Definition at line 80 of file view.h.
References mBrakeCount.
Referenced by KAstTopLevel::slotUpdateVitals().
00080 { return mBrakeCount; }
| int KAsteroidsView::shieldCount | ( | ) | const [inline] |
Definition at line 81 of file view.h.
References mShieldCount.
Referenced by KAstTopLevel::slotUpdateVitals().
00081 { return mShieldCount; }
| int KAsteroidsView::shootCount | ( | ) | const [inline] |
Definition at line 82 of file view.h.
References mShootCount.
Referenced by KAstTopLevel::slotUpdateVitals().
00082 { return mShootCount; }
| void KAsteroidsView::shipKilled | ( | ) | [signal] |
Referenced by processShip().
| void KAsteroidsView::rockHit | ( | int | size | ) | [signal] |
Referenced by processMissiles(), processShip(), and rockHit().
| void KAsteroidsView::rocksRemoved | ( | ) | [signal] |
Referenced by rockHit().
| void KAsteroidsView::updateVitals | ( | ) | [signal] |
Referenced by newGame(), and timerEvent().
| void KAsteroidsView::hideShield | ( | ) | [private, slot] |
Definition at line 911 of file view.cpp.
References FALSE, QGraphicsItem::hide(), mShieldCount, shield, and shieldOn.
Referenced by KAsteroidsView(), and setShield().
00912 { 00913 shield->hide(); 00914 mShieldCount = 0; 00915 shieldOn = FALSE; 00916 }
| bool KAsteroidsView::readSprites | ( | ) | [protected] |
Definition at line 282 of file view.cpp.
References animation, field, QFileInfo::fileName(), QGraphicsItem::hide(), i, ID_SHIELD, ID_SHIP, AnimatedPixmapItem::image(), QMap< Key, T >::insert(), QPixmap::isNull(), kas_animations, QFileInfo::path(), QWidget::QPixmap, QString::replace(), shield, and ship.
Referenced by KAsteroidsView().
00283 { 00284 QString sprites_prefix = ":/trolltech/examples/graphicsview/portedasteroids/sprites/"; 00285 00286 int i = 0; 00287 while ( kas_animations[i].id ) 00288 { 00289 QList<QPixmap> anim; 00290 QString wildcard = sprites_prefix + kas_animations[i].path; 00291 wildcard.replace("%1", "*"); 00292 QFileInfo fi(wildcard); 00293 foreach (QString entry, QDir(fi.path(), fi.fileName()).entryList()) 00294 anim << QPixmap(fi.path() + "/" + entry); 00295 animation.insert( kas_animations[i].id, anim ); 00296 i++; 00297 } 00298 00299 ship = new AnimatedPixmapItem( animation[ID_SHIP], &field ); 00300 ship->hide(); 00301 00302 shield = new KShield( animation[ID_SHIELD], &field ); 00303 shield->hide(); 00304 00305 return (!ship->image(0).isNull() && !shield->image(0).isNull()); 00306 }
Here is the call graph for this function:

| void KAsteroidsView::wrapSprite | ( | QGraphicsItem * | ) | [protected] |
Definition at line 449 of file view.cpp.
References field, QGraphicsScene::height(), int, s, QGraphicsScene::width(), QWidget::x(), and QWidget::y().
Referenced by processMissiles(), processPowerups(), and timerEvent().
00450 { 00451 int x = int(s->x() + s->boundingRect().width() / 2); 00452 int y = int(s->y() + s->boundingRect().height() / 2); 00453 00454 if ( x > field.width() ) 00455 s->setPos( s->x() - field.width(), s->y() ); 00456 else if ( x < 0 ) 00457 s->setPos( field.width() + s->x(), s->y() ); 00458 00459 if ( y > field.height() ) 00460 s->setPos( s->x(), s->y() - field.height() ); 00461 else if ( y < 0 ) 00462 s->setPos( s->x(), field.height() + s->y() ); 00463 }
Here is the call graph for this function:

| void KAsteroidsView::rockHit | ( | AnimatedPixmapItem * | ) | [protected] |
Definition at line 467 of file view.cpp.
References animation, Q3PtrList< type >::append(), Q3PtrList< type >::count(), emit, field, AnimatedPixmapItem::frameCount(), i, ID_BRAKE_POWERUP, ID_ENERGY_POWERUP, ID_ROCK_LARGE, ID_ROCK_MEDIUM, ID_ROCK_SMALL, ID_SHIELD_POWERUP, ID_SHOOT_POWERUP, int, MAX_ROCK_SPEED, powerups, randDouble(), randInt(), Q3PtrList< type >::removeRef(), rockHit(), rocks, rockSpeed, rocksRemoved(), AnimatedPixmapItem::setFrame(), QGraphicsItem::setPos(), AnimatedPixmapItem::setVelocity(), QGraphicsPixmapItem::type(), QGraphicsItem::x(), AnimatedPixmapItem::xVelocity(), QGraphicsItem::y(), and AnimatedPixmapItem::yVelocity().
00468 { 00469 KPowerup *nPup = 0; 00470 int rnd = int(randDouble()*30.0) % 30; 00471 switch( rnd ) 00472 { 00473 case 4: 00474 case 5: 00475 nPup = new KPowerup( animation[ID_ENERGY_POWERUP], &field, 00476 ID_ENERGY_POWERUP ); 00477 break; 00478 case 10: 00479 // nPup = new KPowerup( animation[ID_TELEPORT_POWERUP], &field, 00480 // ID_TELEPORT_POWERUP ); 00481 break; 00482 case 15: 00483 nPup = new KPowerup( animation[ID_BRAKE_POWERUP], &field, 00484 ID_BRAKE_POWERUP ); 00485 break; 00486 case 20: 00487 nPup = new KPowerup( animation[ID_SHIELD_POWERUP], &field, 00488 ID_SHIELD_POWERUP ); 00489 break; 00490 case 24: 00491 case 25: 00492 nPup = new KPowerup( animation[ID_SHOOT_POWERUP], &field, 00493 ID_SHOOT_POWERUP ); 00494 break; 00495 } 00496 if ( nPup ) 00497 { 00498 double r = 0.5 - randDouble(); 00499 nPup->setPos( hit->x(), hit->y() ); 00500 nPup->setFrame( 0 ); 00501 nPup->setVelocity( hit->xVelocity() + r, hit->yVelocity() + r ); 00502 powerups.append( nPup ); 00503 } 00504 00505 if ( hit->type() == ID_ROCK_LARGE || hit->type() == ID_ROCK_MEDIUM ) 00506 { 00507 // break into smaller rocks 00508 double addx[4] = { 1.0, 1.0, -1.0, -1.0 }; 00509 double addy[4] = { -1.0, 1.0, -1.0, 1.0 }; 00510 00511 double dx = hit->xVelocity(); 00512 double dy = hit->yVelocity(); 00513 00514 double maxRockSpeed = MAX_ROCK_SPEED * rockSpeed; 00515 if ( dx > maxRockSpeed ) 00516 dx = maxRockSpeed; 00517 else if ( dx < -maxRockSpeed ) 00518 dx = -maxRockSpeed; 00519 if ( dy > maxRockSpeed ) 00520 dy = maxRockSpeed; 00521 else if ( dy < -maxRockSpeed ) 00522 dy = -maxRockSpeed; 00523 00524 AnimatedPixmapItem *nrock; 00525 00526 for ( int i = 0; i < 4; i++ ) 00527 { 00528 double r = rockSpeed/2 - randDouble()*rockSpeed; 00529 if ( hit->type() == ID_ROCK_LARGE ) 00530 { 00531 nrock = new KRock( animation[ID_ROCK_MEDIUM], &field, 00532 ID_ROCK_MEDIUM, randInt(2), randInt(2) ? -1 : 1 ); 00533 emit rockHit( 0 ); 00534 } 00535 else 00536 { 00537 nrock = new KRock( animation[ID_ROCK_SMALL], &field, 00538 ID_ROCK_SMALL, randInt(2), randInt(2) ? -1 : 1 ); 00539 emit rockHit( 1 ); 00540 } 00541 00542 nrock->setPos( hit->x(), hit->y() ); 00543 nrock->setFrame( 0 ); 00544 nrock->setVelocity( dx+addx[i]*rockSpeed+r, dy+addy[i]*rockSpeed+r ); 00545 nrock->setFrame( randInt( nrock->frameCount() ) ); 00546 rocks.append( nrock ); 00547 } 00548 } 00549 else if ( hit->type() == ID_ROCK_SMALL ) 00550 emit rockHit( 2 ); 00551 rocks.removeRef( hit ); 00552 if ( rocks.count() == 0 ) 00553 emit rocksRemoved(); 00554 }
Here is the call graph for this function:

| void KAsteroidsView::reducePower | ( | int | val | ) | [protected] |
Definition at line 556 of file view.cpp.
References FALSE, QGraphicsItem::hide(), shield, shieldOn, shipPower, thrustShip, TRUE, and vitalsChanged.
Referenced by processShip().
00557 { 00558 shipPower -= val; 00559 if ( shipPower <= 0 ) 00560 { 00561 shipPower = 0; 00562 thrustShip = FALSE; 00563 if ( shieldOn ) 00564 { 00565 shieldOn = FALSE; 00566 shield->hide(); 00567 } 00568 } 00569 vitalsChanged = TRUE; 00570 }
Here is the call graph for this function:

| void KAsteroidsView::addExhaust | ( | double | x, | |
| double | y, | |||
| double | dx, | |||
| double | dy, | |||
| int | count | |||
| ) | [protected] |
Definition at line 572 of file view.cpp.
References animation, Q3PtrList< type >::append(), exhaust, field, i, ID_EXHAUST, and randDouble().
Referenced by processShip().
00574 { 00575 for ( int i = 0; i < count; i++ ) 00576 { 00577 KExhaust *e = new KExhaust( animation[ID_EXHAUST], &field ); 00578 e->setPos( x + 2 - randDouble()*4, y + 2 - randDouble()*4 ); 00579 e->setVelocity( dx, dy ); 00580 exhaust.append( e ); 00581 } 00582 }
Here is the call graph for this function:

| void KAsteroidsView::processMissiles | ( | ) | [protected] |
Definition at line 584 of file view.cpp.
References QGraphicsItem::collidingItems(), Q3PtrListIterator< type >::current(), KMissile::expired(), KMissile::growOlder(), hits(), ID_ROCK_LARGE, ID_ROCK_SMALL, missiles, Q3PtrList< type >::removeRef(), rockHit(), shotsHit, and wrapSprite().
Referenced by timerEvent().
00585 { 00586 KMissile *missile; 00587 00588 // if a missile has hit a rock, remove missile and break rock into smaller 00589 // rocks or remove completely. 00590 Q3PtrListIterator<KMissile> it(missiles); 00591 00592 for ( ; it.current(); ++it ) 00593 { 00594 missile = it.current(); 00595 missile->growOlder(); 00596 00597 if ( missile->expired() ) 00598 { 00599 missiles.removeRef( missile ); 00600 continue; 00601 } 00602 00603 wrapSprite( missile ); 00604 00605 QList<QGraphicsItem *> hits = missile->collidingItems(); 00606 QList<QGraphicsItem *>::Iterator hit; 00607 for ( hit = hits.begin(); hit != hits.end(); ++hit ) 00608 { 00609 if ( (*hit)->type() >= ID_ROCK_LARGE && 00610 (*hit)->type() <= ID_ROCK_SMALL ) 00611 { 00612 shotsHit++; 00613 rockHit( static_cast<AnimatedPixmapItem *>(*hit) ); 00614 missiles.removeRef( missile ); 00615 break; 00616 } 00617 } 00618 } 00619 }
Here is the call graph for this function:

| void KAsteroidsView::processShip | ( | ) | [protected] |
Definition at line 623 of file view.cpp.
References addExhaust(), angle(), animation, Q3PtrList< type >::append(), bits, BRAKE_ON_COST, brakeShip, QGraphicsItem::collidingItems(), Q3PtrList< type >::count(), emit, FALSE, field, AnimatedPixmapItem::frame(), AnimatedPixmapItem::frameCount(), QGraphicsItem::hide(), hits(), i, ID_BIT, ID_MISSILE, ID_ROCK_LARGE, ID_ROCK_MEDIUM, ID_ROCK_SMALL, QGraphicsItem::isVisible(), M_PI, MAX_SHIP_SPEED, mBrakeCount, MISSILE_SPEED, missiles, mShieldCount, mShootCount, PI_X_2, qrand(), randDouble(), randInt(), reducePower(), rockHit(), ROTATE_RATE, rotateL, rotateR, rotateRate, rotateSlow, AnimatedPixmapItem::setFrame(), QGraphicsItem::setPos(), AnimatedPixmapItem::setVelocity(), shield, SHIELD_HIT_COST, SHIELD_ON_COST, shieldOn, ship, SHIP_STEPS, shipAngle, shipDx, shipDy, shipKilled(), shootDelay, shootShip, shotsFired, QGraphicsItem::show(), teleportShip, thrustShip, TRUE, vitalsChanged, QGraphicsItem::x(), and QGraphicsItem::y().
Referenced by timerEvent().
00624 { 00625 if ( ship->isVisible() ) 00626 { 00627 if ( shieldOn ) 00628 { 00629 shield->show(); 00630 reducePower( SHIELD_ON_COST ); 00631 static int sf = 0; 00632 sf++; 00633 00634 if ( sf % 2 ) 00635 shield->setFrame( (shield->frame()+1) % shield->frameCount() ); 00636 shield->setPos( ship->x() - 9, ship->y() - 9 ); 00637 00638 QList<QGraphicsItem *> hits = shield->collidingItems(); 00639 QList<QGraphicsItem *>::Iterator it; 00640 for ( it = hits.begin(); it != hits.end(); ++it ) 00641 { 00642 if ( (*it)->type() >= ID_ROCK_LARGE && 00643 (*it)->type() <= ID_ROCK_SMALL ) 00644 { 00645 int factor; 00646 switch ( (*it)->type() ) 00647 { 00648 case ID_ROCK_LARGE: 00649 factor = 3; 00650 break; 00651 00652 case ID_ROCK_MEDIUM: 00653 factor = 2; 00654 break; 00655 00656 default: 00657 factor = 1; 00658 } 00659 00660 if ( factor > mShieldCount ) 00661 { 00662 // shield not strong enough 00663 shieldOn = FALSE; 00664 break; 00665 } 00666 rockHit( static_cast<AnimatedPixmapItem *>(*it) ); 00667 // the more shields we have the less costly 00668 reducePower( factor * (SHIELD_HIT_COST - mShieldCount*2) ); 00669 } 00670 } 00671 } 00672 00673 if ( !shieldOn ) 00674 { 00675 shield->hide(); 00676 QList<QGraphicsItem *> hits = ship->collidingItems(); 00677 QList<QGraphicsItem *>::Iterator it; 00678 for ( it = hits.begin(); it != hits.end(); ++it ) 00679 { 00680 if ( (*it)->type() >= ID_ROCK_LARGE && 00681 (*it)->type() <= ID_ROCK_SMALL ) 00682 { 00683 KBit *bit; 00684 for ( int i = 0; i < 12; i++ ) 00685 { 00686 bit = new KBit( animation[ID_BIT], &field ); 00687 bit->setPos( ship->x() + 5 - randDouble() * 10, 00688 ship->y() + 5 - randDouble() * 10 ); 00689 bit->setFrame( randInt(bit->frameCount()) ); 00690 bit->setVelocity( 1-randDouble()*2, 00691 1-randDouble()*2 ); 00692 bit->setDeath( 60 + randInt(60) ); 00693 bits.append( bit ); 00694 } 00695 ship->hide(); 00696 shield->hide(); 00697 emit shipKilled(); 00698 break; 00699 } 00700 } 00701 } 00702 00703 00704 if ( rotateSlow ) 00705 rotateSlow--; 00706 00707 if ( rotateL ) 00708 { 00709 shipAngle -= rotateSlow ? 1 : rotateRate; 00710 if ( shipAngle < 0 ) 00711 shipAngle += SHIP_STEPS; 00712 } 00713 00714 if ( rotateR ) 00715 { 00716 shipAngle += rotateSlow ? 1 : rotateRate; 00717 if ( shipAngle >= SHIP_STEPS ) 00718 shipAngle -= SHIP_STEPS; 00719 } 00720 00721 double angle = shipAngle * PI_X_2 / SHIP_STEPS; 00722 double cosangle = cos( angle ); 00723 double sinangle = sin( angle ); 00724 00725 if ( brakeShip ) 00726 { 00727 thrustShip = FALSE; 00728 rotateL = FALSE; 00729 rotateR = FALSE; 00730 rotateRate = ROTATE_RATE; 00731 if ( fabs(shipDx) < 2.5 && fabs(shipDy) < 2.5 ) 00732 { 00733 shipDx = 0.0; 00734 shipDy = 0.0; 00735 ship->setVelocity( shipDx, shipDy ); 00736 brakeShip = FALSE; 00737 } 00738 else 00739 { 00740 double motionAngle = atan2( -shipDy, -shipDx ); 00741 if ( angle > M_PI ) 00742 angle -= PI_X_2; 00743 double angleDiff = angle - motionAngle; 00744 if ( angleDiff > M_PI ) 00745 angleDiff = PI_X_2 - angleDiff; 00746 else if ( angleDiff < -M_PI ) 00747 angleDiff = PI_X_2 + angleDiff; 00748 double fdiff = fabs( angleDiff ); 00749 if ( fdiff > 0.08 ) 00750 { 00751 if ( angleDiff > 0 ) 00752 rotateL = TRUE; 00753 else if ( angleDiff < 0 ) 00754 rotateR = TRUE; 00755 if ( fdiff > 0.6 ) 00756 rotateRate = mBrakeCount + 1; 00757 else if ( fdiff > 0.4 ) 00758 rotateRate = 2; 00759 else 00760 rotateRate = 1; 00761 00762 if ( rotateRate > 5 ) 00763 rotateRate = 5; 00764 } 00765 else if ( fabs(shipDx) > 1 || fabs(shipDy) > 1 ) 00766 { 00767 thrustShip = TRUE; 00768 // we'll make braking a bit faster 00769 shipDx += cosangle/6 * (mBrakeCount - 1); 00770 shipDy += sinangle/6 * (mBrakeCount - 1); 00771 reducePower( BRAKE_ON_COST ); 00772 addExhaust( ship->x() + 20 - cosangle*22, 00773 ship->y() + 20 - sinangle*22, 00774 shipDx-cosangle, shipDy-sinangle, 00775 mBrakeCount+1 ); 00776 } 00777 } 00778 } 00779 00780 if ( thrustShip ) 00781 { 00782 // The ship has a terminal velocity, but trying to go faster 00783 // still uses fuel (can go faster diagonally - don't care). 00784 double thrustx = cosangle/4; 00785 double thrusty = sinangle/4; 00786 if ( fabs(shipDx + thrustx) < MAX_SHIP_SPEED ) 00787 shipDx += thrustx; 00788 if ( fabs(shipDy + thrusty) < MAX_SHIP_SPEED ) 00789 shipDy += thrusty; 00790 ship->setVelocity( shipDx, shipDy ); 00791 reducePower( 1 ); 00792 addExhaust( ship->x() + 20 - cosangle*20, 00793 ship->y() + 20 - sinangle*20, 00794 shipDx-cosangle, shipDy-sinangle, 3 ); 00795 } 00796 00797 ship->setFrame( shipAngle >> 1 ); 00798 00799 if ( shootShip ) 00800 { 00801 if ( !shootDelay && (int)missiles.count() < mShootCount + 2 ) 00802 { 00803 KMissile *missile = new KMissile( animation[ID_MISSILE], &field ); 00804 missile->setPos( 21+ship->x()+cosangle*21, 00805 21+ship->y()+sinangle*21 ); 00806 missile->setFrame( 0 ); 00807 missile->setVelocity( shipDx + cosangle*MISSILE_SPEED, 00808 shipDy + sinangle*MISSILE_SPEED ); 00809 missiles.append( missile ); 00810 shotsFired++; 00811 reducePower( 1 ); 00812 00813 shootDelay = 5; 00814 } 00815 00816 if ( shootDelay ) 00817 shootDelay--; 00818 } 00819 00820 if ( teleportShip ) 00821 { 00822 int ra = qrand() % 10; 00823 if( ra == 0 ) 00824 ra += qrand() % 20; 00825 int xra = ra * 60 + ( (qrand() % 20) * (qrand() % 20) ); 00826 int yra = ra * 50 - ( (qrand() % 20) * (qrand() % 20) ); 00827 ship->setPos( xra, yra ); 00828 } 00829 00830 vitalsChanged = TRUE; 00831 } 00832 }
Here is the call graph for this function:

| void KAsteroidsView::processPowerups | ( | ) | [protected] |
Definition at line 836 of file view.cpp.
References can_destroy_powerups, Q3PtrListIterator< type >::current(), KPowerup::growOlder(), hits(), ID_BRAKE_POWERUP, ID_ENERGY_POWERUP, ID_MISSILE, ID_SHIELD_POWERUP, ID_SHOOT_POWERUP, ID_TELEPORT_POWERUP, Q3PtrList< type >::isEmpty(), MAX_BRAKES, MAX_FIREPOWER, MAX_POWER_LEVEL, MAX_SHIELDS, mBrakeCount, mShieldCount, mShootCount, mTeleportCount, powerups, shield, ship, shipPower, TRUE, vitalsChanged, and wrapSprite().
Referenced by timerEvent().
00837 { 00838 if ( !powerups.isEmpty() ) 00839 { 00840 // if player gets the powerup remove it from the screen, if option 00841 // "Can destroy powerups" is enabled and a missile hits the powerup 00842 // destroy it 00843 00844 KPowerup *pup; 00845 Q3PtrListIterator<KPowerup> it( powerups ); 00846 00847 for( ; it.current(); ++it ) 00848 { 00849 pup = it.current(); 00850 pup->growOlder(); 00851 00852 if( pup->expired() ) 00853 { 00854 powerups.removeRef( pup ); 00855 continue; 00856 } 00857 00858 wrapSprite( pup ); 00859 00860 QList<QGraphicsItem *> hits = pup->collidingItems(); 00861 QList<QGraphicsItem *>::Iterator it; 00862 for ( it = hits.begin(); it != hits.end(); ++it ) 00863 { 00864 if ( (*it) == ship ) 00865 { 00866 switch( pup->type() ) 00867 { 00868 case ID_ENERGY_POWERUP: 00869 shipPower += 150; 00870 if ( shipPower > MAX_POWER_LEVEL ) 00871 shipPower = MAX_POWER_LEVEL; 00872 break; 00873 case ID_TELEPORT_POWERUP: 00874 mTeleportCount++; 00875 break; 00876 case ID_BRAKE_POWERUP: 00877 if ( mBrakeCount < MAX_BRAKES ) 00878 mBrakeCount++; 00879 break; 00880 case ID_SHIELD_POWERUP: 00881 if ( mShieldCount < MAX_SHIELDS ) 00882 mShieldCount++; 00883 break; 00884 case ID_SHOOT_POWERUP: 00885 if ( mShootCount < MAX_FIREPOWER ) 00886 mShootCount++; 00887 break; 00888 } 00889 00890 powerups.removeRef( pup ); 00891 vitalsChanged = TRUE; 00892 } 00893 else if ( (*it) == shield ) 00894 { 00895 powerups.removeRef( pup ); 00896 } 00897 else if ( (*it)->type() == ID_MISSILE ) 00898 { 00899 if ( can_destroy_powerups ) 00900 { 00901 powerups.removeRef( pup ); 00902 } 00903 } 00904 } 00905 } 00906 } // -- if( powerups.isEmpty() ) 00907 }
Here is the call graph for this function:

| void KAsteroidsView::processShield | ( | ) | [protected] |
| double KAsteroidsView::randDouble | ( | ) | [protected] |
Definition at line 918 of file view.cpp.
References qrand().
Referenced by addExhaust(), addRocks(), processShip(), and rockHit().
00919 { 00920 int v = qrand(); 00921 return (double)v / (double)RAND_MAX; 00922 }
Here is the call graph for this function:

| int KAsteroidsView::randInt | ( | int | range | ) | [protected] |
Definition at line 924 of file view.cpp.
References qrand().
Referenced by addRocks(), processShip(), and rockHit().
00925 { 00926 return qrand() % range; 00927 }
Here is the call graph for this function:

| void KAsteroidsView::resizeEvent | ( | QResizeEvent * | event | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive widget resize events which are passed in the event parameter. When resizeEvent() is called, the widget already has its new geometry. The old size is accessible through QResizeEvent::oldSize().
The widget will be erased and receive a paint event immediately after processing the resize event. No drawing need be (or should be) done inside this handler.
Reimplemented from QWidget.
Definition at line 378 of file view.cpp.
References QWidget::event(), field, QWidget::height(), QWidget::resize(), QWidget::resizeEvent(), QGraphicsScene::setSceneRect(), view, and QWidget::width().
00379 { 00380 QWidget::resizeEvent(event); 00381 field.setSceneRect(0, 0, width()-4, height()-4); 00382 view.resize(width(),height()); 00383 }
Here is the call graph for this function:

| void KAsteroidsView::timerEvent | ( | QTimerEvent * | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive timer events for the object.
QTimer provides a higher-level interface to the timer functionality, and also more general information about timers. The timer event is passed in the event parameter.
Reimplemented from QObject.
Definition at line 387 of file view.cpp.
References QGraphicsScene::advance(), bits, QGraphicsTextItem::boundingRect(), emit, exhaust, FALSE, field, Q3PtrList< type >::first(), QRectF::height(), QGraphicsScene::height(), QGraphicsItem::hide(), QGraphicsItem::isVisible(), mFrameNum, QGraphicsItem::moveBy(), Q3PtrList< type >::next(), processMissiles(), processPowerups(), processShip(), Q3PtrList< type >::removeRef(), rocks, QGraphicsItem::sceneBoundingRect(), ship, textDy, textSprite, updateVitals(), vitalsChanged, wrapSprite(), and QRectF::y().
00388 { 00389 field.advance(); 00390 00391 AnimatedPixmapItem *rock; 00392 00393 // move rocks forward 00394 for ( rock = rocks.first(); rock; rock = rocks.next() ) { 00395 ((KRock *)rock)->nextFrame(); 00396 wrapSprite( rock ); 00397 } 00398 00399 wrapSprite( ship ); 00400 00401 // check for missile collision with rocks. 00402 processMissiles(); 00403 00404 // these are generated when a ship explodes 00405 for ( KBit *bit = bits.first(); bit; bit = bits.next() ) 00406 { 00407 if ( bit->expired() ) 00408 { 00409 bits.removeRef( bit ); 00410 } 00411 else 00412 { 00413 bit->growOlder(); 00414 bit->setFrame( ( bit->frame()+1 ) % bit->frameCount() ); 00415 } 00416 } 00417 00418 for ( KExhaust *e = exhaust.first(); e; e = exhaust.next() ) 00419 exhaust.removeRef( e ); 00420 00421 // move / rotate ship. 00422 // check for collision with a rock. 00423 processShip(); 00424 00425 // move powerups and check for collision with player and missiles 00426 processPowerups(); 00427 00428 if ( textSprite->isVisible() ) 00429 { 00430 if ( textDy < 0 && 00431 textSprite->boundingRect().y() <= -textSprite->boundingRect().height() ) { 00432 textSprite->hide(); 00433 } else { 00434 textSprite->moveBy( 0, textDy ); 00435 } 00436 00437 if ( textSprite->sceneBoundingRect().y() > (field.height()-textSprite->boundingRect().height())/2 ) 00438 textDy = 0; 00439 } 00440 00441 if ( vitalsChanged && !(mFrameNum % 10) ) { 00442 emit updateVitals(); 00443 vitalsChanged = FALSE; 00444 } 00445 00446 mFrameNum++; 00447 }
Here is the call graph for this function:

| void KAsteroidsView::showEvent | ( | QShowEvent * | e | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive widget show events which are passed in the event parameter.
Non-spontaneous show events are sent to widgets immediately before they are shown. The spontaneous show events of windows are delivered afterwards.
Note: A widget receives spontaneous show and hide events when its mapping status is changed by the window system, e.g. a spontaneous hide event when the user minimizes the window, and a spontaneous show event when the window is restored again. After receiving a spontaneous hide event, a widget is still considered visible in the sense of isVisible().
Reimplemented from QWidget.
Definition at line 929 of file view.cpp.
References FALSE, QMessageBox::information(), QWidget::showEvent(), and TRUE.
00930 { 00931 #if defined( QT_LICENSE_PROFESSIONAL ) 00932 static bool wasThere = FALSE; 00933 00934 if ( !wasThere ) { 00935 wasThere = TRUE; 00936 QMessageBox::information( this, tr("QCanvas demo"), 00937 tr("This game has been implemented using the QCanvas class.\n" 00938 "The QCanvas class is not part of the Professional Edition. Please \n" 00939 "contact Trolltech if you want to upgrade to the Enterprise Edition.") ); 00940 } 00941 #endif 00942 00943 QWidget::showEvent( e ); 00944 }
Here is the call graph for this function:

QGraphicsScene KAsteroidsView::field [private] |
Definition at line 112 of file view.h.
Referenced by addExhaust(), addRocks(), KAsteroidsView(), processShip(), readSprites(), resizeEvent(), rockHit(), showText(), timerEvent(), and wrapSprite().
QGraphicsView KAsteroidsView::view [private] |
QMap<int, QList<QPixmap> > KAsteroidsView::animation [private] |
Definition at line 114 of file view.h.
Referenced by addExhaust(), addRocks(), processShip(), readSprites(), and rockHit().
Q3PtrList<AnimatedPixmapItem> KAsteroidsView::rocks [private] |
Definition at line 115 of file view.h.
Referenced by addRocks(), KAsteroidsView(), reset(), rockHit(), and timerEvent().
Q3PtrList<KMissile> KAsteroidsView::missiles [private] |
Definition at line 116 of file view.h.
Referenced by KAsteroidsView(), processMissiles(), processShip(), and reset().
Q3PtrList<KBit> KAsteroidsView::bits [private] |
Definition at line 117 of file view.h.
Referenced by KAsteroidsView(), processShip(), reset(), and timerEvent().
Q3PtrList<KExhaust> KAsteroidsView::exhaust [private] |
Definition at line 118 of file view.h.
Referenced by addExhaust(), KAsteroidsView(), reset(), and timerEvent().
Q3PtrList<KPowerup> KAsteroidsView::powerups [private] |
Definition at line 119 of file view.h.
Referenced by KAsteroidsView(), processPowerups(), reset(), and rockHit().
KShield* KAsteroidsView::shield [private] |
Definition at line 120 of file view.h.
Referenced by hideShield(), KAsteroidsView(), newGame(), newShip(), processPowerups(), processShip(), readSprites(), reducePower(), and reset().
AnimatedPixmapItem* KAsteroidsView::ship [private] |
Definition at line 121 of file view.h.
Referenced by newShip(), processPowerups(), processShip(), readSprites(), reset(), and timerEvent().
QGraphicsTextItem* KAsteroidsView::textSprite [private] |
Definition at line 122 of file view.h.
Referenced by KAsteroidsView(), showText(), and timerEvent().
bool KAsteroidsView::rotateL [private] |
Definition at line 124 of file view.h.
Referenced by brake(), newShip(), processShip(), and rotateLeft().
bool KAsteroidsView::rotateR [private] |
Definition at line 125 of file view.h.
Referenced by brake(), newShip(), processShip(), and rotateRight().
bool KAsteroidsView::thrustShip [private] |
Definition at line 126 of file view.h.
Referenced by brake(), newShip(), processShip(), reducePower(), and thrust().
bool KAsteroidsView::shootShip [private] |
bool KAsteroidsView::teleportShip [private] |
bool KAsteroidsView::brakeShip [private] |
bool KAsteroidsView::pauseShip [private] |
bool KAsteroidsView::shieldOn [private] |
Definition at line 131 of file view.h.
Referenced by hideShield(), KAsteroidsView(), newGame(), newShip(), processShip(), reducePower(), and setShield().
bool KAsteroidsView::vitalsChanged [private] |
Definition at line 133 of file view.h.
Referenced by KAsteroidsView(), processPowerups(), processShip(), reducePower(), and timerEvent().
int KAsteroidsView::shipAngle [private] |
int KAsteroidsView::rotateSlow [private] |
Definition at line 136 of file view.h.
Referenced by newShip(), processShip(), rotateLeft(), and rotateRight().
int KAsteroidsView::rotateRate [private] |
int KAsteroidsView::shipPower [private] |
Definition at line 138 of file view.h.
Referenced by KAsteroidsView(), newShip(), power(), processPowerups(), reducePower(), and thrust().
int KAsteroidsView::shotsFired [private] |
int KAsteroidsView::shotsHit [private] |
int KAsteroidsView::shootDelay [private] |
int KAsteroidsView::mBrakeCount [private] |
Definition at line 144 of file view.h.
Referenced by brake(), brakeCount(), newShip(), processPowerups(), and processShip().
int KAsteroidsView::mShieldCount [private] |
Definition at line 145 of file view.h.
Referenced by hideShield(), newShip(), processPowerups(), processShip(), setShield(), and shieldCount().
int KAsteroidsView::mTeleportCount [private] |
Definition at line 146 of file view.h.
Referenced by newShip(), processPowerups(), teleport(), and teleportCount().
int KAsteroidsView::mShootCount [private] |
Definition at line 147 of file view.h.
Referenced by newShip(), processPowerups(), processShip(), and shootCount().
double KAsteroidsView::shipDx [private] |
double KAsteroidsView::shipDy [private] |
int KAsteroidsView::textDy [private] |
int KAsteroidsView::mFrameNum [private] |
bool KAsteroidsView::mPaused [private] |
int KAsteroidsView::mTimerId [private] |
double KAsteroidsView::rockSpeed [private] |
Definition at line 157 of file view.h.
Referenced by addRocks(), reset(), rockHit(), and setRockSpeed().
double KAsteroidsView::powerupSpeed [private] |
bool KAsteroidsView::can_destroy_powerups [private] |
QTimer* KAsteroidsView::shieldTimer [private] |
bool KAsteroidsView::initialized [private] |
Definition at line 163 of file view.h.
Referenced by addRocks(), brake(), KAsteroidsView(), newGame(), newShip(), pause(), reset(), setShield(), and showText().
1.5.1