//-----------------------------------------------------------------------------
void SoccerWorld::onCheckGoalTriggered(bool first_goal)
{
    if (isRaceOver() || isStartPhase())
        return;

    setPhase(WorldStatus::GOAL_PHASE);
    m_goal_sound->play();
    if (m_ball_hitter != -1)
    {
        if (UserConfigParams::m_arena_ai_stats)
        {
            const int elapsed_frame = m_goal_frame.empty() ? 0 :
                std::accumulate(m_goal_frame.begin(), m_goal_frame.end(), 0);
            m_goal_frame.push_back(m_frame_count - elapsed_frame);
        }

        ScorerData sd;
        sd.m_id = m_ball_hitter;
        sd.m_correct_goal = isCorrectGoal(m_ball_hitter, first_goal);

        if (sd.m_correct_goal)
        {
            m_karts[m_ball_hitter]->getKartModel()
                ->setAnimation(KartModel::AF_WIN_START, true/* play_non_loop*/);
        }

        else if (!sd.m_correct_goal)
        {
            m_karts[m_ball_hitter]->getKartModel()
                ->setAnimation(KartModel::AF_LOSE_START, true/* play_non_loop*/);
        }

        if (first_goal)
        {
            // Notice: true first_goal means it's blue goal being shoot,
            // so red team can score
            m_red_scorers.push_back(sd);
            if (race_manager->hasTimeTarget())
            {
                m_red_score_times.push_back(race_manager->getTimeTarget()
                    - getTime());
            }
            else
                m_red_score_times.push_back(getTime());
        }
        else
        {
            m_blue_scorers.push_back(sd);
            if (race_manager->hasTimeTarget())
            {
                m_blue_score_times.push_back(race_manager->getTimeTarget()
                    - getTime());
            }
            else
                m_blue_score_times.push_back(getTime());
        }
    }
    m_ball->reset();

}   // onCheckGoalTriggered
Пример #2
0
/*
*	Step the stepper motor connected through a stepper motor driver.
*	This has the same effect as step except phase not a parameter.
*	Only argument is time and should be in microseconds.
*/
void stepMotor::stepDriver(long time)
{
    if(time == -1)
    {
        time = micros();
    }
    if (timeDelay == -1)
    {
        setPhase(0);
    }
    else
    {
        if(time >= (lastStepTime + timeDelay))
        {
            if(dir)
            {
                digitalWrite(_dirPin,HIGH);
            }
            else
            {
                digitalWrite(_dirPin,LOW);
            }
            digitalWrite(_stepPin,HIGH);
            digitalWrite(_stepPin,LOW);
        }
    }
}
Пример #3
0
	//---------------------------------------------------
	TremoloDSP::TremoloDSP( XMLParser& parser, XMLNode* tremoloNode )
		:	DSP( MONKY_DSP_TYPE_TREMOLO )
	{
		const float NO_VALUE_SPECIFIED = -1000000000.0f;
		parser.validateXMLAttributes( tremoloNode, "", "type,frequency,depth,shape,timeSkewing,duty,flatness,phase,spread" );
		float frequency = parser.getXMLAttributeAsFloat( tremoloNode, "frequency", NO_VALUE_SPECIFIED );
		float depth = parser.getXMLAttributeAsFloat( tremoloNode, "depth", NO_VALUE_SPECIFIED );
		float shape = parser.getXMLAttributeAsFloat( tremoloNode, "shape", NO_VALUE_SPECIFIED );
		float timeSkewing = parser.getXMLAttributeAsFloat( tremoloNode, "timeSkewing", NO_VALUE_SPECIFIED );
		float duty = parser.getXMLAttributeAsFloat( tremoloNode, "duty", NO_VALUE_SPECIFIED );
		float flatness = parser.getXMLAttributeAsFloat( tremoloNode, "flatness", NO_VALUE_SPECIFIED );
		float phase = parser.getXMLAttributeAsFloat( tremoloNode, "phase", NO_VALUE_SPECIFIED );
		float spread = parser.getXMLAttributeAsFloat( tremoloNode, "spread", NO_VALUE_SPECIFIED );

		if( frequency != NO_VALUE_SPECIFIED )
			setFrequency( frequency );
		if( depth != NO_VALUE_SPECIFIED )
			setDepth( depth );
		if( shape != NO_VALUE_SPECIFIED )
			setShape( shape );
		if( timeSkewing != NO_VALUE_SPECIFIED )
			setTimeSkewing( timeSkewing );
		if( duty != NO_VALUE_SPECIFIED )
			setDuty( duty );
		if( flatness != NO_VALUE_SPECIFIED )
			setFlatness( flatness );
		if( phase != NO_VALUE_SPECIFIED )
			setPhase( phase );
		if( spread != NO_VALUE_SPECIFIED )
			setSpread( spread );
	}
Пример #4
0
bool STF_DDS::dds::setSweep(which_channel channel, sweep_type sweep, uInt32 startPoint, uInt32 endPoint, int delta, Int64 time)
{
	// for linear sweeps - start point (S0) is loaded into word 0 register
	// end point (e0) is loaded into word 1 register (0x0A) - MSB aligned as usual (ideally use setAmplitude, setPhase, etc... code)
	
	if (channel != currentChannel)
	{
		setChannel(channel, time-operationTime);
	}

	int address = 0x00 & 0x05;
	addressList.push_back(address);
	
	switch(sweep)
	{
		case amplitude :
			setAmplitude(channel, startPoint, time);
			break;
		case phase :
			setPhase(channel, startPoint, time);
			break;
		case frequency :
			setFrequency(channel, startPoint, time);
			break;
		default :
			std::cerr << "What did you want to do?" << std::endl;
			break;
	}
	return true;
}
Пример #5
0
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// generate
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
RawPcmData::Ptr AdditiveSynthesizer::generate( size_t length )
{
   RawPcmData* result = new RawPcmData( getSamplingInfo(), length );

   const std::vector< HarmonicInfo >& harmonicsInfo = getHarmonicsInfo();
   assert( harmonicsInfo.size() > 0 );

   std::vector< double > phase( harmonicsInfo.size() );
   for ( size_t iHarmonic = 0; iHarmonic < harmonicsInfo.size(); ++iHarmonic )
   {
      phase[ iHarmonic ] = harmonicsInfo[ iHarmonic ].getPhase();
   }

   for ( size_t iSample = 0; iSample < length; ++iSample )
   {
      double val = 0;
      for ( size_t iHarmonic = 0; iHarmonic < harmonicsInfo.size(); ++iHarmonic )
      {
         phase[ iHarmonic ] += harmonicsInfo[ iHarmonic ].getPhaseStep();
         val += harmonicsInfo[ iHarmonic ].getAmplitude() * sin( phase[ iHarmonic ] );
      }
      (*result)[ iSample ] = val * getCurrentSampleAmplitude();
      nextSample();
   }

   setPhase( fmod( phase[ 0 ], 2 * M_PI ) );

   return RawPcmData::Ptr( result );
}
Пример #6
0
BluetoothTransmitter::BluetoothTransmitter(BluetoothTransmitter& txbt)
{
    m_bitrate = 1;
    m_hf=txbt.m_hf;
    m_prev = txbt.m_prev;
    setPhase(txbt.getPhase());
}
Пример #7
0
void animate_moon(AppContextRef ctx, AppTimerHandle handle, uint32_t cookie) {
    (void)ctx;
    (void)handle;
    animationCount++;
    
    if(animationCount*animationStep <= 1 ){
        phasePercent += animationStep;
        if(phasePercent>=1)phasePercent--;
        layer_mark_dirty(&shadow_layer);
        timer_handle = app_timer_send_event(ctx, animationSpeed, 1);
    }
    else{
        PblTm t;
        get_time(&t);
        setPhase(daysSinceNewMoon(t.tm_year+1900,t.tm_yday,t.tm_hour));
        
        curHour=t.tm_hour;
        curMin=t.tm_min;
        curSec=t.tm_sec;
        layer_mark_dirty(&shadow_layer);
        layer_mark_dirty(&phase_layer);
        if(showHours){
            layer_mark_dirty(&hour_layer);
            layer_mark_dirty(&minute_layer);
            layer_mark_dirty(&top_layer);
        }
    }
}
Пример #8
0
void second_tick(AppContextRef ctx, PebbleTickEvent *t) {
    (void)ctx;
    
    curHour=t->tick_time->tm_hour;
    curMin=t->tick_time->tm_min;
    curSec=t->tick_time->tm_sec;

    if (showSeconds && (t->units_changed & SECOND_UNIT)) {
        layer_mark_dirty(&second_layer);
    }
    if (showMinutes && t->units_changed & MINUTE_UNIT) {
        layer_mark_dirty(&minute_layer);
        layer_mark_dirty(&hour_layer);
    }
    if (t->units_changed & HOUR_UNIT) {
        
        setPhase(daysSinceNewMoon(t->tick_time->tm_year+1900,t->tick_time->tm_yday,t->tick_time->tm_hour));
        
        layer_mark_dirty(&shadow_layer);
        layer_mark_dirty(&phase_layer);
        
        if(showHours){
            layer_mark_dirty(&top_layer);
        }
    }
}
Пример #9
0
void BackgroundImageGeometry::useFixedAttachment(
    const LayoutPoint& attachmentPoint) {
  LayoutPoint alignedPoint = attachmentPoint;
  m_phase.move(std::max(alignedPoint.x() - m_destRect.x(), LayoutUnit()),
               std::max(alignedPoint.y() - m_destRect.y(), LayoutUnit()));
  setPhase(LayoutPoint(roundedIntPoint(m_phase)));
}
Пример #10
0
void handle_init(AppContextRef ctx) {
    (void)ctx;

    window_init(&window, "Watchface");
    window_stack_push(&window, true /* Animated */);
    window_set_background_color(&window, GColorBlack);
        
    PblTm t;
    get_time(&t);
    setPhase(daysSinceNewMoon(t.tm_year+1900,t.tm_yday,t.tm_hour));
    
    curHour=t.tm_hour;
    curMin=t.tm_min;
    curSec=t.tm_sec;
    
    if(showDetailedMoonGraphic){
        
        resource_init_current_app(&LUNARCLOCK_IMAGE_RESOURCES);
        bmp_init_container(RESOURCE_ID_IMAGE_MOON, &moonimage_container);
        layer_add_child(&window.layer, &moonimage_container.layer.layer);
    }else{
        layer_init(&moon_layer, window.layer.frame);
        moon_layer.update_proc = &moon_layer_update_callback;
        layer_add_child(&window.layer, &moon_layer);
    }
    layer_init(&shadow_layer, window.layer.frame);
    shadow_layer.update_proc = &shadow_layer_update_callback;
    layer_add_child(&window.layer, &shadow_layer);
    
    layer_init(&phase_layer, window.layer.frame);
    phase_layer.update_proc = &phase_layer_update_callback;
    layer_add_child(&window.layer, &phase_layer);
    
    if(showHours){
        layer_init(&hour_layer, window.layer.frame);
        hour_layer.update_proc = &hour_layer_update_callback;
        layer_add_child(&window.layer, &hour_layer);
        
        gpath_init(&hour_hand, &hour_hand_info);
        gpath_move_to(&hour_hand, GPoint(centerx, centery));
        
    }
    if(showMinutes){
        layer_init(&minute_layer, window.layer.frame);
        minute_layer.update_proc = &minute_layer_update_callback;
        layer_add_child(&window.layer, &minute_layer);
        
        gpath_init(&minute_hand, &minute_hand_info);
        gpath_move_to(&minute_hand, GPoint(centerx, centery));
    }
    if(showSeconds){
        layer_init(&second_layer, window.layer.frame);
        second_layer.update_proc = &second_layer_update_callback;
        layer_add_child(&window.layer, &second_layer);
    }
    layer_init(&top_layer, window.layer.frame);
    top_layer.update_proc = &top_layer_update_callback;
    layer_add_child(&window.layer, &top_layer);
}
Пример #11
0
BluetoothTransmitter::BluetoothTransmitter(double hf,
                                           double phase_shift)
{
    m_bitrate = 1;          // 1 Mb/s
    m_hf = hf;              // Modulation index
    m_prev = false;         // Previous bit transmitted
    setPhase(phase_shift);  // Current phase
}
Пример #12
0
Oscillator::Oscillator(double sampleRate)
    : Generator(sampleRate, 0.0),
    curAngle(0.0)
{
    setAmplitude(1.0);
    setFrequency(440);
    setPhase(0);
}
Пример #13
0
PhaseItem::PhaseItem(AbstractScene* scene, const QJsonObject& phase, QGraphicsItem* parent):AbstractItem(scene, parent),
mState(Qt::Unchecked),
mEyeActivated(false),
mControlsVisible(true)
{
    mBorderWidth = 10;
    mEltsHeight = 15;
    setPhase(phase);
}
Пример #14
0
/** General update function called once per frame.
 *  \param dt Time step size.
 */
void OverWorld::update(float dt)
{
    // Skip annoying waiting without a purpose
    // Make sure to do all things that would normally happen in the
    // update() method of the base classes.
    if (getPhase() < GO_PHASE)
    {
        setPhase(RACE_PHASE);
        // Normally done in WorldStatus::update(), during phase SET_PHASE,
        // so we have to start music 'manually', since we skip all phases.
        World::getWorld()->getTrack()->startMusic();

        if (UserConfigParams::m_music)
            music_manager->startMusic();
        m_karts[0]->startEngineSFX();
    }
    World::update(dt);
    World::updateTrack(dt);
    const unsigned int kart_amount  = (unsigned int)m_karts.size();

    // isn't it cool, on the overworld nitro is free!
    for(unsigned int n=0; n<kart_amount; n++)
    {
        m_karts[n]->setEnergy(100.0f);
    }

    /*
    TrackObjectManager* tom = getTrack()->getTrackObjectManager();
    PtrVector<TrackObject>& objects = tom->getObjects();
    for(unsigned int i=0; i<objects.size(); i++)
    {
        TrackObject* obj = objects.get(i);
        if(!obj->isGarage())
            continue;

        float m_distance = obj->getDistance();
        Vec3 m_garage_pos = obj->getPosition();
        Vec3 m_kart_pos = getKart(0)->getXYZ();

        if ((m_garage_pos-m_kart_pos).length_2d() > m_distance)
        {
            obj->reset();
        }
    }
    */

    if (m_return_to_garage)
    {
        m_return_to_garage = false;
        race_manager->exitRace();
        KartSelectionScreen* s = OfflineKartSelectionScreen::getInstance();
        s->setMultiplayer(false);
        s->setFromOverworld(true);
        StateManager::get()->resetAndGoToScreen(s);
        throw AbortWorldUpdateException();
    }
}   // update
Пример #15
0
/*
 * Steps through the step sequence. If the time interval given in the input
 * is greater than the time delay for the motor's speed than the phase is set
 * to the next phase configuration.
 */
void stepMotor::step(long time)
{
    if(time == -1)
    {
        time = micros();
    }
    if (timeDelay == -1)
    {
        setPhase(0);
    }
    else
    {
        if(time >= (lastStepTime + timeDelay))
        {
            if (dir)
            {
                if(phase == 4)
                {
                    phase = 1;
                }
                else
                {
                    phase++;
                }
            }
            else
            {
                if(phase == 1)
                {
                    phase = 4;
                }
                else
                {
                    phase--;
                }
            }
            if (!shiftRegister)
            {
                setPhase(phase);
            }
            lastStepTime = time;
        }
    }
}
Пример #16
0
	Phasor(
		float sampleRate = 1000.0f,
		float frequency = 100.0f,
		float initialPhase = 0.0f
	)
	: OscillatorGenerator(sampleRate, frequency)
	{
		setPhase(initialPhase);
		_update();
	}
Пример #17
0
//-----------------------------------------------------------------------------
void SoccerWorld::onCheckGoalTriggered(bool first_goal)
{
    if (isRaceOver() || isStartPhase())
        return;

    setPhase(WorldStatus::GOAL_PHASE);
    m_goal_sound->play();
    if (m_ball_hitter != -1)
    {
        ScorerData sd;
        sd.m_id = m_ball_hitter;
        sd.m_correct_goal = isCorrectGoal(m_ball_hitter, first_goal);

        if (sd.m_correct_goal)
        {
            m_karts[m_ball_hitter]->getKartModel()
                ->setAnimation(KartModel::AF_WIN_START, true/* play_non_loop*/);
        }

        else if (!sd.m_correct_goal)
        {
            m_karts[m_ball_hitter]->getKartModel()
                ->setAnimation(KartModel::AF_LOSE_START, true/* play_non_loop*/);
        }

        if (first_goal)
        {
            // Notice: true first_goal means it's blue goal being shoot,
            // so red team can score
            m_red_scorers.push_back(sd);
            if (race_manager->hasTimeTarget())
            {
                m_red_score_times.push_back(race_manager->getTimeTarget()
                    - getTime());
            }
            else
                m_red_score_times.push_back(getTime());
        }
        else
        {
            m_blue_scorers.push_back(sd);
            if (race_manager->hasTimeTarget())
            {
                m_blue_score_times.push_back(race_manager->getTimeTarget()
                    - getTime());
            }
            else
                m_blue_score_times.push_back(getTime());
        }
    }
    m_ball->reset();

}   // onCheckGoalTriggered
Пример #18
0
/*==================  State functions	====================*/
void gotoMenuPhaseState(void)
{
	switch (menu_control(phase_table, phase_table_max))
	{
		case -2:
			break;
		case -1:
			setMenuCurrentState(MENU_IDLE_STATE);
			set_current_menu(0);			
			gotoMenuIdleState();
			break;
		case 0:
			setMenuCurrentState(MENU_MEASUREMENTS_STATE);
			set_current_menu(0);
			setPhase(1);	//setPhase('A');
			gotoMenuMeasurementState();
			break;
		case 1:
			setMenuCurrentState(MENU_MEASUREMENTS_STATE);
			set_current_menu(0);
			setPhase(2);	//setPhase('B');
			gotoMenuMeasurementState();
			break;
		case 2:
			setMenuCurrentState(MENU_MEASUREMENTS_STATE);
			set_current_menu(0);
			setPhase(3);	//setPhase('C');
			gotoMenuMeasurementState();
			break;
		case 3:
			setMenuCurrentState(MENU_MISC_STATE);
			set_current_menu(0);
			setPhase(0);	//setPhase('M');
			gotoMenuMiscState();
			break;
		default:
			break;
	}	
}	
Пример #19
0
void Player::setPhaseString(const QString &phase_str){
    static QMap<QString, Phase> phase_map;
    if(phase_map.isEmpty()){
        phase_map.insert("start",Start);
        phase_map.insert("judge", Judge);
        phase_map.insert("draw", Draw);
        phase_map.insert("play", Play);
        phase_map.insert("discard", Discard);
        phase_map.insert("finish", Finish);
        phase_map.insert("not_active", NotActive);
    }

    setPhase(phase_map.value(phase_str, NotActive));
}
Пример #20
0
/** The constructor sets the number of (local) players to 0, since only AI
 *  karts are used.
 */
DemoWorld::DemoWorld()
{
    // Profile mode sets the phase to RACE_PHASE, which means the track intro
    // is not shown, the music is not start, no countdown. So reset it to
    // the correct value.
    setPhase(SETUP_PHASE);
    m_abort = false;
    ProfileWorld::setProfileModeLaps(m_num_laps);
    race_manager->setReverseTrack(false);
    race_manager->setMinorMode (RaceManager::MINOR_MODE_NORMAL_RACE);
    race_manager->setDifficulty(RaceManager::DIFFICULTY_HARD);
    race_manager->setNumKarts(m_num_karts);
    race_manager->setNumLocalPlayers(1);
    race_manager->setLocalKartInfo(0, UserConfigParams::m_default_kart);

}   // DemoWorld
Пример #21
0
//constructor where all motor controlling pins are connected to arduino
stepMotor::stepMotor (int stepsPR, int a, int b, int c, int d)
{
    pin1 = a;
    pin2 = b;
    pin3 = c;
    pin4 = d;
    pinMode(pin1,OUTPUT);
    pinMode(pin2,OUTPUT);
    pinMode(pin3,OUTPUT);
    pinMode(pin4,OUTPUT);
    SPR = stepsPR;
    lastStepTime = 0;
    phase = 1;
    setPhase(phase);
    shiftRegister = false;
}
Пример #22
0
void Game::start(TimerFormat &aformat)
{
	format = new TimerFormat(aformat);
	int version = format->getVersion();


	if ( (version == 10) || (version == 11) || (version == 20) )
	{
		throneTrack->addHouse(1);
		throneTrack->addHouse(2);
		throneTrack->addHouse(3);
		if ( format->getPlayerCount() >= 4 )
		{
			throneTrack->addHouse(4);
		}
		if ( format->getPlayerCount() >= 5 )
		{
			throneTrack->addHouse(5);
		}
		if ( format->getPlayerCount() == 6 )
		{
			throneTrack->addHouse(6);
		}
	}

	totalTime = 0;
	gameTime = 0;

	for (int i = 0, count = format->getPlayerCount(); i < count; ++i)
	{
		HouseTimer* house = new HouseTimer();
		int id = format->getHouseAt(i);
		house->init(aformat.getReserve(), aformat.getPlanning(), aformat.getAction());
		house->setHouseId(id);
		houseMap[throneTrack->getHouseAt(i)] = house;
	}

	turn = 1;
	setPhase(PHASE_PLN);
	houseRunFlag = true;

	for (MAPIntHouseTimer_it i = houseMap.begin(), end = houseMap.end(); i != end; ++i)
	{
		std::cout << i->second->getHouseId() << std::endl;
	}
}
Пример #23
0
/** The constructor sets the number of (local) players to 0, since only AI
 *  karts are used.
 */
ProfileWorld::ProfileWorld()
{
    race_manager->setNumLocalPlayers(0);
    // Set number of laps so that the end of the race can be detected by
    // quering the number of finished karts from the race manager (in laps
    // based profiling) - in case of time based profiling, the number of
    // laps is set to 99999.
    race_manager->setNumLaps(m_num_laps);
    setPhase(RACE_PHASE);
    m_frame_count      = 0;
    m_start_time       = irr_driver->getRealTime();
    m_num_triangles    = 0;
    m_num_culls        = 0;
    m_num_solid        = 0;
    m_num_transparent  = 0;
    m_num_trans_effect = 0;
    m_num_calls        = 0;
}   // ProfileWorld
Пример #24
0
Lockin2::Lockin2(QObject *parent) :
    QObject(parent)
{
    //    _bufferWrite = new QBuffer(&_byteArray, this);
    //    _bufferWrite->open(QIODevice::WriteOnly | QIODevice::Unbuffered);

    //    _bufferRead = new QBuffer(&_byteArray, this);
    //    _bufferRead->open(QIODevice::ReadOnly | QIODevice::Unbuffered);
    _fifo = new QFifo(this);
    _fifo->open(QIODevice::ReadWrite /*| QIODevice::Unbuffered*/);

    _audioInput = 0;

    setOutputPeriod(0.5);
    setVumeterTime(0.0);
    setIntegrationTime(3.0);
    setPhase(0.0);
}
Пример #25
0
/** Ends the race early and places still active player karts at the back.
 *  The race immediately goes to the result stage, estimating the time for the
 *  karts still in the race. Still active player karts get a penalty in time
 *  as well as being placed at the back. Players that already finished keep
 *  their position.
 *
 *  End time for the punished players is calculated as follows
 *  end_time = current_time + (estimated_time - current_time)
 *                          + (estimated_time_for_last - current_time)
 *           = estimated_time + estimated_time_for_last - current_time
 *  This will put them at the end at all times. The further you (and the last in
 *  the race) are from the finish line, the harsher the punishment will be.
 */
void StandardRace::endRaceEarly()
{
    const unsigned int kart_amount = (unsigned int)m_karts.size();
    std::vector<int> active_players;
    // Required for debugging purposes
    beginSetKartPositions();
    for (unsigned int i = 1; i <= kart_amount; i++)
    {
        int kartid = m_position_index[i-1];
        AbstractKart* kart = m_karts[kartid];
        if (kart->hasFinishedRace())
        {
            // Have to do this to keep endSetKartPosition happy
            setKartPosition(kartid, kart->getPosition());
            continue;
        }

        if (kart->getController()->isPlayerController())
        {
            // Keep active players apart for now
            active_players.push_back(kartid);
        }
        else
        {
            // AI karts finish
            setKartPosition(kartid, i - (unsigned int) active_players.size());
            kart->finishedRace(estimateFinishTimeForKart(kart));
        }
    } // i <= kart_amount
    // Now make the active players finish
    for (unsigned int i = 0; i < active_players.size(); i++)
    {
        int kartid = active_players[i];
        int position = getNumKarts() - (int) active_players.size() + 1 + i;
        setKartPosition(kartid, position);
        m_karts[kartid]->eliminate();
    } // Finish the active players
    endSetKartPositions();
    setPhase(RESULT_DISPLAY_PHASE);
    if (!isNetworkWorld() || NetworkConfig::get()->isServer())
        terminateRace();
} // endRaceEarly
int ApproxLoadingElement::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    
#ifndef QT_NO_PROPERTIES
     if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< double*>(_v) = getPhase(); break;
        default: break;
        }
        _id -= 1;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setPhase(*reinterpret_cast< double*>(_v)); break;
        default: break;
        }
        _id -= 1;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 1;
    } else if (_c == QMetaObject::RegisterPropertyMetaType) {
        if (_id < 1)
            *reinterpret_cast<int*>(_a[0]) = -1;
        _id -= 1;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Пример #27
0
/*
 * 	Returns the step motor Byte sequence instead of setting the pins.
 * 	Inputs of time just like the step() and impliments timing the exact same
 * 	as in step().
 */
byte stepMotor::stepByte(long time)
{
    if(time == -1)
    {
        time = micros();
    }
    if (timeDelay == -1)
    {
        setPhase(0);
    }
    else
    {
        if(time >= (lastStepTime + timeDelay))
        {
            if (dir)
            {
                if(phase == 4)
                {
                    phase = 1;
                }
                else
                {
                    phase++;
                }
            }
            else
            {
                if(phase == 1)
                {
                    phase = 4;
                }
                else
                {
                    phase--;
                }
            }
            lastStepTime = time;
        }
        return bytePhase(phase);
    }
}
Пример #28
0
float* ofxFftw::ifft(float* a, float* b, fftMode mode) {
	if(mode == OF_FFT_POLAR) {
		setAmplitude(a);
		setPhase(b);
		updateCartesian();
	} else if(mode == OF_FFT_CARTESIAN) {
		setReal(a);
		setImaginary(b);
	}

	memcpy(ifftIn, amplitude, sizeof(float) * bins);
	for(int i = 1; i < signalSize; i++)
		ifftIn[signalSize - i] = phase[i];

	fftwf_execute(ifftPlan);

	setSignal(ifftOut);
	signalReady = false;

	return getSignal();
}
Пример #29
0
/** Update the world and the track.
 *  \param dt Time step size.
 */
void SoccerWorld::update(float dt)
{
    updateBallPosition(dt);
    if (m_track->hasNavMesh())
    {
        updateKartNodes();
        updateAIData();
    }

    WorldWithRank::update(dt);
    WorldWithRank::updateTrack(dt);

    if (getPhase() == World::GOAL_PHASE)
    {
        if (m_goal_timer == 0.0f)
        {
            // Stop all karts
            for (unsigned int i = 0; i < m_karts.size(); i++)
                m_karts[i]->setVelocity(btVector3(0, 0, 0));
        }
        m_goal_timer += dt;

        if (m_goal_timer > 3.0f)
        {
            setPhase(WorldStatus::RACE_PHASE);
            m_goal_timer = 0.0f;
            if (!isRaceOver())
            {
                // Reset all karts
                for (unsigned int i = 0; i < m_karts.size(); i++)
                    moveKartAfterRescue(m_karts[i]);
                if (UserConfigParams::m_arena_ai_stats)
                    getKart(8)->flyUp();
            }
        }
    }
    if (UserConfigParams::m_arena_ai_stats)
        m_frame_count++;

}   // update
/** Update the world and the track.
 *  \param ticks Physics time steps - should be 1.
 */
void SoccerWorld::update(int ticks)
{
    updateBallPosition(ticks);
    if (Track::getCurrentTrack()->hasNavMesh())
    {
        updateSectorForKarts();
        updateAIData();
    }

    WorldWithRank::update(ticks);
    WorldWithRank::updateTrack(ticks);

    if (getPhase() == World::GOAL_PHASE)
    {
        if (m_goal_timer == 0)
        {
            // Stop all karts
            for (unsigned int i = 0; i < m_karts.size(); i++)
                m_karts[i]->setVelocity(btVector3(0, 0, 0));
        }
        m_goal_timer += ticks;

        if (m_goal_timer > stk_config->time2Ticks(3.0f))
        {
            setPhase(WorldStatus::RACE_PHASE);
            m_goal_timer = 0;
            if (!isRaceOver())
            {
                // Reset all karts
                for (unsigned int i = 0; i < m_karts.size(); i++)
                    moveKartAfterRescue(m_karts[i]);
                if (UserConfigParams::m_arena_ai_stats)
                    getKart(8)->flyUp();
            }
        }
    }
    if (UserConfigParams::m_arena_ai_stats)
        m_frame_count++;

}   // update