Skip to content

Instantly share code, notes, and snippets.

@plasma-effect
Created June 1, 2016 15:21
Show Gist options
  • Save plasma-effect/eaa0d84d34f9836ecabc79bac852e29a to your computer and use it in GitHub Desktop.
Save plasma-effect/eaa0d84d34f9836ecabc79bac852e29a to your computer and use it in GitHub Desktop.
plasma.Coroutineは死にました
#include<Siv3D.hpp>
#include<boost/coroutine2/all.hpp>
#include<boost/optional.hpp>
std::vector<int> vec;
boost::optional<int> opt;
constexpr int count = 2;
std::wstring str;
const wchar_t message[] = L"新しい数字を入力するが良い";
void test(boost::coroutines2::coroutine<int>::push_type& yield)
{
while (true)
{
if (opt)
{
vec.emplace_back(*opt);
str.clear();
for (auto const& c : message)
{
str += c;
for (int i{};i < count;++i)
{
yield(0);
}
}
str += L"▼";
opt.reset();
yield(1);
}
yield(0);
}
}
void Main()
{
boost::coroutines2::coroutine<int>::pull_type Test(test);
s3d::Key input[] =
{
s3d::Input::Key0,
s3d::Input::Key1,
s3d::Input::Key2,
s3d::Input::Key3,
s3d::Input::Key4,
s3d::Input::Key5,
s3d::Input::Key6,
s3d::Input::Key7,
s3d::Input::Key8,
s3d::Input::Key9
};
bool f{};
s3d::Font font(30);
str = L"数字を入力するがよい";
while (s3d::System::Update())
{
if (!f)
{
for (int i{};i < std::size(input);++i)
{
if (input[i].clicked)
{
opt.emplace(i);
f = true;
break;
}
}
}
if (Test().get() == 1)
{
f = false;
}
for (int i{};i < vec.size();++i)
{
font(vec[i]).draw(i * 24, 0);
}
font(str).draw(0, 36);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment