BosonX/src/generator/gen2.cpp

29 lines
587 B
C++
Raw Normal View History

2022-08-20 16:32:37 +02:00
#include "../generator.h"
#include "../level.h"
#include <stdlib.h>
#define N PLATFORM_COUNT
2022-08-20 16:32:37 +02:00
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 = N - 1;
if (this->last_pos >= N)
2022-08-20 16:32:37 +02:00
this->last_pos = 0;
for (int i = 0; i < N; ++i) {
2022-08-20 16:32:37 +02:00
if (i == this->last_pos)
section.platforms[i].type = PLATFORM_WHITE;
2022-08-24 20:40:21 +02:00
else
section.platforms[i].type =
(rand() % 2) ? PLATFORM_EMPTY : PLATFORM_WHITE;
2022-08-20 16:32:37 +02:00
}
level->section_buffer.push_back(section);
}