Skip to content

Instantly share code, notes, and snippets.

@ChunChunMorning ChunChunMorning/Main.cpp
Last active Dec 11, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.