summaryrefslogtreecommitdiff
path: root/noncore/games/bounce/game.cpp
authoralwin <alwin>2004-03-02 12:21:11 (UTC)
committer alwin <alwin>2004-03-02 12:21:11 (UTC)
commitb6b1c97559c0ed9f2e33632272426bf98f289232 (patch) (unidiff)
treed3a9987704770cdf5eb14e1136f6e3ecb2f36a04 /noncore/games/bounce/game.cpp
parent0d59c780513da78033f4d9040475dee9db0256d4 (diff)
downloadopie-b6b1c97559c0ed9f2e33632272426bf98f289232.zip
opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.gz
opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.bz2
applied the patch generated by the optimize_connect script from
TT.
Diffstat (limited to 'noncore/games/bounce/game.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/bounce/game.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/noncore/games/bounce/game.cpp b/noncore/games/bounce/game.cpp
index c07f453..1f1f8cd 100644
--- a/noncore/games/bounce/game.cpp
+++ b/noncore/games/bounce/game.cpp
@@ -300,55 +300,55 @@ JezzGame::JezzGame( int ballNum, QWidget *parent, const char *name )
300 m_ballPixmaps->image(n)->setOffset( 0, 0 ); 300 m_ballPixmaps->image(n)->setOffset( 0, 0 );
301 301
302 m_arrowPixmaps = new QCanvasPixmapArray( path + "arrow%1.png", 2 ); 302 m_arrowPixmaps = new QCanvasPixmapArray( path + "arrow%1.png", 2 );
303 for ( unsigned n=0; n < m_arrowPixmaps->count(); n++ ) 303 for ( unsigned n=0; n < m_arrowPixmaps->count(); n++ )
304 m_arrowPixmaps->image(n)->setOffset( 0, 0 ); 304 m_arrowPixmaps->image(n)->setOffset( 0, 0 );
305 305
306 QPixmap tiles( path + "tiles.png" ); 306 QPixmap tiles( path + "tiles.png" );
307 307
308 // create field 308 // create field
309 m_field = new JezzField( tiles, this, "m_field" ); 309 m_field = new JezzField( tiles, this, "m_field" );
310 m_field->resize( TILE_SIZE*FIELD_WIDTH, TILE_SIZE*FIELD_HEIGHT ); 310 m_field->resize( TILE_SIZE*FIELD_WIDTH, TILE_SIZE*FIELD_HEIGHT );
311 311
312 for ( int x=0; x<FIELD_WIDTH; x++ ) 312 for ( int x=0; x<FIELD_WIDTH; x++ )
313 m_field->setTile( x, 0, TILE_BORDER ); 313 m_field->setTile( x, 0, TILE_BORDER );
314 for ( int y=1; y<FIELD_HEIGHT-1; y++ ) 314 for ( int y=1; y<FIELD_HEIGHT-1; y++ )
315 { 315 {
316 m_field->setTile( 0, y, TILE_BORDER ); 316 m_field->setTile( 0, y, TILE_BORDER );
317 for ( int x=1; x<FIELD_WIDTH-1; x++ ) 317 for ( int x=1; x<FIELD_WIDTH-1; x++ )
318 m_field->setTile( x, y, TILE_FREE ); 318 m_field->setTile( x, y, TILE_FREE );
319 m_field->setTile( FIELD_WIDTH-1, y, TILE_BORDER ); 319 m_field->setTile( FIELD_WIDTH-1, y, TILE_BORDER );
320 } 320 }
321 for ( int x=0; x<FIELD_WIDTH; x++ ) 321 for ( int x=0; x<FIELD_WIDTH; x++ )
322 m_field->setTile( x, FIELD_HEIGHT-1, TILE_BORDER ); 322 m_field->setTile( x, FIELD_HEIGHT-1, TILE_BORDER );
323 323
324 connect( m_field, SIGNAL(ballCollision(Ball *, int, int, int)), this, SLOT(ballCollision(Ball *, int, int, int)) ); 324 connect( m_field, SIGNAL(ballCollision(Ball*,int,int,int)), this, SLOT(ballCollision(Ball*,int,int,int)) );
325 325
326 // create view 326 // create view
327 m_view = new JezzView( m_field, this, "m_view" ); 327 m_view = new JezzView( m_field, this, "m_view" );
328 m_view->move( 0, 0 ); 328 m_view->move( 0, 0 );
329 m_view->adjustSize(); 329 m_view->adjustSize();
330 connect( m_view, SIGNAL(buildWall(int, int, bool)), this, SLOT(buildWall(int, int, bool)) ); 330 connect( m_view, SIGNAL(buildWall(int,int,bool)), this, SLOT(buildWall(int,int,bool)) );
331 331
332 // create balls 332 // create balls
333 for ( int n=0; n<ballNum; n++ ) 333 for ( int n=0; n<ballNum; n++ )
334 { 334 {
335 Ball *ball = new Ball( m_ballPixmaps, m_field ); 335 Ball *ball = new Ball( m_ballPixmaps, m_field );
336 m_balls.append( ball ); 336 m_balls.append( ball );
337 ball->setVelocity( ((rand() & 1)*2-1)*2, ((rand() & 1)*2-1)*2 ); 337 ball->setVelocity( ((rand() & 1)*2-1)*2, ((rand() & 1)*2-1)*2 );
338 ball->setFrame( rand() % 25 ); 338 ball->setFrame( rand() % 25 );
339 ball->move( 4*TILE_SIZE + ( rand() - 50 ) % ( (FIELD_WIDTH-8)*TILE_SIZE ), 339 ball->move( 4*TILE_SIZE + ( rand() - 50 ) % ( (FIELD_WIDTH-8)*TILE_SIZE ),
340 4*TILE_SIZE + rand() % ( (FIELD_HEIGHT-8)*TILE_SIZE ) ); 340 4*TILE_SIZE + rand() % ( (FIELD_HEIGHT-8)*TILE_SIZE ) );
341 ball->show(); 341 ball->show();
342 } 342 }
343 343
344 // create arrow 344 // create arrow
345 arrow = new Arrow( m_arrowPixmaps, m_field ); 345 arrow = new Arrow( m_arrowPixmaps, m_field );
346 arrow->show(); 346 arrow->show();
347 347
348 // create text label 348 // create text label
349 m_text = new QCanvasText( m_field ); 349 m_text = new QCanvasText( m_field );
350 350
351 // create game clock 351 // create game clock
352 m_clock = new QTimer( this ); 352 m_clock = new QTimer( this );
353 connect( m_clock, SIGNAL(timeout()), this, SLOT(tick()) ); 353 connect( m_clock, SIGNAL(timeout()), this, SLOT(tick()) );
354 m_clock->start( GAME_DELAY ); 354 m_clock->start( GAME_DELAY );
@@ -504,59 +504,59 @@ void JezzGame::ballCollision( Ball*, int, int, int tile )
504} 504}
505 505
506void JezzGame::buildWall( int x, int y, bool vertical ) 506void JezzGame::buildWall( int x, int y, bool vertical )
507{ 507{
508 if ( !m_running ) return; 508 if ( !m_running ) return;
509 509
510 if ( m_field->tile(x, y)==TILE_FREE ) 510 if ( m_field->tile(x, y)==TILE_FREE )
511 { 511 {
512 // check whether there is a ball at the moment 512 // check whether there is a ball at the moment
513 QCanvasItemList cols = m_field->collisions( QRect(x*TILE_SIZE, y*TILE_SIZE, TILE_SIZE, TILE_SIZE) ); 513 QCanvasItemList cols = m_field->collisions( QRect(x*TILE_SIZE, y*TILE_SIZE, TILE_SIZE, TILE_SIZE) );
514 if ( cols.count()>0 ) 514 if ( cols.count()>0 )
515 { 515 {
516 //kdDebug() << "Direct collision" << endl; 516 //kdDebug() << "Direct collision" << endl;
517 emit ballCollision( (Ball*)cols.first(), x, y, TILE_WALLUP ); 517 emit ballCollision( (Ball*)cols.first(), x, y, TILE_WALLUP );
518 return; 518 return;
519 } 519 }
520 520
521 // start walls 521 // start walls
522 if ( !m_wall1 ) 522 if ( !m_wall1 )
523 { 523 {
524 m_wall1 = new Wall( m_field, x, y, 524 m_wall1 = new Wall( m_field, x, y,
525 vertical? Wall::Up : Wall::Left, 525 vertical? Wall::Up : Wall::Left,
526 vertical? TILE_WALLUP : TILE_WALLLEFT, 526 vertical? TILE_WALLUP : TILE_WALLLEFT,
527 this, "m_wall1" ); 527 this, "m_wall1" );
528 connect( m_wall1, SIGNAL(finished(Wall *, int)), 528 connect( m_wall1, SIGNAL(finished(Wall*,int)),
529 this, SLOT(wallFinished(Wall *, int)) ); } 529 this, SLOT(wallFinished(Wall*,int)) ); }
530 530
531 if ( !m_wall2 ) 531 if ( !m_wall2 )
532 { 532 {
533 m_wall2 = new Wall( m_field, x, y, 533 m_wall2 = new Wall( m_field, x, y,
534 vertical? Wall::Down: Wall::Right, 534 vertical? Wall::Down: Wall::Right,
535 vertical? TILE_WALLDOWN : TILE_WALLRIGHT, 535 vertical? TILE_WALLDOWN : TILE_WALLRIGHT,
536 this, "m_wall2" ); 536 this, "m_wall2" );
537 connect( m_wall2, SIGNAL(finished(Wall *, int)), 537 connect( m_wall2, SIGNAL(finished(Wall*,int)),
538 this, SLOT(wallFinished(Wall *, int)) ); 538 this, SLOT(wallFinished(Wall*,int)) );
539 } 539 }
540 } 540 }
541} 541}
542 542
543void JezzGame::wallFinished( Wall *wall, int tile ) 543void JezzGame::wallFinished( Wall *wall, int tile )
544{ 544{
545 if ( tile==TILE_WALLEND ) 545 if ( tile==TILE_WALLEND )
546 { 546 {
547 if ( m_wall1 ) 547 if ( m_wall1 )
548 { 548 {
549 m_wall1->fill( false ); 549 m_wall1->fill( false );
550 delete m_wall1; 550 delete m_wall1;
551 m_wall1 = 0; 551 m_wall1 = 0;
552 } 552 }
553 553
554 if ( m_wall2 ) 554 if ( m_wall2 )
555 { 555 {
556 m_wall2->fill( false ); 556 m_wall2->fill( false );
557 delete m_wall2; 557 delete m_wall2;
558 m_wall2 = 0; 558 m_wall2 = 0;
559 } 559 }
560 } else 560 } else
561 { 561 {
562 if ( m_wall1==wall && m_wall1 ) 562 if ( m_wall1==wall && m_wall1 )