Dawn/src/dawntictactoe/scenes/TicTacToeScene.hpp

60 lines
2.0 KiB
C++

// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "scene/Scene.hpp"
#include "prefabs/SimpleSpinningCubePrefab.hpp"
#include "prefabs/TicTacToeTilePrefab.hpp"
#include "display/mesh/TriangleMesh.hpp"
#include "components/TicTacToeGame.hpp"
namespace Dawn {
class TicTacToeScene : public Scene {
protected:
Camera *camera;
void stage() override {
camera = Camera::create(this);
// camera->transform->lookAt(glm::vec3(0, 0, 5), glm::vec3(0, 0, 0));
// camera->type = CAMERA_TYPE_ORTHONOGRAPHIC;
camera->transform->lookAt(glm::vec3(1, 2, 3), glm::vec3(0, 0, 0));
float_t s = 2.0f;
camera->orthoTop = s;
camera->orthoBottom = -s;
float_t ratio = 1.0f / 9.0f * 16.0f;
camera->orthoLeft = -s * ratio;
camera->orthoRight = s * ratio;
auto cube = SimpleSpinningCubePrefab::create(this);
// TriangleMesh::createTriangleMesh(&cube->meshHost->mesh);
// SphereMesh::createSphere(&cube->meshHost->mesh, 1.0f, 16, 16);
auto gameItem = this->createSceneItem();
auto game = gameItem->addComponent<TicTacToeGame>();
int32_t i = 0;
for(int32_t x = -1; x <= 1; x++) {
for(int32_t y = -1; y <= 1; y++) {
auto tile = TicTacToeTilePrefab::create(this);
tile->transform.setLocalPosition(glm::vec3(x * 1.25f, y * 1.25f, 0));
// tile->ticTacToe->setState(i % 2 == 0 ? TIC_TAC_TOE_CROSS : TIC_TAC_TOE_NOUGHT);
}
}
}
std::vector<Asset*> getRequiredAssets() override {
auto assMan = &this->game->assetManager;
std::vector<Asset*> assets;
vectorAppend(&assets, SimpleSpinningCubePrefab::getRequiredAssets(assMan));
vectorAppend(&assets, TicTacToeTilePrefab::getRequiredAssets(assMan));
return assets;
}
public:
TicTacToeScene(DawnGame *game) : Scene(game) {}
};
}