Skip to content

OpenSiv3D Sample [v0.2.X 0.3.X]

Kasugaccho edited this page Apr 30, 2019 · 1 revision

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

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

#include <Siv3D.hpp>
#include <DTL.hpp>

#include <cstdint>
#include <cstddef>
#include <array>
#include <bitset>

void Main() {

	constexpr std::size_t matrix_size{ 128 };
	constexpr std::size_t dungeon_pixel_size{ 2 };

	Window::Resize(int32(matrix_size*dungeon_pixel_size), int32(matrix_size*dungeon_pixel_size));

	std::array<std::bitset<matrix_size>, matrix_size> matrix{ {} };
	const dtl::generator::terrain::stl::SimpleVoronoiIsland<bool> create(matrix);
	dtl::utility::stl::noiseShoreBool(matrix);

	while (System::Update())
		for (std::size_t row{}; row < matrix.size(); ++row)
			for (std::size_t col{}; col < matrix[row].size(); ++col)
				Rect(int32(col*dungeon_pixel_size), int32(row*dungeon_pixel_size), int32(dungeon_pixel_size)).draw((matrix[row][col]) ? Color(98, 170, 48) : Color(30, 30, 163));

}

sample

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

#include <Siv3D.hpp>
#include <DTL.hpp>

#include <cstdint>
#include <cstddef>
#include <array>
#include <bitset>

void Main() {

	constexpr std::size_t matrix_size_x{ 196 };
	constexpr std::size_t matrix_size_y{ 128 };
	constexpr std::size_t dungeon_pixel_size{ 2 };

	Window::Resize(int32(matrix_size_x*dungeon_pixel_size), int32(matrix_size_y*dungeon_pixel_size));

	std::array<std::bitset<matrix_size_x>, matrix_size_y> matrix{ {} };
	const dtl::generator::terrain::stl::SimpleVoronoiIsland<bool> create(matrix);
	dtl::utility::stl::noiseShoreBool(matrix);

	while (System::Update())
		for (std::size_t row{}; row < matrix.size(); ++row)
			for (std::size_t col{}; col < matrix[row].size(); ++col)
				Rect(int32(col*dungeon_pixel_size), int32(row*dungeon_pixel_size), int32(dungeon_pixel_size)).draw((matrix[row][col]) ? Color(98, 170, 48) : Color(30, 30, 163));

}

sample2

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

#include <Siv3D.hpp>
#include <DTL.hpp>

#include <cstdint>
#include <cstddef>
#include <array>
#include <bitset>

void Main() {

	constexpr std::size_t matrix_size_x{ 196 };
	constexpr std::size_t matrix_size_y{ 128 };
	constexpr std::size_t dungeon_pixel_size{ 2 };

	Window::Resize(int32(matrix_size_x*dungeon_pixel_size), int32(matrix_size_y*dungeon_pixel_size));

	std::array<std::bitset<matrix_size_x>, matrix_size_y> matrix{ {} };
	const dtl::generator::terrain::stl::SimpleVoronoiIsland<bool> generation;

	constexpr int loop_counter_max{ 20 };
	int loop_counter{ loop_counter_max };

	while (System::Update()) {
		if (loop_counter >= loop_counter_max) {
			dtl::utility::stl::init(matrix);
			generation.create(matrix);
			dtl::utility::stl::noiseShoreBool(matrix);
			loop_counter = 0;
		}
		for (std::size_t row{}; row < matrix.size(); ++row)
			for (std::size_t col{}; col < matrix[row].size(); ++col)
				Rect(int32(col*dungeon_pixel_size), int32(row*dungeon_pixel_size), int32(dungeon_pixel_size)).draw((matrix[row][col]) ? Color(98, 170, 48) : Color(30, 30, 163));
		++loop_counter;
	}
}

sample3

Clone this wiki locally