add struts

This commit is contained in:
Yann MAGNIN 2022-08-20 13:00:23 +02:00
parent 96ec759657
commit e8a624a9e9
3 changed files with 72 additions and 1 deletions

View File

@ -9,7 +9,8 @@ find_package(Gint 2.8 REQUIRED)
find_package(LibProf 2.1 REQUIRED)
set(SOURCES
src/main.cpp)
src/main.cpp
src/generator.cpp)
set(ASSETS)
fxconv_declare_assets(${ASSETS} WITH_METADATA)

51
src/bosonx.h Normal file
View File

@ -0,0 +1,51 @@
#ifndef __BOSONX__
# define __BOSONX__
#include <vector>
#ifndef PLATFORM_COUNT
# define PLATFORM_COUNT 10
#endif
typedef enum {
PLATFORM_EMPTY,
PLATFORM_WHITE,
PLATFORM_RED,
PLATFORM_BLUE,
PLATFORM_BLOCK
} platform_type_t;
struct platform {
platform_type_t type;
//TODO blink ? meta...
};
struct section {
struct platform platforms[PLATFORM_COUNT];
//...
};
typedef struct level {
std::vector<struct section> section_buffer;
// ...
} level_t ;
struct generator
{
virtual void generate(level_t *) = 0;
virtual ~generator() = default;
};
struct gen1 : public generator
{
gen1();
void generate(level_t *) override;
~gen1() override = default;
int last_pos;
};
#endif /* __BOSONX__ */

19
src/generator.cpp Normal file
View File

@ -0,0 +1,19 @@
#include "bosonx.h"
gen1::gen1() : last_pos{0} { }
void gen1::generate(level_t *level)
{
struct section section;
this->last_pos += 1;
this->last_pos %= PLATFORM_COUNT;
for (int i = 0; i < PLATFORM_COUNT; ++i) {
section.platforms[i].type = PLATFORM_EMPTY;
if (i == this->last_pos)
section.platforms[i].type = PLATFORM_WHITE;
}
level->section_buffer.push_back(section);
}