Skip to content

Instantly share code, notes, and snippets.

@Reputeless
Created June 12, 2017 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Reputeless/68831eca61a1808b897d3ca923e7091a to your computer and use it in GitHub Desktop.
Save Reputeless/68831eca61a1808b897d3ca923e7091a to your computer and use it in GitHub Desktop.
# 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