Skip to content
Kasugaccho edited this page Apr 30, 2019 · 26 revisions

>> Old

0.4.X

CellularAutomatonMixIsland

#include <DTL.hpp>
#include <DxLib.h>

namespace System {
	bool Update() noexcept { return (DxLib::ScreenFlip() != -1 && DxLib::ProcessMessage() != -1); }
}

void Main();

int WINAPI WinMain([[maybe_unused]]HINSTANCE hInstance, [[maybe_unused]]HINSTANCE hPrevInstance, [[maybe_unused]]LPSTR lpCmdLine, [[maybe_unused]]int nCmdShow) {
	DxLib::SetOutApplicationLogValidFlag(FALSE);
	DxLib::ChangeWindowMode(TRUE);
	DxLib::SetGraphMode(512, 512, 32);
	if (DxLib::DxLib_Init() == -1) return -1;
	DxLib::SetDrawScreen(DX_SCREEN_BACK);
	DxLib::SetMainWindowText("Sample");
	Main();
	return DxLib::DxLib_End();
}

constexpr int hachi{ 2 };
template<typename Matrix_>
void output(const Matrix_& matrix_) {
	int a{}, b{}, c{};
	for (std::size_t y{}; y < matrix_.size(); ++y)
		for (std::size_t x{}; x < matrix_[y].size(); ++x) {
			a = dtl::random::mt32bit.get<int>(20) - 10;
			b = dtl::random::mt32bit.get<int>(20) - 10;
			c = dtl::random::mt32bit.get<int>(20) - 10;
			switch (matrix_[y][x]) {
			case 0:
				DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi, GetColor(41 + a, 40 + b, 159 + c), TRUE);
				break;
			case 1:
				DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi, GetColor(101 + a, 163 + b, 56 + c), TRUE);
				break;
			case 2:
				DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi, GetColor(223 + a, 203 + b, 140 + c), TRUE);
				break;
			case 3:
				DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi, GetColor(9, 100 + b, 5), TRUE);
				break;
			case 4:
				DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi, GetColor(164 + a, 143 + b, 50 + c), TRUE);
				break;
			}
		}
}

void Main() {

	using shape_t = std::uint_fast8_t;
	constexpr std::size_t width{ 256 };
	constexpr std::size_t height{ 256 };
	std::array<std::array<shape_t, width>, height> matrix{ {} };

	constexpr int update_fps{ 30 };
	int now_fps{ update_fps };
	while (System::Update()) {
		++now_fps;
		if (now_fps < update_fps) continue;
		now_fps = 0;
		dtl::CellularAutomatonMixIsland<shape_t>(60, 0, 1, 2, 3, 4).draw(matrix);
		output(matrix);
	}

}
#include <DTL.hpp>
#include <DxLib.h>

namespace System {
	bool Update() noexcept { return (DxLib::ScreenFlip() != -1 && DxLib::ProcessMessage() != -1); }
}

void Main();

int WINAPI WinMain([[maybe_unused]]HINSTANCE hInstance, [[maybe_unused]]HINSTANCE hPrevInstance, [[maybe_unused]]LPSTR lpCmdLine, [[maybe_unused]]int nCmdShow) {
	DxLib::SetOutApplicationLogValidFlag(FALSE);
	DxLib::ChangeWindowMode(TRUE);
	DxLib::SetGraphMode(512, 512, 32);
	if (DxLib::DxLib_Init() == -1) return -1;
	DxLib::SetDrawScreen(DX_SCREEN_BACK);
	DxLib::SetMainWindowText("Sample");
	Main();
	return DxLib::DxLib_End();
}

void Main() {

	using shape_t = std::uint_fast8_t;
	constexpr std::size_t width{ 256 };
	constexpr std::size_t height{ 256 };
	std::array<std::array<shape_t, width>, height> matrix{ {} };

	constexpr int length{ 2 };
	constexpr int update_fps{ 30 };
	int now_fps{ update_fps };
	while (System::Update()) {
		++now_fps;
		if (now_fps < update_fps) continue;
		now_fps = 0;
		dtl::CellularAutomatonMixIsland<shape_t>(100, 0, 1, 2, 3, 4).draw(matrix);

		dtl::OutputView<shape_t, int>(length).draw(matrix, [](const shape_t value_, const int x_, const int y_, const int w_, const int h_) {
			const int a{ dtl::random::mt32bit.get<int>(20) - 10 };
			const int b{ dtl::random::mt32bit.get<int>(20) - 10 };
			const int c{ dtl::random::mt32bit.get<int>(20) - 10 };
			unsigned int color{};
			switch (value_) {
			case 0:color = DxLib::GetColor(41 + a, 40 + b, 159 + c); break;
			case 1:color = DxLib::GetColor(101 + a, 163 + b, 56 + c); break;
			case 2:color = DxLib::GetColor(223 + a, 203 + b, 140 + c); break;
			case 3:color = DxLib::GetColor(9, 100 + b, 5); break;
			case 4:color = DxLib::GetColor(164 + a, 143 + b, 50 + c); break;
			}
			DxLib::DrawBox(x_ * w_, y_ * h_, x_ * w_ + w_, y_ * h_ + h_, color, TRUE);
			});
	}
}

DiamondSquareAverageIsland

#include <DTL.hpp>
#include <DxLib.h>

namespace System {
	bool Update() noexcept { return (DxLib::ScreenFlip() != -1 && DxLib::ProcessMessage() != -1); }
}

void Main();

int WINAPI WinMain([[maybe_unused]]HINSTANCE hInstance, [[maybe_unused]]HINSTANCE hPrevInstance, [[maybe_unused]]LPSTR lpCmdLine, [[maybe_unused]]int nCmdShow) {
	DxLib::SetOutApplicationLogValidFlag(FALSE);
	DxLib::ChangeWindowMode(TRUE);
	DxLib::SetGraphMode(512, 512, 32);
	if (DxLib::DxLib_Init() == -1) return -1;
	DxLib::SetDrawScreen(DX_SCREEN_BACK);
	DxLib::SetMainWindowText("Sample");
	Main();
	return DxLib::DxLib_End();
}

constexpr int hachi{ 2 };
template<typename Matrix_>
void output(const Matrix_& matrix_) {

	constexpr int color_sub{ 1 };
	constexpr int deep_max_value{ 80 };
	constexpr int sea_max_value{ 120 };
	constexpr int sand_max_value{ 142 };
	constexpr int land_max_value{ 160 };

	int a{}, b{}, c{};
	for (std::size_t y{}; y < matrix_.size(); ++y)
		for (std::size_t x{}; x < matrix_[y].size(); ++x) {

			a = dtl::random::mt32bit.get<int>(10) - 5;
			b = dtl::random::mt32bit.get<int>(10) - 5;
			c = dtl::random::mt32bit.get<int>(10) - 5;

			if (matrix_[y][x] <= deep_max_value) {
				DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi,
					GetColor(30 + a, 88 + b, 126 + c), TRUE);
			}
			else if (matrix_[y][x] <= sea_max_value) {
				DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi,
					GetColor((30 + 135 * (matrix_[y][x] - deep_max_value) / (sea_max_value - deep_max_value)) / color_sub * color_sub + a,
					(88 + 133 * (matrix_[y][x] - deep_max_value) / (sea_max_value - deep_max_value)) / color_sub * color_sub,
						(126 + 84 * (matrix_[y][x] - deep_max_value) / (sea_max_value - deep_max_value)) / color_sub * color_sub + c), TRUE);
			}
			else if (matrix_[y][x] <= sand_max_value) {
				DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi,
					GetColor((244 - 20 * (matrix_[y][x] - sea_max_value) / (sand_max_value - sea_max_value)) / color_sub * color_sub + a,
					(236 - 27 * (matrix_[y][x] - sea_max_value) / (sand_max_value - sea_max_value)) / color_sub * color_sub + b,
						(215 - 25 * (matrix_[y][x] - sea_max_value) / (sand_max_value - sea_max_value)) / color_sub * color_sub + c), TRUE);
			}
			else if (matrix_[y][x] <= sand_max_value + 2) {
				DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi,
				GetColor(224 / 2 + 166 / 2 + a,
					209 / 2 + 193 / 2 + b,
					190 / 2 + 98 / 2 + c), TRUE);
			}
			else {
				DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi,
				GetColor((166 - 30 * (matrix_[y][x] - sand_max_value) / (land_max_value - sand_max_value)) / color_sub * color_sub,
					(193 + 12 * (matrix_[y][x] - sand_max_value) / (land_max_value - sand_max_value)) / color_sub * color_sub,
					(98 + 1 * (matrix_[y][x] - sand_max_value) / (land_max_value - sand_max_value)) / color_sub * color_sub), TRUE);
			}
		}
}

void Main() {

	using shape_t = std::uint_fast8_t;
	constexpr std::size_t width{ 257 };
	constexpr std::size_t height{ 257 };
	std::array<std::array<shape_t, width>, height> matrix{ {} };

	constexpr int update_fps{ 30 };
	int now_fps{ update_fps };
	while (System::Update()) {
		++now_fps;
		if (now_fps < update_fps) continue;
		now_fps = 0;
		dtl::shape::DiamondSquareAverageIsland<shape_t>(0, 165, 85).draw(matrix);
		//dtl::CellularAutomatonMixIsland<shape_t>(60, 0, 1, 2, 3, 4).draw(matrix);
		output(matrix);
	}

}

潮の満ち引き(DiamondSquareAverageIsland)

#include <DTL.hpp>
#include <DxLib.h>

namespace System {
	bool Update() noexcept { return (DxLib::ScreenFlip() != -1 && DxLib::ProcessMessage() != -1); }
}

void Main();

int WINAPI WinMain([[maybe_unused]]HINSTANCE hInstance, [[maybe_unused]]HINSTANCE hPrevInstance, [[maybe_unused]]LPSTR lpCmdLine, [[maybe_unused]]int nCmdShow) {
	DxLib::SetOutApplicationLogValidFlag(FALSE);
	DxLib::ChangeWindowMode(TRUE);
	DxLib::SetGraphMode(512, 512, 32);
	if (DxLib::DxLib_Init() == -1) return -1;
	DxLib::SetDrawScreen(DX_SCREEN_BACK);
	DxLib::SetMainWindowText("Sample");
	Main();
	return DxLib::DxLib_End();
}

constexpr int hachi{ 2 };
template<typename Matrix_>
void output(const Matrix_& matrix_,const int add_) {

	constexpr int color_sub{ 1 };
	const int deep_max_value{ 80 + add_ };
	const int sea_max_value{ 120 + add_ };
	constexpr int sand_max_value{ 142 };
	constexpr int land_max_value{ 160 };

	int a{}, b{}, c{};
	for (std::size_t y{}; y < matrix_.size(); ++y)
		for (std::size_t x{}; x < matrix_[y].size(); ++x) {

			a = dtl::random::mt32bit.get<int>(10) - 5;
			b = dtl::random::mt32bit.get<int>(10) - 5;
			c = dtl::random::mt32bit.get<int>(10) - 5;

			if (matrix_[y][x] <= deep_max_value) {
				DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi,
					GetColor(30 + a, 88 + b, 126 + c), TRUE);
			}
			else if (matrix_[y][x] <= sea_max_value) {
				DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi,
					GetColor((30 + 135 * (matrix_[y][x] - deep_max_value) / (sea_max_value - deep_max_value)) / color_sub * color_sub + a,
					(88 + 133 * (matrix_[y][x] - deep_max_value) / (sea_max_value - deep_max_value)) / color_sub * color_sub,
						(126 + 84 * (matrix_[y][x] - deep_max_value) / (sea_max_value - deep_max_value)) / color_sub * color_sub + c), TRUE);
			}
			else if (matrix_[y][x] <= sand_max_value) {
				DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi,
					GetColor((244 - 20 * (matrix_[y][x] - sea_max_value) / (sand_max_value - sea_max_value)) / color_sub * color_sub + a,
					(236 - 27 * (matrix_[y][x] - sea_max_value) / (sand_max_value - sea_max_value)) / color_sub * color_sub + b,
						(215 - 25 * (matrix_[y][x] - sea_max_value) / (sand_max_value - sea_max_value)) / color_sub * color_sub + c), TRUE);
			}
			else if (matrix_[y][x] <= sand_max_value + 2) {
				DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi,
				GetColor(224 / 2 + 166 / 2 + a,
					209 / 2 + 193 / 2 + b,
					190 / 2 + 98 / 2 + c), TRUE);
			}
			else {
				DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi,
				GetColor((166 - 30 * (matrix_[y][x] - sand_max_value) / (land_max_value - sand_max_value)) / color_sub * color_sub,
					(193 + 12 * (matrix_[y][x] - sand_max_value) / (land_max_value - sand_max_value)) / color_sub * color_sub,
					(98 + 1 * (matrix_[y][x] - sand_max_value) / (land_max_value - sand_max_value)) / color_sub * color_sub), TRUE);
			}
		}
}

void Main() {

	using shape_t = std::uint_fast8_t;
	constexpr std::size_t width{ 257 };
	constexpr std::size_t height{ 257 };
	std::array<std::array<shape_t, width>, height> matrix{ {} };
	dtl::shape::DiamondSquareAverageIsland<shape_t>(0, 165, 85).draw(matrix);

	constexpr int update_water{ 24 };
	int now_water{ update_water };
	bool is_minus{ false };

	while (System::Update()) {
		++now_water;

		output(matrix, (now_water) / ((is_minus) ? -4 : 4));

		if (now_water < update_water) continue;
		now_water = 0;
		now_water = -update_water;
		is_minus = !is_minus;
	}

}

潮の満ち引き(FractalLoopIsland)

#include <DTL.hpp>
#include <DxLib.h>

namespace System {
	bool Update() noexcept { return (DxLib::ScreenFlip() != -1 && DxLib::ProcessMessage() != -1); }
}

void Main();

int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) {
	DxLib::SetOutApplicationLogValidFlag(FALSE);
	DxLib::ChangeWindowMode(TRUE);
	DxLib::SetGraphMode(512, 512, 32);
	if (DxLib::DxLib_Init() == -1) return -1;
	DxLib::SetDrawScreen(DX_SCREEN_BACK);
	DxLib::SetMainWindowText("Sample");
	Main();
	return DxLib::DxLib_End();
}

constexpr int hachi{ 2 };
template<typename Matrix_>
void output(const Matrix_& matrix_, const int add_) {

	constexpr int color_sub{ 1 };
	const int deep_max_value{ 100 + add_ };
	const int sea_max_value{ 130 + add_ };
	constexpr int sand_max_value{ 152 };
	constexpr int land_max_value{ 230 };

	int a{}, b{}, c{};
	for (std::size_t y{}; y < matrix_.size(); ++y)
		for (std::size_t x{}; x < matrix_[y].size(); ++x) {

			a = dtl::random::mt32bit.get<int>(10) - 5;
			b = dtl::random::mt32bit.get<int>(10) - 5;
			c = dtl::random::mt32bit.get<int>(10) - 5;

			if (matrix_[y][x] <= deep_max_value) {
				DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi,
					GetColor(30 + a, 88 + b, 126 + c), TRUE);
			}
			else if (matrix_[y][x] <= sea_max_value) {
				DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi,
					GetColor((30 + 135 * (matrix_[y][x] - deep_max_value) / (sea_max_value - deep_max_value)) / color_sub * color_sub + a,
					(88 + 133 * (matrix_[y][x] - deep_max_value) / (sea_max_value - deep_max_value)) / color_sub * color_sub,
						(126 + 84 * (matrix_[y][x] - deep_max_value) / (sea_max_value - deep_max_value)) / color_sub * color_sub + c), TRUE);
			}
			else if (matrix_[y][x] <= sand_max_value) {
				DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi,
					GetColor((244 - 20 * (matrix_[y][x] - sea_max_value) / (sand_max_value - sea_max_value)) / color_sub * color_sub + a,
					(236 - 27 * (matrix_[y][x] - sea_max_value) / (sand_max_value - sea_max_value)) / color_sub * color_sub + b,
						(215 - 25 * (matrix_[y][x] - sea_max_value) / (sand_max_value - sea_max_value)) / color_sub * color_sub + c), TRUE);
			}
			else if (matrix_[y][x] <= sand_max_value + 2) {
				DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi,
					GetColor(224 / 2 + 166 / 2 + a,
						209 / 2 + 193 / 2 + b,
						190 / 2 + 98 / 2 + c), TRUE);
			}
			else {
				DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi,
					GetColor((166 - 30 * (matrix_[y][x] - sand_max_value) / (land_max_value - sand_max_value)) / color_sub * color_sub,
					(193 + 12 * (matrix_[y][x] - sand_max_value) / (land_max_value - sand_max_value)) / color_sub * color_sub,
						(98 + 1 * (matrix_[y][x] - sand_max_value) / (land_max_value - sand_max_value)) / color_sub * color_sub), TRUE);
			}
		}
}

void Main() {

	using shape_t = std::uint_fast8_t;
	constexpr std::size_t width{ 256 };
	constexpr std::size_t height{ 256 };
	std::array<std::array<shape_t, width>, height> matrix{ {} };
	dtl::shape::FractalLoopIsland<shape_t>(0, 165, 85).draw(matrix);

	constexpr int update_water{ 24 };
	int now_water{ update_water };
	bool is_minus{ false };

	while (System::Update()) {
		++now_water;

		output(matrix, (now_water) / ((is_minus) ? -4 : 4));

		if (now_water < update_water) continue;
		now_water = 0;
		now_water = -update_water;
		is_minus = !is_minus;
	}

}

FractalLoopIsland

#include <DTL.hpp>
#include <DxLib.h>

namespace System {
	bool Update() noexcept { return (DxLib::ScreenFlip() != -1 && DxLib::ProcessMessage() != -1); }
}

void Main();

int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) {
	DxLib::SetOutApplicationLogValidFlag(FALSE);
	DxLib::ChangeWindowMode(TRUE);
	DxLib::SetGraphMode(512, 512, 32);
	if (DxLib::DxLib_Init() == -1) return -1;
	DxLib::SetDrawScreen(DX_SCREEN_BACK);
	DxLib::SetMainWindowText("Sample");
	Main();
	return DxLib::DxLib_End();
}

constexpr int hachi{ 2 };
template<typename Matrix_>
void output(const Matrix_& matrix_) {

	constexpr int color_sub{ 24 };
	const int deep_max_value{ 100 };
	const int sea_max_value{ 130 };
	constexpr int sand_max_value{ 152 };
	constexpr int land_max_value{ 230 };

	int a{}, b{}, c{};
	for (std::size_t y{}; y < matrix_.size(); ++y)
		for (std::size_t x{}; x < matrix_[y].size(); ++x) {

			a = dtl::random::mt32bit.get<int>(10) - 5;
			b = dtl::random::mt32bit.get<int>(10) - 5;
			c = dtl::random::mt32bit.get<int>(10) - 5;

			DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi,
				GetColor(0,
				(matrix_[y][x]) / color_sub * color_sub,
					(matrix_[y][x]) / color_sub * color_sub), TRUE);
		}
}

void Main() {

	using shape_t = std::uint_fast8_t;
	constexpr std::size_t width{ 256 };
	constexpr std::size_t height{ 256 };
	std::array<std::array<shape_t, width>, height> matrix{ {} };
	dtl::shape::FractalLoopIsland<shape_t> fil(0, 200, 50);
	fil.draw(matrix);

	constexpr int update_timer{ 30 };
	int now_timer{ update_timer };

	while (System::Update()) {
		if (now_timer >= update_timer) {
			now_timer = 0;
			fil.draw(matrix);
			output(matrix);
		}
		++now_timer;
	}

}

当記事のライセンス

CC0

Clone this wiki locally