Exemplo n.º 1
0
	void ZombieGame::makeGameStep() {
		float time = engine_.getTime();

		// Update all game entities.
		for (Car2D& car : cars_) {
			if (car.getBody() != nullptr) {
				car.updatePhysics(time, timeStep_);
			}
		}
		
		// filter out the valid spawningpoints
		calculateValidSpawningPoints(units_[0]);
		
		for (Unit& unit : units_) {
			if (unit.isActive()) {
				// move the unit if to far away
				moveUnits(unit, units_[0]);
				unit.updatePhysics(time, timeStep_);
			}
		}

		for (Missile& missile : missiles_) {
			if (missile.isActive()) {
				missile.updatePhysics(time, timeStep_);
			}
		}

		// Update the human and ai input.
		for (auto& player : players_) {
			player->updateInput(time, timeStep_);
		}

		// Update the engine.
		engine_.update(timeStep_);
	}
Exemplo n.º 2
0
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
 char * filename;
 FILE * fid;
 int buflen;
 char * method;

 char fileType[8];
 unsigned char version[2];
 char fileFormatAdditional[2];
 unsigned long headerSize;
 unsigned int timeResTimeStamps;
 unsigned int timeResSamples;
 unsigned short timeOrigin[8];
 char application[32];
 char comment[256];
 long extendedHeaderNumber;

 /* Get filename */
 buflen = mxGetM(prhs[0]) * mxGetN(prhs[0])+1;
 filename = mxCalloc(buflen, sizeof(char));
 mxGetString(prhs[0], filename, buflen);
 fid = fopen(filename,"rb+");

 /* Read the header */
 fread(fileType, 1, 8, fid);
 fread(version, 1, 2, fid);
 fread(fileFormatAdditional, 1, 2, fid);
 fread(&headerSize, 4, 1, fid);
 fread(&packetSize, 4, 1, fid);
 fread(&timeResTimeStamps, 4, 1, fid);
 fread(&timeResSamples, 4, 1, fid);
 fread(&timeOrigin, 2, 8, fid);
 fread(application, 1, 32, fid);
 fread(comment, 1, 256, fid);
 fread(&extendedHeaderNumber,4,1,fid);

 numSamples = (packetSize-8)/bytesPerSample;

 /* Get the task type */
 method = (char *) mxGetPr(prhs[1]);

 fseek(fid,headerSize,SEEK_SET);

 switch(*method)
 {
 case 'm':
   /* Move waveforms from one sort code to another sort code */
   moveUnits(fid,*mxGetPr(prhs[2]),*mxGetPr(prhs[3]));
   break;
 case 't':
   /* Threshold spikes at some +- value and move to a sort code */
   thresholdSpikes(fid,*mxGetPr(prhs[2]),*mxGetPr(prhs[3]),1);
   break;
 case 'n':
   /* Mark electrical noise by synchrony across channels, move to a sort code */
   markElectricalNoise(fid,*mxGetPr(prhs[2]),*mxGetPr(prhs[3]));
   break;
 case 'h':
   /* Move all spikes which DON'T exceed a thresholde +- value */
   thresholdSpikes(fid,*mxGetPr(prhs[2]),*mxGetPr(prhs[3]),0);
   break;   
 }

 fclose(fid);
}