-
-
Notifications
You must be signed in to change notification settings - Fork 82
DxLib中級サンプル
Kasugaccho edited this page Apr 30, 2019
·
1 revision
#include <DxLib.h>
#include <DTL.hpp>
#include <cstdint>
#include <cstddef>
#include <array>
#include <bitset>
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) {
SetOutApplicationLogValidFlag(FALSE);
ChangeWindowMode(TRUE);
constexpr std::size_t matrix_size{ 128 };
constexpr std::size_t dungeon_pixel_size{ 2 };
SetGraphMode(int(matrix_size*dungeon_pixel_size), int(matrix_size*dungeon_pixel_size), 32);
if (DxLib_Init() == -1) return -1;
std::array<std::bitset<matrix_size>, matrix_size> matrix{ {} };
dtl::shape::SimpleVoronoiIsland<bool>(100, 0.5, 1, 0).draw(matrix);
dtl::utility::CellularAutomation<bool>().draw(matrix);
for (std::size_t row{}; row < matrix.size(); ++row)
for (std::size_t col{}; col < matrix[row].size(); ++col)
DrawBox(int(col*dungeon_pixel_size), int(row*dungeon_pixel_size), int((col + 1)*dungeon_pixel_size), int((row + 1)*dungeon_pixel_size), (matrix[row][col]) ? GetColor(98, 170, 48) : GetColor(30, 30, 163), TRUE);
WaitKey();
return DxLib_End();
}
#include <DxLib.h>
#include <DTL.hpp>
#include <cstdint>
#include <cstddef>
#include <array>
#include <bitset>
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) {
SetOutApplicationLogValidFlag(FALSE);
ChangeWindowMode(TRUE);
constexpr std::size_t matrix_size_x{ 196 };
constexpr std::size_t matrix_size_y{ 128 };
constexpr std::size_t dungeon_pixel_size{ 2 };
SetGraphMode(int(matrix_size_x*dungeon_pixel_size), int(matrix_size_y*dungeon_pixel_size), 32);
if (DxLib_Init() == -1) return -1;
std::array<std::bitset<matrix_size_x>, matrix_size_y> matrix{ {} };
dtl::shape::SimpleVoronoiIsland<bool>(100, 0.5, 1, 0).draw(matrix);
dtl::utility::CellularAutomation<bool>().draw(matrix);
for (std::size_t row{}; row < matrix.size(); ++row)
for (std::size_t col{}; col < matrix[row].size(); ++col)
DrawBox(int(col*dungeon_pixel_size), int(row*dungeon_pixel_size), int((col + 1)*dungeon_pixel_size), int((row + 1)*dungeon_pixel_size), (matrix[row][col]) ? GetColor(98, 170, 48) : GetColor(30, 30, 163), TRUE);
WaitKey();
return DxLib_End();
}
#include <DxLib.h>
#include <DTL.hpp>
#include <cstdint>
#include <cstddef>
#include <array>
#include <bitset>
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) {
SetOutApplicationLogValidFlag(FALSE);
ChangeWindowMode(TRUE);
constexpr std::size_t matrix_size_x{ 196 };
constexpr std::size_t matrix_size_y{ 128 };
constexpr std::size_t dungeon_pixel_size{ 2 };
SetGraphMode(int(matrix_size_x*dungeon_pixel_size), int(matrix_size_y*dungeon_pixel_size), 32);
if (DxLib_Init() == -1) return -1;
SetDrawScreen(DX_SCREEN_BACK);
std::array<std::bitset<matrix_size_x>, matrix_size_y> matrix{ {} };
constexpr int loop_counter_max{ 20 };
int loop_counter{ loop_counter_max };
while (ScreenFlip() == 0 && ProcessMessage() == 0 && CheckHitKey(KEY_INPUT_ESCAPE) == 0) {
if (loop_counter >= loop_counter_max) {
dtl::utility::Init<bool>(0).draw(matrix);
dtl::shape::SimpleVoronoiIsland<bool>(100, 0.5, 1, 0).draw(matrix);
dtl::utility::CellularAutomation<bool>().draw(matrix);
loop_counter = 0;
}
for (std::size_t row{}; row < matrix.size(); ++row)
for (std::size_t col{}; col < matrix[row].size(); ++col)
DrawBox(int(col*dungeon_pixel_size), int(row*dungeon_pixel_size), int((col + 1)*dungeon_pixel_size), int((row + 1)*dungeon_pixel_size), (matrix[row][col]) ? GetColor(98, 170, 48) : GetColor(30, 30, 163), TRUE);
++loop_counter;
}
return DxLib_End();
}
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)