Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
# include <Siv3D.hpp>
Array<TextureRegion> LoadTextureRegions(const FilePath& path, const Size& size)
{
const Texture texture(path);
Array<TextureRegion> textureRegions;
for (auto p : step(Size(texture.width / size.x, texture.height / size.y)))
{
textureRegions.push_back(texture(p * size, size));
}
return textureRegions;
}
void Main()
{
const Array<TextureRegion> textureRegions = LoadTextureRegions(L"example/windmill.png", Size(40, 20));
while (System::Update())
{
for (size_t i = 0; i < textureRegions.size(); ++i)
{
textureRegions[i].draw(42 * (i % 12), 22 * (i / 12));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment