Ejemplo n.º 1
0
bool CannonField::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0:
        setAngle((int)static_QUType_int.get(_o+1));
        break;
    case 1:
        setForce((int)static_QUType_int.get(_o+1));
        break;
    case 2:
        shoot();
        break;
    case 3:
        newTarget();
        break;
    case 4:
        setGameOver();
        break;
    case 5:
        restartGame();
        break;
    case 6:
        moveShot();
        break;
    default:
        return QWidget::qt_invoke( _id, _o );
    }
    return TRUE;
}
Ejemplo n.º 2
0
CannonField::CannonField(QWidget *parent) : QWidget(parent)
{
  currentAngle = 45;
  currentForce = 0;
  timerCount = 0;
  autoShootTimer = new QTimer(this);
  connect(autoShootTimer, SIGNAL(timeout()), this, SLOT(moveShot()));
  shootAngle = 0;
  shootForce = 0;
  setPalette(QPalette(QColor(250, 250, 200)));
  setAutoFillBackground(true);
  newTarget();
}
Ejemplo n.º 3
0
/*
 *  moveShots
 *  ------
 *  moves the shots towards the farthest along minion in wave
 */
void moveShots(void)
{
  int i,j;
  for (i=0;i<lastShot;i++){
    //    shot s = shots[i];
    for (j=0;j<Length(waves[waveNumber-1].m);j++) {
      if (waves[waveNumber-1].m[j].inPlay) {
	moveShot(i,waveNumber-1,j);
	break; /* only fire move shot towards the first minion */
      } /* end if minion in play */
    } /* end for each minion in the last wave */
  } /* end for until last shot */
}
Ejemplo n.º 4
0
CannonField::CannonField( QWidget *parent, const char *name )
        : QWidget( parent, name )
{
    ang = 45;
    f = 0;
    timerCount = 0;
    autoShootTimer = new QTimer( this, "movement handler" );
    connect( autoShootTimer, SIGNAL(timeout()),
             this, SLOT(moveShot()) );
    shoot_ang = 0;
    shoot_f = 0;
    target = QPoint( 0, 0 );
    setPalette( QPalette( QColor( 250, 250, 200) ) );
    newTarget();
}
Ejemplo n.º 5
0
PlayerShip::PlayerShip(int width, int height,
                       BattleField *battleField, QWidget *parent)
    : QWidget(parent)
{
    cout << "width: " << width << " height: " << height << endl;
    posShip.setX(width/2);
    posShip.setY(height -20);

    xmax = width-20, xmin = 20;
    ymax = 0, ymin= height-20;

    this->battleField = battleField;

    //emit canShoot(true);
    connect(battleField->autoShootTimer, SIGNAL(timeout()),
            this, SLOT(moveShot()));

}
Ejemplo n.º 6
0
// program code aways begins at the top of main()
int main(){
  //The next line is a function drom core.cpp
  // it sets up Allegro for graphics and keyboard
  techInit();
    
  gameSetup();
    
  while(key[KEY_ESC] == false){
    movePlayer();
    
    moveShot();
    
    drawThings();
    
    updateScreen();

    // is the game going too fast on your awesome modern hardware?
    // Experiment with numbers 0-15 here to slow down the application:
    rest(1);
    }
  return 0;
} END_OF_MAIN()// putting this line after the main() function