-
-
Save Reputeless/68831eca61a1808b897d3ca923e7091a to your computer and use it in GitHub Desktop.
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> | |
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