BosonX/src/generator/gen2.cpp

28 lines
601 B
C++

#include "../generator.h"
#include "../level.h"
#include <stdlib.h>
gen2::gen2() : last_pos{0} { srand(123456); }
void gen2::generate(level_t *level)
{
struct section section;
this->last_pos += (rand() % 3) - 1;
if (this->last_pos < 0)
this->last_pos = PLATFORM_COUNT - 1;
if (this->last_pos >= PLATFORM_COUNT)
this->last_pos = 0;
for (int i = 0; i < PLATFORM_COUNT; ++i) {
if (i == this->last_pos)
section.platforms[i].type = PLATFORM_WHITE;
else
section.platforms[i].type =
(rand() % 2) ? PLATFORM_EMPTY : PLATFORM_WHITE;
}
level->section_buffer.push_back(section);
}