Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Show : public ApplicationListener {
- std::vector<std::unique_ptr<ApplicationListener>> apps{};
- size_t current_app = 0;
- size_t prev_app = 0;
- public:
- Show() {
- apps.push_back(std::make_unique<StartScreen>());
- apps.push_back(std::make_unique<Gradius>());
- apps.push_back(std::make_unique<GameOver>());
- prev_app = apps.size();
- current_app = 0;
- }
- void OnRender(Context &ctx) override {
- if (prev_app != current_app) {
- if (prev_app != apps.size()) {
- apps.at(prev_app)->OnDispose(ctx);
- }
- apps.at(current_app)->OnCreate(ctx);
- prev_app = current_app;
- }
- apps.at(current_app)->OnRender(ctx);
- if (IsClicked(ctx, Button::KEY_G)) {
- current_app = (current_app + 1) % apps.size();
- LogInfo("Transition to the %d", current_app);
- }
- if (IsClicked(ctx, Button::KEY_ESCAPE)) {
- ExitApp(ctx);
- }
- }
- ~Show() override {
- apps.clear();
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement