-
-
Notifications
You must be signed in to change notification settings - Fork 82
DxLib雑多なサンプル
Kasugaccho edited this page Dec 10, 2019
·
19 revisions
#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{ 8 };
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 };
for (std::size_t y{}; y < matrix_.size(); ++y)
for (std::size_t x{}; x < matrix_[y].size(); ++x) {
DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi,
(matrix_[y][x] == 1) ? GetColor(35, 100, 180) : GetColor(235, 235, 235), TRUE);
}
}
void Main() {
WaitKey();
using shape_t = std::uint_fast8_t;
constexpr std::size_t width{ 64 };
constexpr std::size_t height{ 64 };
std::array<std::array<shape_t, width>, height> matrix{ {} };
dtl::shape::StarLine<shape_t> fil(1, 32, 32, 30, 0.0);
fil.draw(matrix);
double angle{ 0.0 };
constexpr int update_timer{ 2 };
int now_timer{ update_timer };
while (System::Update()) {
if (now_timer >= update_timer) {
now_timer = 0;
dtl::Init<shape_t>().draw(matrix);
angle += 0.02;
dtl::shape::StarLine<shape_t>(1, 32, 32, 30, angle).draw(matrix);
output(matrix);
}
++now_timer;
}
}
#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("Island");
Main();
return DxLib::DxLib_End();
}
constexpr std::size_t size_x{ 512 };
constexpr std::size_t size_y{ 512 };
constexpr int hachi{ 1 };
template<typename Matrix_, typename Matrix2_>
void output(const Matrix_& matrix_, const Matrix2_& elevation_) {
for (std::size_t y{}; y < size_y; ++y)
for (std::size_t x{}; x < size_x; ++x) {
float a{ (elevation_[y][x] < 60) ? 1.1f : ((elevation_[y][x] < 80) ? 1.0f : (elevation_[y][x] < 110) ? 0.9f : ((elevation_[y][x] < 140) ? 1.0f : 1.3f)) };
float b{ (elevation_[y][x] < 60) ? 1.1f : ((elevation_[y][x] < 80) ? 1.0f : (elevation_[y][x] < 110) ? 0.9f : ((elevation_[y][x] < 140) ? 1.0f : 1.3f)) };
float c{ (elevation_[y][x] < 60) ? 1.1f : ((elevation_[y][x] < 80) ? 1.0f : (elevation_[y][x] < 110) ? 0.9f : ((elevation_[y][x] < 140) ? 1.0f : 1.3f)) };
unsigned int color{};
switch (matrix_[y][x]) {
case 0:color = GetColor(int(41 / a), int(40 / b), int(159 / c)); break;
case 1:color = GetColor(int(218 / a), int(217 / b), int(225 / c)); break;
case 2:color = GetColor(int(223 / a), int(203 / b), int(140 / c)); break;
case 3:color = GetColor(int(188 / a), int(205 / b), int(146 / c)); break;
case 4:color = GetColor(int(164 / a), int(143 / b), int(50 / c)); break;
case 5:color = GetColor(int(97 / a), int(154 / b), int(96 / c)); break;
case 6:color = GetColor(int(101 / a), int(163 / b), int(56 / c)); break;
case 7:color = GetColor(9, int(100 / b), 5);
case 8:case 9:case 10:
color = GetColor(int(43 / a), int(84 / b), int(41 / c));
break;
}
DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi, color, TRUE);
}
}
void Main() {
using shape_t = std::uint_fast8_t;
std::unique_ptr<float[][size_x] > temperature(new(std::nothrow) float[size_y][size_x]);
std::unique_ptr<std::int_fast16_t[][size_x] > amount_of_rainfall(new(std::nothrow) std::int_fast16_t[size_y][size_x]);
std::unique_ptr<std::uint_fast8_t[][size_x] > elevation(new(std::nothrow) std::uint_fast8_t[size_y][size_x]);
std::unique_ptr<shape_t[][size_x] > biome(new(std::nothrow) shape_t[size_y][size_x]);
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::PerlinIsland<float>(4.0, 2, -20.0f, 60.0f).draw(temperature, size_x, size_y);
dtl::shape::PerlinIsland<std::int_fast16_t>(4.0, 4, 0, 4500).draw(amount_of_rainfall, size_x, size_y);
dtl::shape::PerlinSolitaryIsland<shape_t>(0.9, 0.45, 6.0, 6, 200).draw(elevation, size_x, size_y);
for (std::size_t row{}; row < size_y; ++row)
for (std::size_t col{}; col < size_x; ++col) {
temperature[row][col] -= (elevation[row][col] - 130.0f) * 0.5f;
if (elevation[row][col] < 100) biome[row][col] = 0;
//ツンドラ
else if (temperature[row][col] < -5.0f) biome[row][col] = 1;
//砂漠
else if (amount_of_rainfall[row][col] < 500) biome[row][col] = 2;
else if (amount_of_rainfall[row][col] < 1500) {
//ステップ
if (temperature[row][col] < 20.0f) biome[row][col] = 3;
//サバンナ
else biome[row][col] = 4;
}
//針葉樹林
else if (temperature[row][col] < 3.0f) biome[row][col] = 5;
//夏緑樹林
else if (temperature[row][col] < 12.0f) biome[row][col] = 6;
//照葉樹林
else if (temperature[row][col] < 20.0f) biome[row][col] = 7;
//雨緑樹林
else if (amount_of_rainfall[row][col] < 2500) biome[row][col] = 8;
//亜熱帯多雨林
else if (temperature[row][col] < 24.0f) biome[row][col] = 9;
//熱帯多雨林
else biome[row][col] = 10;
}
output(biome, elevation);
}
}
#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 std::size_t size_x{ 512 };
constexpr std::size_t size_y{ 512 };
constexpr int hachi{ 1 };
template<typename Matrix_, typename Matrix2_>
void output(const Matrix_& matrix_, const Matrix2_& elevation_) {
float a{ 1 }, b{ 1 }, c{ 1 };
for (std::size_t y{}; y < size_y; ++y)
for (std::size_t x{}; x < size_x; ++x) {
a = (elevation_[y][x] < 60) ? 1.1f : ((elevation_[y][x] < 80) ? 1.0f : (elevation_[y][x] < 110) ? 0.9f : ((elevation_[y][x] < 140) ? 1.0f : 1.3f));
b = (elevation_[y][x] < 60) ? 1.1f : ((elevation_[y][x] < 80) ? 1.0f : (elevation_[y][x] < 110) ? 0.9f : ((elevation_[y][x] < 140) ? 1.0f : 1.3f));
c = (elevation_[y][x] < 60) ? 1.1f : ((elevation_[y][x] < 80) ? 1.0f : (elevation_[y][x] < 110) ? 0.9f : ((elevation_[y][x] < 140) ? 1.0f : 1.3f));
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(int(41 / a), int(40 / b), int(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(int(218 / a), int(217 / b), int(225 / 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(int(223 / a), int(203 / b), int(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(int(188 / a), int(205 / b), int(146 / c)), 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(int(164 / a), int(143 / b), int(50 / c)), TRUE);
break;
case 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(int(97 / a), int(154 / b), int(96 / c)), TRUE);
break;
case 6:
DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi, GetColor(int(101 / a), int(163 / b), int(56 / c)), TRUE);
break;
case 7:
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, int(100 / b), 5), TRUE);
break;
case 8:
case 9:
case 10:
DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi, GetColor(int(43 / a), int(84 / b), int(41 / c)), TRUE);
break;
}
}
}
void Main() {
using shape_t = std::uint_fast8_t;
//温度
std::unique_ptr<float[][size_x] > temperature(new(std::nothrow) float[size_y][size_x]);
//降水量
std::unique_ptr<std::int_fast16_t[][size_x] > amount_of_rainfall(new(std::nothrow) std::int_fast16_t[size_y][size_x]);
std::unique_ptr<std::uint_fast8_t[][size_x] > elevation(new(std::nothrow) std::uint_fast8_t[size_y][size_x]);
std::unique_ptr<shape_t[][size_x] > biome(new(std::nothrow) shape_t[size_y][size_x]);
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::PerlinIsland<float>(4.0, 2, -20.0f, 60.0f).draw(temperature, size_x, size_y);
dtl::shape::PerlinIsland<std::int_fast16_t>(4.0, 4, 0, 4500).draw(amount_of_rainfall, size_x, size_y);
dtl::shape::PerlinSolitaryIsland<shape_t>(0.9, 0.45, 6.0, 6, 200).draw(elevation, size_x, size_y);
for (std::size_t row{}; row < size_y; ++row)
for (std::size_t col{}; col < size_x; ++col) {
temperature[row][col] -= (elevation[row][col] - 130.0f) * 0.5f;
if (elevation[row][col] < 100) biome[row][col] = 0;
//ツンドラ
else if (temperature[row][col] < -5.0f) biome[row][col] = 1;
//砂漠
else if (amount_of_rainfall[row][col] < 500) biome[row][col] = 2;
else if (amount_of_rainfall[row][col] < 1500) {
//ステップ
if (temperature[row][col] < 20.0f) biome[row][col] = 3;
//サバンナ
else biome[row][col] = 4;
}
//針葉樹林
else if (temperature[row][col] < 3.0f) biome[row][col] = 5;
//夏緑樹林
else if (temperature[row][col] < 12.0f) biome[row][col] = 6;
//照葉樹林
else if (temperature[row][col] < 20.0f) biome[row][col] = 7;
//雨緑樹林
else if (amount_of_rainfall[row][col] < 2500) biome[row][col] = 8;
//亜熱帯多雨林
else if (temperature[row][col] < 24.0f) biome[row][col] = 9;
//熱帯多雨林
else biome[row][col] = 10;
}
output(biome, elevation);
}
}
#include <DTL.hpp>
#include <DxLib.h>
namespace System {
bool Update() noexcept { return (DxLib::ScreenFlip() != -1 && DxLib::ProcessMessage() != -1); }
}
void Main();
constexpr std::size_t size_x{ 1024 };
constexpr std::size_t size_y{ 1024 };
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) {
DxLib::SetOutApplicationLogValidFlag(FALSE);
DxLib::ChangeWindowMode(TRUE);
DxLib::SetGraphMode((int)size_x, (int)size_y, 32);
if (DxLib::DxLib_Init() == -1) return -1;
DxLib::SetDrawScreen(DX_SCREEN_BACK);
DxLib::SetMainWindowText("Sample");
Main();
return DxLib::DxLib_End();
}
constexpr int hachi{ 1 };
template<typename Matrix_, typename Matrix2_>
void output(const Matrix_& matrix_, const Matrix2_& elevation_) {
float a{ 1 }, b{ 1 }, c{ 1 };
for (std::size_t y{}; y < size_y; ++y)
for (std::size_t x{}; x < size_x; ++x) {
a = (elevation_[y][x] < 60) ? 1.1f : ((elevation_[y][x] < 80) ? 1.0f : (elevation_[y][x] < 110) ? 0.9f : ((elevation_[y][x] < 140) ? 1.0f : ((elevation_[y][x] < 160) ? 1.4f : 1.8f)));
b = (elevation_[y][x] < 60) ? 1.1f : ((elevation_[y][x] < 80) ? 1.0f : (elevation_[y][x] < 110) ? 0.9f : ((elevation_[y][x] < 140) ? 1.0f : ((elevation_[y][x] < 160) ? 1.4f : 1.8f)));
c = (elevation_[y][x] < 60) ? 1.1f : ((elevation_[y][x] < 80) ? 1.0f : (elevation_[y][x] < 110) ? 0.9f : ((elevation_[y][x] < 140) ? 1.0f : ((elevation_[y][x] < 160) ? 1.4f : 1.8f)));
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(int(41 / a), int(40 / b), int(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(int(218 / a), int(217 / b), int(225 / 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(int(223 / a), int(203 / b), int(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(int(188 / a), int(205 / b), int(146 / c)), 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(int(164 / a), int(143 / b), int(50 / c)), TRUE);
break;
case 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(int(97 / a), int(154 / b), int(96 / c)), TRUE);
break;
case 6:
DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi, GetColor(int(101 / a), int(163 / b), int(56 / c)), TRUE);
break;
case 7:
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, int(100 / b), 5), TRUE);
break;
case 8:
case 9:
case 10:
DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi, GetColor(int(43 / a), int(84 / b), int(41 / c)), TRUE);
break;
case 11:
DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi, GetColor(int(30 / a), int(90 / b), int(165 / c)), TRUE);
break;
}
}
}
void Main() {
using shape_t = std::uint_fast8_t;
std::unique_ptr<shape_t[][size_x] > temperature(new(std::nothrow) shape_t[size_y][size_x]);
std::unique_ptr<shape_t[][size_x] > amount_of_rainfall(new(std::nothrow) shape_t[size_y][size_x]);
std::unique_ptr<shape_t[][size_x] > elevation(new(std::nothrow) shape_t[size_y][size_x]);
std::unique_ptr<shape_t[][size_x] > biome(new(std::nothrow) shape_t[size_y][size_x]);
std::unique_ptr<shape_t[][size_x] > land(new(std::nothrow) shape_t[size_y][size_x]);
constexpr int update_fps{ 50 };
int now_fps{ update_fps };
while (System::Update()) {
++now_fps;
if (now_fps < update_fps) continue;
now_fps = 0;
dtl::shape::PerlinIsland<shape_t>(4.0, 7, 240, 100).draw(temperature, size_x, size_y);
dtl::shape::PerlinIsland<shape_t>(4.0, 7, 225).draw(amount_of_rainfall, size_x, size_y);
dtl::shape::PerlinSolitaryIsland<shape_t>(0.9, 0.45, 6.0, 7, 200).draw(elevation, size_x, size_y);
for (std::size_t row{}; row < size_y; ++row)
for (std::size_t col{}; col < size_x; ++col) {
temperature[row][col] -= elevation[row][col] / 2;
land[row][col] = 1;
if (elevation[row][col] < 110) {
biome[row][col] = 0;
land[row][col] = 0;
}
//ツンドラ
else if (temperature[row][col] < 45) biome[row][col] = 1;
//砂漠
else if (amount_of_rainfall[row][col] < 25) biome[row][col] = 2;
else if (amount_of_rainfall[row][col] < 75) {
//ステップ
if (temperature[row][col] < 120) biome[row][col] = 3;
//サバンナ
else biome[row][col] = 4;
}
//針葉樹林
else if (temperature[row][col] < 69) biome[row][col] = 5;
//夏緑樹林
else if (temperature[row][col] < 96) biome[row][col] = 6;
//照葉樹林
else if (temperature[row][col] < 120) biome[row][col] = 7;
//雨緑樹林
else if (amount_of_rainfall[row][col] < 125) biome[row][col] = 8;
//亜熱帯多雨林
else if (temperature[row][col] < 132) biome[row][col] = 9;
//熱帯多雨林
else biome[row][col] = 10;
}
dtl::retouch::Bucket<shape_t>(1,0,0).draw(land, size_x, size_y);
for (std::size_t row{}; row < size_y; ++row)
for (std::size_t col{}; col < size_x; ++col) {
if (elevation[row][col] < 110 && land[row][col] == 0) {
biome[row][col] = 11;
}
}
output(biome, elevation);
//WaitKey();
}
}
#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 std::size_t size_x{ 512 };
constexpr std::size_t size_y{ 512 };
constexpr int hachi{ 1 };
template<typename Matrix_, typename Matrix2_>
void output(const Matrix_& matrix_, const Matrix2_& elevation_) {
float a{1}, b{1}, c{1};
for (std::size_t y{}; y < size_y; ++y)
for (std::size_t x{}; x < size_x; ++x) {
a = ((elevation_[y][x] < 50) ? 1.1f : (elevation_[y][x] < 110) ? 0.9f : ((elevation_[y][x] < 140) ? 1.0f : 1.3f));
b = ((elevation_[y][x] < 50) ? 1.1f : (elevation_[y][x] < 110) ? 0.9f : ((elevation_[y][x] < 140) ? 1.0f : 1.3f));
c = ((elevation_[y][x] < 50) ? 1.1f : (elevation_[y][x] < 110) ? 0.9f : ((elevation_[y][x] < 140) ? 1.0f : 1.3f));
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(int(41 / a), int(40 / b), int(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(int(218 / a), int(217 / b), int(225 / 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(int(223 / a), int(203 / b), int(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(int(188 / a), int(205 / b), int(146 / c)), 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(int(164 / a), int(143 / b), int(50 / c)), TRUE);
break;
case 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(int(97 / a), int(154 / b), int(96 / c)), TRUE);
break;
case 6:
DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi, GetColor(int(101 / a), int(163 / b), int(56 / c)), TRUE);
break;
case 7:
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, int(100 / b), 5), TRUE);
break;
case 8:
case 9:
case 10:
DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi, GetColor(int(43 / a), int(84 / b), int(41 / c)), TRUE);
break;
}
}
}
void Main() {
using shape_t = std::uint_fast8_t;
//温度
std::unique_ptr<float[][size_x] > temperature(new(std::nothrow) float[size_y][size_x]);
//降水量
std::unique_ptr<std::int_fast16_t[][size_x] > amount_of_rainfall(new(std::nothrow) std::int_fast16_t[size_y][size_x]);
std::unique_ptr<std::uint_fast8_t[][size_x] > elevation(new(std::nothrow) std::uint_fast8_t[size_y][size_x]);
std::unique_ptr<shape_t[][size_x] > biome(new(std::nothrow) shape_t[size_y][size_x]);
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::PerlinIsland<float>(6.0, 8, -20.0f, 60.0f).draw(temperature, size_x, size_y);
dtl::shape::PerlinIsland<std::int_fast16_t>(6.0, 8, 0, 4500).draw(amount_of_rainfall, size_x, size_y);
dtl::shape::PerlinIsland<std::uint_fast8_t>(6.0, 8, 200).draw(elevation, size_x, size_y);
//dtl::shape::PerlinIsland<std::int_fast8_t>(6.0, 8, 0, 0).draw(elevation, size_x, size_y);
for (std::size_t row{}; row < size_y; ++row)
for (std::size_t col{}; col < size_x; ++col) {
if (elevation[row][col] < 90) biome[row][col] = 0;
//ツンドラ
else if (temperature[row][col] < -5.0f) biome[row][col] = 1;
//砂漠
else if (amount_of_rainfall[row][col] < 500) biome[row][col] = 2;//(((temperature[row][col] + 5.0f) / 35.0f) * 500)
else if (amount_of_rainfall[row][col] < 1500) {
//ステップ
if (temperature[row][col] < 20.0f) biome[row][col] = 3;
//サバンナ
else biome[row][col] = 4;
}
//針葉樹林
else if (temperature[row][col] < 3.0f) biome[row][col] = 5;
//夏緑樹林
else if (temperature[row][col] < 12.0f) biome[row][col] = 6;
//照葉樹林
else if (temperature[row][col] < 20.0f) biome[row][col] = 7;
//雨緑樹林
else if (amount_of_rainfall[row][col] < 2500) biome[row][col] = 8;
//亜熱帯多雨林
else if (temperature[row][col] < 24.0f) biome[row][col] = 9;
//熱帯多雨林
else biome[row][col] = 10;
}
output(biome, elevation);
}
}
#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_) {
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>(200, 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(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();
}
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>(200, 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);
});
}
}
#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{ 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);
}
}
#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{ 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;
}
}
#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;
}
}
#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;
}
}
#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 };
for (std::size_t y{}; y < matrix_.size(); ++y)
for (std::size_t x{}; x < matrix_[y].size(); ++x) {
DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi,
(matrix_[y][x]) ? GetColor(255, 255, 255) : GetColor(0, 0, 0), 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::RandomVoronoi<shape_t> fil(300, 0.3, 1);
fil.draw(matrix);
constexpr int update_timer{ 30 };
int now_timer{ update_timer };
while (System::Update()) {
if (now_timer >= update_timer) {
now_timer = 0;
dtl::Init<shape_t>().draw(matrix);
fil.draw(matrix);
output(matrix);
}
++now_timer;
}
}
#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(1280/2, 720/2, 32);
if (DxLib::DxLib_Init() == -1) return -1;
DxLib::SetDrawScreen(DX_SCREEN_BACK);
DxLib::SetMainWindowText("Sample");
Main();
return DxLib::DxLib_End();
}
constexpr std::size_t size_x{ 1280/2 };
constexpr std::size_t size_y{ 720/2 };
constexpr int hachi{ 1 };
template<typename Matrix_, typename Matrix2_>
void output(const Matrix_& matrix_, const Matrix2_& elevation_) {
float a{ 1 }, b{ 1 }, c{ 1 };
for (std::size_t y{}; y < size_y; ++y)
for (std::size_t x{}; x < size_x; ++x) {
a = ((elevation_[y][x] < 50) ? 1.1f : (elevation_[y][x] < 90) ? 0.9f : ((elevation_[y][x] < 110) ? 1.0f : 1.3f));
b = ((elevation_[y][x] < 50) ? 1.1f : (elevation_[y][x] < 90) ? 0.9f : ((elevation_[y][x] < 110) ? 1.0f : 1.3f));
c = ((elevation_[y][x] < 50) ? 1.1f : (elevation_[y][x] < 90) ? 0.9f : ((elevation_[y][x] < 110) ? 1.0f : 1.3f));
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(int(41 / a), int(40 / b), int(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(int(218 / a), int(217 / b), int(225 / 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(int(223 / a), int(203 / b), int(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(int(188 / a), int(205 / b), int(146 / c)), 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(int(164 / a), int(143 / b), int(50 / c)), TRUE);
break;
case 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(int(97 / a), int(154 / b), int(96 / c)), TRUE);
break;
case 6:
DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi, GetColor(int(101 / a), int(163 / b), int(56 / c)), TRUE);
break;
case 7:
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, int(100 / b), 5), TRUE);
break;
case 8:
case 9:
case 10:
DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi, GetColor(int(43 / a), int(84 / b), int(41 / c)), TRUE);
break;
case 11:
DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi, GetColor(int(120 / a), int(120 / b), int(190 / c)), TRUE);//81/80/159
break;
}
}
}
void Main() {
using shape_t = std::uint_fast8_t;
constexpr double frequency{ 400 };
constexpr std::size_t octaves{ 8 };
constexpr std::uint_fast32_t seed{ 1 };
constexpr double frequency_x{ frequency };
constexpr double frequency_y{ frequency };
constexpr std::size_t start_x{};
constexpr std::size_t start_y{};
//温度
std::unique_ptr<float[][size_x] > temperature(new(std::nothrow) float[size_y][size_x]);
//降水量
std::unique_ptr<std::int_fast16_t[][size_x] > amount_of_rainfall(new(std::nothrow) std::int_fast16_t[size_y][size_x]);
std::unique_ptr<std::uint_fast8_t[][size_x] > elevation(new(std::nothrow) std::uint_fast8_t[size_y][size_x]);
std::unique_ptr<shape_t[][size_x] > biome(new(std::nothrow) shape_t[size_y][size_x]);
std::size_t now_fps{ start_x };
const dtl::utility::PerlinNoise perlin(seed);
const dtl::utility::PerlinNoise perlin2(seed + 12345);
const dtl::utility::PerlinNoise perlin3(seed + 3456789);
const dtl::utility::PerlinNoise perlin4(seed + 6543210);
for (std::size_t row{}; row < size_y; ++row)
for (std::size_t col{}; col < size_x; ++col) {
temperature[row][col] = static_cast<float>(80.0 * perlin.octaveNoise(octaves, (col + now_fps) / frequency_x, (row) / frequency_y)) - 20.0f;
amount_of_rainfall[row][col] = static_cast<std::int_fast16_t>(4500.0 * perlin2.octaveNoise(octaves, (col + now_fps) / frequency_x, (row) / frequency_y));
elevation[row][col] = static_cast<std::uint_fast8_t>(50.0 * perlin3.octaveNoise(octaves, (col + now_fps) / frequency_x, (row) / frequency_y));
elevation[row][col] += static_cast<std::uint_fast8_t>(120.0 * perlin4.octaveNoise(octaves, (col + now_fps) / (frequency_x * 20), (row) / (frequency_y * 20)));
}
for (std::size_t row{}; row < size_y; ++row)
for (std::size_t col{}; col < size_x; ++col) {
if (elevation[row][col] < 80) {
if (temperature[row][col] < -5.0f && elevation[row][col] >= 80) biome[row][col] = 11;
else biome[row][col] = 0;
}
//ツンドラ
else if (temperature[row][col] < -5.0f) biome[row][col] = 1;
//砂漠
else if (amount_of_rainfall[row][col] < 500) biome[row][col] = 2;
else if (amount_of_rainfall[row][col] < 1500) {
//ステップ
if (temperature[row][col] < 20.0f) biome[row][col] = 3;
//サバンナ
else biome[row][col] = 4;
}
//針葉樹林
else if (temperature[row][col] < 3.0f) biome[row][col] = 5;
//夏緑樹林
else if (temperature[row][col] < 12.0f) biome[row][col] = 6;
//照葉樹林
else if (temperature[row][col] < 20.0f) biome[row][col] = 7;
//雨緑樹林
else if (amount_of_rainfall[row][col] < 2500) biome[row][col] = 8;
//亜熱帯多雨林
else if (temperature[row][col] < 24.0f) biome[row][col] = 9;
//熱帯多雨林
else biome[row][col] = 10;
}
while (System::Update()) {
++now_fps;
for (std::size_t row{}; row < size_y; ++row) {
for (std::size_t col{ 1 }; col < size_x; ++col) {
temperature[row][col - 1] = temperature[row][col];
amount_of_rainfall[row][col - 1] = amount_of_rainfall[row][col];
elevation[row][col - 1] = elevation[row][col];
biome[row][col - 1] = biome[row][col];
}
for (std::size_t col{ size_x - 1 }; col < size_x; ++col) {
temperature[row][col] = static_cast<float>(80.0 * perlin.octaveNoise(octaves, (col + now_fps) / frequency_x, (row) / frequency_y)) - 20.0f;
amount_of_rainfall[row][col] = static_cast<std::int_fast16_t>(4500.0 * perlin2.octaveNoise(octaves, (col + now_fps) / frequency_x, (row) / frequency_y));
elevation[row][col] = static_cast<std::uint_fast8_t>(50.0 * perlin3.octaveNoise(octaves, (col + now_fps) / frequency_x, (row) / frequency_y));
elevation[row][col] += static_cast<std::uint_fast8_t>(120.0 * perlin4.octaveNoise(octaves, (col + now_fps) / (frequency_x * 20), (row) / (frequency_y * 20)));
if (elevation[row][col] < 80) {
if (temperature[row][col] < -5.0f && elevation[row][col] >= 80) biome[row][col] = 11;
else biome[row][col] = 0;
}
//ツンドラ
else if (temperature[row][col] < -5.0f) biome[row][col] = 1;
//砂漠
else if (amount_of_rainfall[row][col] < 500) biome[row][col] = 2;
else if (amount_of_rainfall[row][col] < 1500) {
//ステップ
if (temperature[row][col] < 20.0f) biome[row][col] = 3;
//サバンナ
else biome[row][col] = 4;
}
//針葉樹林
else if (temperature[row][col] < 3.0f) biome[row][col] = 5;
//夏緑樹林
else if (temperature[row][col] < 12.0f) biome[row][col] = 6;
//照葉樹林
else if (temperature[row][col] < 20.0f) biome[row][col] = 7;
//雨緑樹林
else if (amount_of_rainfall[row][col] < 2500) biome[row][col] = 8;
//亜熱帯多雨林
else if (temperature[row][col] < 24.0f) biome[row][col] = 9;
//熱帯多雨林
else biome[row][col] = 10;
}
}
output(biome, elevation);
}
}
#include <DTL.hpp>
#include <DxLib.h>
namespace System {
bool Update() noexcept { return (DxLib::ScreenFlip() != -1 && DxLib::ProcessMessage() != -1); }
}
void Main();
constexpr std::size_t size_x{ 512 };
constexpr std::size_t size_y{ 512 };
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) {
DxLib::SetOutApplicationLogValidFlag(FALSE);
DxLib::ChangeWindowMode(TRUE);
DxLib::SetGraphMode((int)size_x, (int)size_y, 32);
if (DxLib::DxLib_Init() == -1) return -1;
DxLib::SetDrawScreen(DX_SCREEN_BACK);
DxLib::SetMainWindowText("Sample");
Main();
return DxLib::DxLib_End();
}
constexpr int hachi{ 1 };
constexpr float cloud_p{ 0.75f };
constexpr float sky_p{ 0.25f };
template<typename Matrix2_>
void output(const Matrix2_& elevation_) {
for (std::size_t y{}; y < size_y; ++y)
for (std::size_t x{}; x < size_x; ++x) {
if (elevation_[y][x] < 0) elevation_[y][x] = 0;
//elevation_[y][x] = 255;
if (elevation_[y][x] > 255) {
DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi, GetColor(
static_cast<int>((230 + ((39 - 244) * (elevation_[y][x] - 256.0f) / 523.0f)) * cloud_p + 16 * sky_p),
static_cast<int>((235 + ((45 - 244) * (elevation_[y][x] - 256.0f) / 523.0f)) * cloud_p + 123 * sky_p),
static_cast<int>((245 + ((57 - 244) * (elevation_[y][x] - 256.0f) / 523.0f)) * cloud_p + 219 * sky_p)), 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(
static_cast<int>((16 + ((255 - 16) * elevation_[y][x] / 255.0f)) * (1.0f - elevation_[y][x] / (255.0f * 12)) * cloud_p + 16 * sky_p),
static_cast<int>((123 + ((255 - 123) * elevation_[y][x] / 255.0f)) * (1.0f - elevation_[y][x] / (255.0f * 12)) * cloud_p + 123 * sky_p),
static_cast<int>((219 + ((255 - 219) * elevation_[y][x] / 255.0f)) * (1.0f - elevation_[y][x] / (255.0f * 12)) * cloud_p + 219 * sky_p)), TRUE);
}
}
void Main() {
using shape_t = std::uint_fast8_t;
constexpr double frequency{ 500 };
constexpr std::size_t octaves{ 8 };
constexpr std::uint_fast32_t seed{ 1 };
constexpr double frequency_x{ frequency };
constexpr double frequency_y{ frequency };
constexpr std::size_t start_x{};
constexpr std::size_t start_y{};
std::unique_ptr<float[][size_x] > elevation(new(std::nothrow) float[size_y][size_x]);
std::size_t now_fps{ start_x };
const dtl::utility::PerlinNoise perlin3(seed + 34567890);
for (std::size_t row{}; row < size_y; ++row)
for (std::size_t col{}; col < size_x; ++col) {
elevation[row][col] = static_cast<float>(1000.0 * perlin3.octaveNoise(octaves, (col + now_fps) / frequency_x, (row) / frequency_y)) - 500.0f;
}
while (System::Update()) {
++now_fps;
for (std::size_t row{}; row < size_y; ++row) {
for (std::size_t col{ 1 }; col < size_x; ++col) {
elevation[row][col - 1] = elevation[row][col];
}
for (std::size_t col{ size_x - 1 }; col < size_x; ++col) {
elevation[row][col] = static_cast<float>(1000.0 * perlin3.octaveNoise(octaves, (col + now_fps) / frequency_x, (row) / frequency_y)) - 500.0f;
}
}
output(elevation);
}
}
#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{ 8 };
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 };
for (std::size_t y{}; y < matrix_.size(); ++y)
for (std::size_t x{}; x < matrix_[y].size(); ++x) {
DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi,
(matrix_[y][x] == 0) ? GetColor(35, 100, 180) : GetColor(235, 235, 235), TRUE);
}
}
void Main() {
using shape_t = std::uint_fast8_t;
constexpr std::size_t width{ 64 };
constexpr std::size_t height{ 64 };
std::array<std::array<shape_t, width>, height> matrix{ {} };
dtl::shape::ClusteringMaze<shape_t> fil(1);
fil.draw(matrix);
constexpr int update_timer{ 30 };
int now_timer{ update_timer };
while (System::Update()) {
if (now_timer >= update_timer) {
now_timer = 0;
dtl::Init<shape_t>().draw(matrix);
fil.draw(matrix);
output(matrix);
}
++now_timer;
}
}
#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{ 16 };
template<typename Matrix_>
void output(const Matrix_& matrix_) {
unsigned int color{};
for (std::size_t y{}; y < matrix_.size(); ++y)
for (std::size_t x{}; x < matrix_[y].size(); ++x) {
switch (matrix_[y][x])
{
case 0:color = GetColor(35, 100, 178);
break;
case 1:color = GetColor(203, 203, 203);
break;
case 2:color = GetColor(53, 158, 69);
break;
case 3:color = GetColor(52, 44, 68);
break;
case 4:color = GetColor(167, 159, 70);
break;
}
DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi, color, TRUE);
}
}
void Main() {
using shape_t = std::uint_fast8_t;
constexpr std::size_t width{ 32 };
constexpr std::size_t height{ 32 };
std::array<std::array<shape_t, width>, height> matrix{ {} };
dtl::shape::RogueLike<shape_t> fil(0, 1, 2, 3, 4, 15);
fil.draw(matrix);
constexpr int update_timer{ 30 };
int now_timer{ update_timer };
while (System::Update()) {
if (now_timer >= update_timer) {
now_timer = 0;
dtl::Init<shape_t>().draw(matrix);
fil.draw(matrix);
output(matrix);
}
++now_timer;
}
}
#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{ 16 };
template<typename Matrix_>
void output(const Matrix_& matrix_) {
unsigned int color{};
for (std::size_t y{}; y < matrix_.size(); ++y)
for (std::size_t x{}; x < matrix_[y].size(); ++x) {
switch (matrix_[y][x])
{
case 0:color = GetColor(35, 100, 178);
break;
case 1:color = GetColor(203, 203, 203);
//color = GetColor(35, 120, 208);
break;
case 2:color = GetColor(53, 158, 69);
break;
case 3://color = GetColor(52, 44, 68);
color = GetColor(127, 119, 50);
break;
case 4:color = GetColor(167, 159, 70);
break;
case 5:color = GetColor(80, 80, 80);
break;
case 6:color = GetColor(240, 80, 80);
break;
case 7:color = GetColor(80, 220, 80);
break;
case 8:color = GetColor(80, 80, 240);
break;
}
if (matrix_[y][x] < 6)
DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi, color, 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(53, 158, 69), TRUE);
DrawCircle(static_cast<int>(x) * hachi + hachi / 2, static_cast<int>(y) * hachi + hachi / 2, hachi / 2, color, TRUE);
}
}
}
void Main() {
using shape_t = std::uint_fast8_t;
constexpr std::size_t width{ 32 };
constexpr std::size_t height{ 32 };
std::array<std::array<shape_t, width>, height> matrix{ {} };
dtl::shape::RogueLike<shape_t> fil(0, 1, 2, 3, 4, 20);
fil.draw(matrix);
constexpr int update_timer{ 60 };
int now_timer{ update_timer };
while (System::Update()) {
if (now_timer >= update_timer) {
now_timer = 0;
dtl::Init<shape_t>().draw(matrix);
fil.draw(matrix);
dtl::utility::ReplaceSome<shape_t>(1, 5, 2).draw(matrix);
dtl::utility::ReplaceSome<shape_t>(3, 6, 2).draw(matrix);
dtl::utility::ReplaceSome<shape_t>(1, 7, 2).draw(matrix);
dtl::utility::ReplaceSome<shape_t>(3, 8, 2).draw(matrix);
output(matrix);
}
++now_timer;
}
}
#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{ 8 };
template<typename Matrix_>
void output(const Matrix_& matrix_) {
for (std::size_t y{}; y < matrix_.size(); ++y)
for (std::size_t x{}; x < matrix_[y].size(); ++x) {
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(255,255,255), TRUE);
break;
case 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, 0, 0), TRUE);
break;
default:
DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi, GetColor(128,128,128), TRUE);
break;
}
}
}
void Main() {
using shape_t = std::uint_fast8_t;
constexpr std::size_t width{ 64 };
constexpr std::size_t height{ 64 };
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::Init<shape_t>(0).draw(matrix);
dtl::CellularAutomatonIsland<shape_t>(1, 0, 30, 0.4).draw(matrix);
dtl::Rect<shape_t>(dtl::GetLargestRectArea<shape_t>(1).draw(matrix), 5).draw(matrix);
DxLib::ClearDrawScreen();
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(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{ 8 };
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 };
for (std::size_t y{}; y < matrix_.size(); ++y)
for (std::size_t x{}; x < matrix_[y].size(); ++x) {
DrawBox(static_cast<int>(x) * hachi, static_cast<int>(y) * hachi, static_cast<int>(x + 1) * hachi, static_cast<int>(y + 1) * hachi,
(matrix_[y][x] == 1) ? GetColor(35, 100, 180) : GetColor(235, 235, 235), TRUE);
}
}
void Main() {
using shape_t = std::uint_fast8_t;
constexpr std::size_t width{ 64 };
constexpr std::size_t height{ 64 };
std::array<std::array<shape_t, width>, height> matrix{ {} };
dtl::shape::MazeBar<shape_t> fil(0, 1);;
fil.draw(matrix);
constexpr int update_timer{ 30 };
int now_timer{ update_timer };
while (System::Update()) {
if (now_timer >= update_timer) {
now_timer = 0;
dtl::Init<shape_t>().draw(matrix);
fil.draw(matrix);
output(matrix);
}
++now_timer;
}
}
#include <DTL.hpp>
#include <DxLib.h>
namespace System {
bool Update() noexcept { return (DxLib::ScreenFlip() != -1 && DxLib::ProcessMessage() != -1 && DxLib::ClearDrawScreen() != -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();
}
void Main() {
using shape_t = std::uint_fast8_t;
constexpr std::size_t width{ 31 };
constexpr std::size_t height{ 31 };
constexpr int hachi{ 8 };
constexpr float speed{ 0.4f };
std::array<std::array<shape_t, width>, height> matrix_{ {} };
dtl::shape::MazeBar<shape_t> fil(0, 1);;
fil.draw(matrix_);
bool isKey{ false };
dtl::MatrixRange win(0, 0, 512, 512); //描画範囲
dtl::MatrixVec2 wp(hachi, hachi); //マスのサイズ
dtl::Vec2<float> mc(width / 2.0f, height / 2.0f); //視点
dtl::Vec2<int> wssp{}; //始点座標
dtl::MatrixVec2 wsss{}; //始点位置
//dtl::Vec2<int> wsss{}; //始点位置
dtl::utility::setCamera<float, int>(win, wp, mc, wssp, wsss);
//dtl::utility::setCameraLoop<float, int>(win, wp, mc, wssp, wsss);
while (System::Update()) {
isKey = false;
if (CheckHitKey(KEY_INPUT_W) == 1) {
mc.y -= speed;
isKey = true;
}
if (CheckHitKey(KEY_INPUT_S) == 1) {
mc.y += speed;
isKey = true;
}
if (CheckHitKey(KEY_INPUT_A) == 1) {
mc.x -= speed;
isKey = true;
}
if (CheckHitKey(KEY_INPUT_D) == 1) {
mc.x += speed;
isKey = true;
}
if (isKey) dtl::utility::setCamera<float, int>(win, wp, mc, wssp, wsss);
//dtl::utility::setCameraLoop<float, int>(win, wp, mc, wssp, wsss);
dtl::Vec2<int> wssp2(wssp);
////cameraLoop
//dtl::Vec2<int> wsss2(wsss);
//while (wsss2.x < 0) wsss2.x += (int)matrix_[0].size();
//while (wsss2.y < 0) wsss2.y += (int)matrix_.size();
//for (int y{ wsss2.y };; ++y) {
// y %= (int)matrix_.size();
// wssp2.x = wssp.x;
// for (int x{ wsss2.x };; ++x) {
// x %= (int)matrix_[y].size();
// DrawBox(wssp2.x, wssp2.y, wssp2.x + static_cast<int>(wp.x), wssp2.y + static_cast<int>(wp.y),
// (matrix_[y][x] == 1) ? GetColor(35, 100, 180) : GetColor(235, 235, 235), TRUE);
// wssp2.x += int(wp.x);
// if (wssp2.x >= win.w) break;
// }
// wssp2.y += int(wp.y);
// if (wssp2.y >= win.h) break;
//}
//camera
for (size_t y{ wsss.y }; y < matrix_.size(); ++y) {
wssp2.x = wssp.x;
for (size_t x{ wsss.x }; x < matrix_[y].size(); ++x) {
DrawBox(wssp2.x, wssp2.y, wssp2.x + static_cast<int>(wp.x), wssp2.y + static_cast<int>(wp.y),
(matrix_[y][x] == 1) ? GetColor(35, 100, 180) : GetColor(235, 235, 235), TRUE);
wssp2.x += int(wp.x);
if (wssp2.x >= win.w) break;
}
wssp2.y += int(wp.y);
if (wssp2.y >= win.h) break;
}
DrawCircle((int)win.w / 2, (int)win.h / 2, hachi / 2, GetColor(255, 50, 50), TRUE);
}
}
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)