-
-
Notifications
You must be signed in to change notification settings - Fork 81
openFrameworks
Kasugaccho edited this page Apr 12, 2019
·
9 revisions
#include "ofMain.h"
#include "DTL.hpp"
#include <cstdint>
#include <cstddef>
#include <array>
#include <bitset>
constexpr std::size_t matrix_size{ 128 };
constexpr std::size_t dungeon_pixel_size{ 2 };
class ofApp : public ofBaseApp {
private:
std::array<std::bitset<matrix_size>, matrix_size> matrix{ {} };
public:
void setup() {
const dtl::generator::terrain::stl::SimpleVoronoiIsland<bool> create(matrix);
dtl::utility::stl::noiseShoreBool(matrix);
}
void draw() {
for (std::size_t row{}; row < matrix.size(); ++row)
for (std::size_t col{}; col < matrix[row].size(); ++col) {
(matrix[row][col]) ? ofSetColor(98, 170, 48) : ofSetColor(30, 30, 163);
ofDrawRectangle(float(col*dungeon_pixel_size), float(row*dungeon_pixel_size), float(dungeon_pixel_size), float(dungeon_pixel_size));
}
}
};
int main() {
ofSetupOpenGL(int(matrix_size*dungeon_pixel_size), int(matrix_size*dungeon_pixel_size), OF_WINDOW);
ofRunApp(new ofApp());
return 0;
}
#include "ofMain.h"
#include "DTL.hpp"
#include <cstdint>
#include <cstddef>
#include <array>
#include <bitset>
constexpr std::size_t matrix_size_x{ 196 };
constexpr std::size_t matrix_size_y{ 128 };
constexpr std::size_t dungeon_pixel_size{ 2 };
class ofApp : public ofBaseApp {
private:
std::array<std::bitset<matrix_size_x>, matrix_size_y> matrix{ {} };
public:
void setup() {
const dtl::generator::terrain::stl::SimpleVoronoiIsland<bool> create(matrix);
dtl::utility::stl::noiseShoreBool(matrix);
}
void draw() {
for (std::size_t row{}; row < matrix.size(); ++row)
for (std::size_t col{}; col < matrix[row].size(); ++col) {
(matrix[row][col]) ? ofSetColor(98, 170, 48) : ofSetColor(30, 30, 163);
ofDrawRectangle(float(col*dungeon_pixel_size), float(row*dungeon_pixel_size), float(dungeon_pixel_size), float(dungeon_pixel_size));
}
}
};
int main() {
ofSetupOpenGL(int(matrix_size_x*dungeon_pixel_size), int(matrix_size_y*dungeon_pixel_size), OF_WINDOW);
ofRunApp(new ofApp());
return 0;
}
#include "ofMain.h"
#include "DTL.hpp"
#include <cstdint>
#include <cstddef>
#include <array>
#include <bitset>
constexpr std::size_t matrix_size_x{ 196 };
constexpr std::size_t matrix_size_y{ 128 };
constexpr std::size_t dungeon_pixel_size{ 2 };
constexpr int loop_counter_max{ 20 };
class ofApp : public ofBaseApp {
private:
std::array<std::bitset<matrix_size_x>, matrix_size_y> matrix{ {} };
int loop_counter{ loop_counter_max };
public:
void update() {
if (loop_counter >= loop_counter_max) {
dtl::utility::stl::init(matrix);
const dtl::generator::terrain::stl::SimpleVoronoiIsland<bool> create(matrix);
dtl::utility::stl::noiseShoreBool(matrix);
loop_counter = 0;
}
++loop_counter;
}
void draw() {
for (std::size_t row{}; row < matrix.size(); ++row)
for (std::size_t col{}; col < matrix[row].size(); ++col) {
(matrix[row][col]) ? ofSetColor(98, 170, 48) : ofSetColor(30, 30, 163);
ofDrawRectangle(float(col*dungeon_pixel_size), float(row*dungeon_pixel_size), float(dungeon_pixel_size), float(dungeon_pixel_size));
}
}
};
int main() {
ofSetupOpenGL(int(matrix_size_x*dungeon_pixel_size), int(matrix_size_y*dungeon_pixel_size), OF_WINDOW);
ofRunApp(new ofApp());
return 0;
}
Copyright (c) 2018-2021 As Project.
Distributed under the Boost Software License, Version 1.0.(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)