Пример #1
0
//update cell info
void update(int *cell) {
	int lifetime = getLifeTime(cell);

	if (cell[TYPE] == EXPOSED && ETOZ(cell[AGE]))
		exposedToZombie(cell);
	else if (DIE(cell[AGE], lifetime))
		reset(cell);
	else
		++(cell[AGE]);
	cell[MOVED] = false;
}
Пример #2
0
string Packet::toString() const{
	// Serialize this object for the network

	string delimiter = "\n";

	stringstream serialization;
	
	serialization << getType();

	serialization << delimiter;

	struct tm *nowtm;
	char tmbuf[64] ;
	
	nowtm = localtime(&timeSent);
	strftime(tmbuf, sizeof tmbuf, "%Y-%m-%d %H:%M:%S", nowtm);
	
	string timeString (tmbuf);

	serialization << timeString;

	serialization << delimiter;

	serialization << getLifeTime(); 

	serialization << delimiter;

	serialization << getPacketNumber();

	serialization << delimiter;

	serialization << getHopCount();

	serialization << delimiter;
	
	serialization << getSourceAddress();

	serialization << delimiter;

	serialization << getDestinationAddress();

	serialization << delimiter;

	serialization << getPayload();

	return serialization.str();
}
Пример #3
0
/*!
  Informs that the particle position has been updated by the particle system.
  The QGLSceneNode is updated to move the visual representation of the particle.
*/
void LightParticle::particleUpdated()
{
    if (isActive() == true) {
        float psize = getLifeTime() * 2.0f;

        if (psize > 1.0f)
            psize = 1.0f;

        QMatrix4x4 mat;
        mat.rotate(m_Rotation[2], 0,0,1);
        mat.scale(psize);

        setLocalTransform(mat);
        setPosition(m_ParticlePos);
    }
    else {
        setPosition(QVector3D());
    }
}
Пример #4
0
//update cell info
void update(int *cell) {
	int isBorn;

	int lifetime = getLifeTime(cell);
	if (cell[TYPE] == EMPTY) {
		isBorn = random(0, 500);
		if (isBorn == true){
			cell[TYPE]  = HUMAN;
			cell[AGE]   = 0;
			cell[SPEED] = HSPEED;
		}
	}
	else if (cell[TYPE] == EXPOSED && ETOZ (cell[AGE]))
		exposedToZombie(cell);
	else if (DIE(cell[AGE], lifetime))
		reset(cell);
	else
		++(cell[AGE]);

	cell[MOVED] = false;
}