Пример #1
0
 void FieldManager::start(long width, long height, int numberOfThreads) {
   currentIteration = 0;
   stopped = false;
   numberOfiterations = LONG_MAX;
   this->numberOfThreads = numberOfThreads;
   generateField(width, height);
 }
Пример #2
0
/*
 * Just starts a new level
 */
void startLevel() {
    pieceCount = 0x00;
    gamePaused = 0x01;

    // annimation beetween levels
    // there is two annimations to show:
    // - a simple shift of the last image to left
    // - a shift to left with a men pushing
    if (level % 4 == 0 && level != 0) {
        playMusic(2);
        pushLeftAll(displayField);
        rollNumber('l', level, 10, 1000);
        rollNumber('p', score, 10, 1000);
    } else {
        shiftLeftAll(displayField);
    }

    playMusic(0);
    delay(1900);
    playMusic(3);

    generateField();        // new field
    generatePiece();        // new piece
    addPiece();             // adds the new piece to fild
    updateDisplayField();   // updates the display field
    limit = 0x11;           // sets the checkLines limit to default

    gamePaused = 0x00;
}
Пример #3
0
void GameObjectLoader::loadLevel(string path)
{
	vector<glm::fvec2> wallsPos;
	glm::fvec2 playerPos;
	glm::fvec2 whiteHolePos;
	GLuint fieldSize;
	ifstream levelFile;
	levelFile.open(path);
	string buffer;
	getline(levelFile, buffer);
	try {
		fieldSize = stoi(buffer);
	}
	catch (invalid_argument e)
	{
		cerr << "Error on reading level";
		return;
	}
	GLint radius = fieldSize / 2;
	// Read and parse file
	for (unsigned int i = 0; i < fieldSize; i++)
	{
		getline(levelFile, buffer);
		const char * line = buffer.c_str();
		for (unsigned int j = 0; j < fieldSize; j++)
		{
			glm::fvec2 curPos = glm::fvec2(- radius + (int)j, - radius + (int)i);
			switch (line[j])
			{
				case '0':
					break;
				case '1':
				{
					wallsPos.push_back(curPos);
				}break;
				case '2':
				{
					whiteHolePos = curPos;
				}break;
				case '3':
				{
					playerPos = curPos;
				}break;
				default:
				{
					throw invalid_argument("Incorrect file format");
				}
			}
		}
	}
	
	generateField(glm::fvec2(0.0f, 0.0f), fieldSize);
	for (glm::fvec2 curPos : wallsPos)
		createWall(curPos);
	createPlayer(playerPos);
	creatWhiteHole(whiteHolePos);
	EnergyBar * bar = new EnergyBar(glm::fvec2(-1.0f + 0.255 + 0.01f, 1.0f - 0.128 - 0.01f), loader, font);
	this->manager->addObject(bar);
	this->manager->swapWalls();
}
Пример #4
0
 void FieldManager::start(ll width, ll height, int numberOfThreads) {
   if (height < numberOfThreads) {
     numberOfThreads = height;
     out << "too many threads, made number of threads equal height of field" << std::endl;
   }
   this->numberOfThreads = numberOfThreads;
   stopped = true;
   generateField(width, height);
   sendInitialParts();
 }
Пример #5
0
void GameField::reset()
{
	for (size_t row = 0; row < rowCount; row++)
	{
		for (size_t col = 0; col < colCount; col++)
		{
			front[row][col] = Clip::CELL_INIT;
		}
	}
	generateField();
	pressedRow = INF;
	pressedCol = INF;
	gameState = GameState::INIT;
}
Пример #6
0
GameField::GameField(Config* config)
	: cfg(config), rowCount(cfg->getFieldRowCnt()), colCount(cfg->getFieldColCnt()), mineCount(cfg->getMineCnt()), front(nullptr), back(nullptr), pressedRow(INF), pressedCol(INF), gameState(GameState::INIT), topBarHeight(0)
{
	front = new size_t*[rowCount];
	back = new size_t*[rowCount];
	for (size_t row = 0; row < rowCount; row++)
	{
		front[row] = new size_t[colCount];
		back[row] = new size_t[colCount];

		for (size_t col = 0; col < colCount; col++)
		{
			front[row][col] = Clip::CELL_INIT;
			back[row][col] = Clip::CELL_PRESSED;
		}
	}
	topBarHeight = 2 + cfg->getClip(Clip::SMILE_INIT)->h + 2;
	generateField();
}
Пример #7
0
void SP_DPCodeRender :: generateStruct( SP_DPSyntaxStruct * structure, FILE * writer )
{
	char structName[ 128 ] = { 0 };

	mNameRender->getStructBaseName( structure->getName(), structName, sizeof( structName ) );

	fprintf( writer, "typedef struct tag%s {\n", structName );

	SP_DPSyntaxFieldVector * flist = structure->getFieldList();

	SP_DPSyntaxFieldVector::iterator fit = flist->begin();

	for( ; flist->end() != fit; ++fit ) {
		generateField( &(*fit), writer );

		if( '\0' != *(fit->getReferTo()) && flist->end() != ( fit + 1 ) ) {
			fprintf( writer, "\n" );
		}
	}

	fprintf( writer, "} %s_t;\n", structName );
}