Skip to content

Instantly share code, notes, and snippets.

@ChunChunMorning
Last active December 11, 2015 06:32
Show Gist options
  • Save ChunChunMorning/94fdc0613fac4fd16d51 to your computer and use it in GitHub Desktop.
Save ChunChunMorning/94fdc0613fac4fd16d51 to your computer and use it in GitHub Desktop.
Siv3Dでポーズ画面を簡単に実装する with HamFramework
# include <Siv3D.hpp>
# include <HamFramework.hpp>
struct GameData {};
struct Game : SceneManager<String, GameData>::Scene
{
Font font;
Circle player;
Array<Circle> bullets;
bool pause;
void init() override
{
font = Font(20);
player = Circle(320, 400, 50);
pause = false;
}
void update() override
{
if (Input::KeyP.clicked)
{
pause = !pause;
}
if (pause)
{
return;
}
if (Input::KeyLeft.pressed)
{
player.moveBy(Vec2::Left);
}
if (Input::KeyRight.pressed)
{
player.moveBy(Vec2::Right);
}
if (Input::KeyZ.clicked)
{
bullets.emplace_back(player.center, 10);
}
for (auto& bullet : bullets)
{
bullet.moveBy(5.0 * Vec2::Up);
}
player.draw(Palette::Red);
}
void draw() const override
{
for (auto& bullet : bullets)
{
bullet.draw(Palette::Blue);
}
player.draw(Palette::Red);
if (pause)
{
font(L"ポーズ中").drawCenter(240, Palette::Yellow);
}
}
};
void Main()
{
SceneManager<String, GameData> manager;
manager.add<Game>(L"Game");
while (System::Update())
{
if (!manager.updateAndDraw())
break;
if (Input::KeyS.clicked)
{
ScreenCapture::Save();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment