void GameRoot::spawnRandomNode(float top, float bottom) { static int counter = 0; int r = rand(); int val = r % 100; enum FigureType type; if (counter < GAME_RANDOM_ROW) { type = FigureScore; counter++; } else if (val < 50) { type = FigureScore; } else { if (val < 60) { type = FigureBorder; } else if (val < 70) { type = FigureAccelerator; } else if (val < 80) { type = FigureDeccelerator; } else if (val < 90) { type = FigureRepair; } else if (val < 100) { type = FigureShield; } counter = 0; } float pos = bottom + (top - bottom) * ((float) r / (float) RAND_MAX); spawnNode(m_obContentSize.height / 2 + pos, 0, type, GAME_BORDER_DURABILITY, GAME_BORDER_DURABILITY); }
void SpawnScript::runScripts() { if(this->useSpawn) { spawnNode(); } }
void SpawnScript::spawnBullet() { if(scene->nodes["player"] != NULL) { spawnloc = scene->nodes["player"]->meshInst->T.translation; didSpawnBullet = true; spawnNode(); } }
void GameRoot::raceSpawnProc(float fDeltha) { static float spawnTimer = 0, directPos = 0, directRate = 0; float pathDeltha = fDeltha * gameSpeedRate; spawnTimer += pathDeltha; if (spawnTimer > GAME_SPAWN_RATE) { float diff = spawnTimer - GAME_SPAWN_RATE; if (fabsf(directPos) > m_obContentSize.height - GAME_RACE_DIRECT_SIZE * 2 - GAME_RACE_DIRECT_MIN) { if (directPos > 0 && directRate > 0) { directRate = 0; } else if (directPos < 0 && directRate < 0) { directRate = 0; } } int r = rand(); directRate += r % GAME_RACE_DIRECT_RATE - (GAME_RACE_DIRECT_RATE / 2); directPos += directRate * fDeltha; spawnNode(m_obContentSize.height / 2 - GAME_RACE_DIRECT_SIZE + directPos + GAME_RACE_DIRECT_SHIFT, diff, FigureBorder, GAME_BORDER_DURABILITY, GAME_BORDER_DURABILITY); spawnNode(m_obContentSize.height / 2 + GAME_RACE_DIRECT_SIZE + directPos + GAME_RACE_DIRECT_SHIFT, diff, FigureBorder, GAME_BORDER_DURABILITY, GAME_BORDER_DURABILITY); spawnTimer -= GAME_SPAWN_RATE; } static float randomSpawnRate = GAME_RANDOM_START; if (randomSpawnRate < 0) { spawnRandomNode(GAME_RACE_DIRECT_SIZE + directPos - 100, - GAME_RACE_DIRECT_SIZE + directPos + 100); randomSpawnRate = GAME_RANDOM_MIN + rand() % (GAME_RANDOM_MAX - GAME_RANDOM_MIN); } randomSpawnRate -= pathDeltha; gamePathLength += pathDeltha; gameSpeedRate += fDeltha * gameSpeedAcceleration; }