Last active
December 11, 2015 06:32
-
-
Save ChunChunMorning/94fdc0613fac4fd16d51 to your computer and use it in GitHub Desktop.
Siv3Dでポーズ画面を簡単に実装する with HamFramework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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