Skip to content

openFrameworks

Kasugaccho edited this page Apr 12, 2019 · 9 revisions

ใ‚ตใƒณใƒ—ใƒซใ‚ณใƒผใƒ‰[v0.2.X-0.3.X]

็ธฆๆจช ๅŒใ˜ใ‚ตใ‚คใ‚บใงๅœฐๅฝข็”Ÿๆˆ

#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;
}

sample

็ธฆๆจช ็•ฐใชใ‚‹ใ‚ตใ‚คใ‚บใงๅœฐๅฝข็”Ÿๆˆ

#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;
}

sample2

็”Ÿๆˆใƒซใƒผใƒ—

#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;
}

sample3

ๅฝ“่จ˜ไบ‹ใฎใƒฉใ‚คใ‚ปใƒณใ‚น

CC0

Clone this wiki locally