Skip to content

openFrameworks

Kasuga Chiyo edited this page Feb 27, 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;
}
Clone this wiki locally