Ejemplo n.º 1
0
void EnemyView::animate(int dt)
{
	Enemy::animate(dt);

	/* CHANGEMENT DE FRAME */
	cpt_time += dt;
	if(cpt_time >= animations[current_anim].getSpeed())
	{
		setNextFrame();
		cpt_time = 0;
	}

	if(type == REBEL)
	{
		if(state_b==PRESHOOT && animations[current_anim].getIndFrame() == 10)
			shoot(save_air,save_angle);
		else if(state_b==KNIFE && current_anim==REBEL_WATCH)
		{
			state_b = NORMAL;
			if(haveAI)
				walk(walkway);
		}
	}

	if(type == BOWSER)
	{
		if(state_b==PRESHOOT && animations[current_anim].getIndFrame() == 4)
			shoot(save_air,save_angle);
		else if(state_b==SHOOT && current_anim==BOWSER_STAND)
		{
			state_b = NORMAL;
			state_p = RUN;
		}
	}

	updateIntRect();
}
Ejemplo n.º 2
0
int main(int argc, char **argv)
{
  dev_name = "/dev/video0";
  

  if (argc == 1)
    {
      usage(stdout, argc, argv);
      exit(EXIT_SUCCESS);
    }

  for (;; ) {
    int idx;
    int c;
    
    c = getopt_long(argc, argv,
		    short_options, long_options, &idx);
    
    if (-1 == c)
      break;

    switch (c) {
    case 0: /* getopt_long() flag */
      break;
      
    case 'd':
      dev_name = optarg;
      break;
      
    case 'h':
      usage(stdout, argc, argv);
      exit(EXIT_SUCCESS);
      
    case 'i':
      iframe = 1;
      break;
      
    case 'r':
      if (!strcmp(optarg, "VBR"))
	rcmode = RATECONTROL_VBR;
      
      if (!strcmp(optarg, "CBR"))
	rcmode = RATECONTROL_CBR;
      
      if (!strcmp(optarg, "QP"))
	rcmode = RATECONTROL_CONST_QP;
      
      if (rcmode < 0)
	{
	  fprintf(stderr, "Unknown RC mode.\n");
	  usage(stdout, argc, argv);
	  exit(EXIT_SUCCESS);
	}
      
      break;
      
    case 'b':
      errno = 0;
      bitrate = strtol(optarg, NULL, 0);
      if (errno)
	errno_exit(optarg);
      break;

    case 'q':
      errno = 0;
      qp = strtol(optarg, NULL, 0);
      if (errno)
	errno_exit(optarg);
      break;
      
    default:
      usage(stderr, argc, argv);
      exit(EXIT_FAILURE);
    }
  }
  
  open_device();
  
  if (bitrate > 0)
    setBitrate(bitrate / 8, bitrate / 8);
  
  if (iframe)
    setNextFrame(0x01);
  
  if (rcmode >= 0)
    setRCMode(rcmode);

  if (qp > 0)
    setQP(0, qp, qp);

  close_device();
  return 0;
}
Ejemplo n.º 3
0
Logger::Logger(QObject *parent) :
    QObject(parent)
{
    mPort = new SerialPort(this);
    mPacketInterface = new PacketInterface(this);

    mValueFile = new QFile("Data/BLDC_Values");
    mPrintFile = new QFile("Data/BLDC_Print");

    mValueFile->open(QIODevice::WriteOnly | QIODevice::Text);
    mPrintFile->open(QIODevice::WriteOnly | QIODevice::Text);

    mValueStream = new QTextStream(mValueFile);
    mPrintStream = new QTextStream(mPrintFile);

    mPort->openPort("/dev/ttyACM0");

    // Video
    mVidW = 1280;
    mVidH = 720;
    mVidFps = 25.0;
    mFAudioSamp = 44100;

    mFrameGrabber = new FrameGrabber(mVidW, mVidH, mVidFps, 0, this);
    mFrameGrabber->start(QThread::InheritPriority);
    mPlotter = new FramePlotter(this);
    mPlotter->start(QThread::InheritPriority);

    mCoder = new VideoCoder(mVidW, mVidH, mVidFps, "Data/v_video.avi", this);
    mCoder->start(QThread::InheritPriority);

    // Audio recording
    mTimer = 0;
    mAudio = 0;

    if (QAudioDeviceInfo::availableDevices(QAudio::AudioInput).size() > 0) {
        mAudioFile.setFileName("Data/v_audio.raw");
        mAudioFile.open(QIODevice::WriteOnly | QIODevice::Truncate);

        QAudioFormat format;
        // Set up the desired format, for example:
        format.setSampleRate(mFAudioSamp);
        format.setChannelCount(1);
        format.setSampleSize(8);
        format.setCodec("audio/pcm");
        format.setByteOrder(QAudioFormat::LittleEndian);
        format.setSampleType(QAudioFormat::UnSignedInt);

        QAudioDeviceInfo info = QAudioDeviceInfo::defaultInputDevice();
        if (!info.isFormatSupported(format)) {
            qWarning() << "Default format not supported, trying to use the nearest.";
            format = info.nearestFormat(format);
        }

        mAudio = new QAudioInput(format, this);
        mAudio->setNotifyInterval(1000 / mVidFps);
        mAudio->start(&mAudioFile);
    } else {
        mTimer = new QTimer(this);
        mTimer->setInterval(1000 / mVidFps);
        mTimer->start();
    }

    mConsoleReader = new ConsoleReader(this);

    connect(mConsoleReader, SIGNAL(textReceived(QString)),
            this, SLOT(consoleLineReceived(QString)));

    connect(mPort, SIGNAL(serial_data_available()),
            this, SLOT(serialDataAvailable()));

    if (mTimer != 0) {
        connect(mTimer, SIGNAL(timeout()), this, SLOT(timerSlot()));
    }

    if (mAudio != 0) {
        connect(mAudio, SIGNAL(notify()),
                this, SLOT(audioNotify()));

        // Lower the volume to avoid clipping. This seems to be passed to
        // pulseaudio.
        mAudio->setVolume(0.1);
    }

    connect(mPacketInterface, SIGNAL(dataToSend(QByteArray&)),
            this, SLOT(packetDataToSend(QByteArray&)));
    connect(mPacketInterface, SIGNAL(valuesReceived(PacketInterface::MC_VALUES)),
            this, SLOT(mcValuesReceived(PacketInterface::MC_VALUES)));
    connect(mPacketInterface, SIGNAL(printReceived(QString)),
            this, SLOT(printReceived(QString)));
    connect(mPacketInterface, SIGNAL(samplesReceived(QByteArray)),
            this, SLOT(samplesReceived(QByteArray)));
    connect(mPacketInterface, SIGNAL(rotorPosReceived(double)),
            this, SLOT(rotorPosReceived(double)));
    connect(mPacketInterface, SIGNAL(experimentSamplesReceived(QVector<double>)),
            this, SLOT(experimentSamplesReceived(QVector<double>)));

    connect(mPlotter, SIGNAL(frameReady(QImage)),
            mCoder, SLOT(setNextFrame(QImage)));
}