BosonX/src/generator/gen1.cpp

35 lines
641 B
C++

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