Skip to content
Snippets Groups Projects
Commit 52342ac7 authored by Joseph Walton-Rivers's avatar Joseph Walton-Rivers
Browse files

start of 2D game stuff

parent 4fc1eaed
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@ add_executable(demo
demo/grid.cpp
demo/robot/programmer.cpp
demo/models/viewer.cpp
demo/hexboard/board.cpp
)
target_include_directories(demo
......
/*
* This file is part of FGGL.
*
* FGGL is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* FGGL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with FGGL.
* If not, see <https://www.gnu.org/licenses/>.
*/
//
// Created by webpigeon on 10/12/22.
//
#include "hexboard/scene.hpp"
namespace demo::hexboard {
Scene::Scene(fggl::App &app) : GameBase(app), m_board(nullptr) {
}
void Scene::activate() {
m_board = std::make_unique<fggl::grid::HexGrid>();
}
void Scene::deactivate() {
m_board = nullptr;
}
void Scene::update(float delta) {
GameBase::update(delta);
// if the board is not set, abort
if ( m_board == nullptr ){
return;
}
}
void Scene::render(fggl::gfx::Graphics &gfx) {
// if the board is not set, abort
if ( m_board == nullptr ){
return;
}
// draw the grid
fggl::gfx::Paint paint;
gfx.draw2D(paint);
}
} // namespace demo::hexboard
\ No newline at end of file
......@@ -50,13 +50,14 @@
#include "topdown.hpp"
#include "grid.hpp"
#include "models/viewer.hpp"
#include "hexboard/scene.hpp"
static void setup_menu(fggl::App& app) {
auto *menu = app.addState<fggl::scenes::BasicMenu>("menu");
// add some menu items for the game states
const std::array labels = {"terrain", "rollball", "Top Down", "Grid World", "Viewer"};
const std::array scenes = {"game", "rollball", "topdown", "gridworld", "viewer"};
const std::array labels = {"terrain", "rollball", "Top Down", "Grid World", "Viewer", "gridworld"};
const std::array scenes = {"game", "rollball", "topdown", "gridworld", "viewer", "hexboard"};
for (std::size_t i = 0; i < labels.size(); ++i) {
std::string sceneName = scenes.at(i);
......@@ -131,6 +132,7 @@ int main(int argc, const char* argv[]) {
app.addState<demo::TopDown>("topdown");
app.addState<demo::GridScene>("gridworld");
app.addState<demo::Viewer>("viewer");
app.addState<demo::hexboard::Scene>("hexboard");
return app.run(argc, argv);
}
/*
* This file is part of FGGL.
*
* FGGL is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* FGGL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with FGGL.
* If not, see <https://www.gnu.org/licenses/>.
*/
//
// Created by webpigeon on 10/12/22.
//
#ifndef FGGL_DEMO_INCLUDE_HEXBOARD_BOARD_HPP
#define FGGL_DEMO_INCLUDE_HEXBOARD_BOARD_HPP
#include <cstdint>
namespace demo::hexboard {
constexpr uint64_t NO_SELECTION{0};
struct SelectionModel {
uint64_t m_hover = NO_SELECTION;
};
} // namespace demo::hexboard
#endif //FGGL_DEMO_INCLUDE_HEXBOARD_BOARD_HPP
/*
* This file is part of FGGL.
*
* FGGL is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* FGGL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with FGGL.
* If not, see <https://www.gnu.org/licenses/>.
*/
//
// Created by webpigeon on 10/12/22.
//
#ifndef FGGL_DEMO_INCLUDE_HEXBOARD_SCENE_H
#define FGGL_DEMO_INCLUDE_HEXBOARD_SCENE_H
#include <memory>
#include "fggl/scenes/game.hpp"
#include "fggl/grid/hexgrid.hpp"
namespace demo::hexboard {
class Scene : public fggl::scenes::GameBase {
public:
explicit Scene(fggl::App& app);
void activate() override;
void deactivate() override;
void update(float delta) override;
void render(fggl::gfx::Graphics& gfx) override;
private:
std::unique_ptr<fggl::grid::HexGrid> m_board;
};
} // namespace demo::hexboard
#endif //FGGL_DEMO_INCLUDE_HEXBOARD_SCENE_H
......@@ -225,7 +225,7 @@ namespace fggl::gfx {
};
inline Path2D make_shape(math::vec2 center, float radius, int sides, math::vec3 colour = colours::WHITE, ShapeOpts opts = {}) {
float angle = (M_PI * 2.0F) / sides;
float angle = (math::PI * 2.0F) / sides;
fggl::gfx::Path2D tileGfx(center);
tileGfx.colour(colour);
......
/*
* This file is part of FGGL.
*
* FGGL is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* FGGL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with FGGL.
* If not, see <https://www.gnu.org/licenses/>.
*/
//
// Created by webpigeon on 10/12/22.
//
#ifndef FGGL_GRID_HEXAGON_BOARD_HPP
#define FGGL_GRID_HEXAGON_BOARD_HPP
#include "fggl/grid/hexagon.hpp"
namespace fggl::grid {
class HexGrid {
};
} // namespace fggl::grid
#endif //FGGL_GRID_HEXAGON_BOARD_HPP
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment