Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dabbertorres/spritebatch
SFML Sprite Batch
https://github.com/dabbertorres/spritebatch
Last synced: 2 months ago
JSON representation
SFML Sprite Batch
- Host: GitHub
- URL: https://github.com/dabbertorres/spritebatch
- Owner: dabbertorres
- License: mit
- Created: 2015-01-20T02:29:15.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2024-04-29T19:35:50.000Z (9 months ago)
- Last Synced: 2024-04-29T20:47:45.560Z (9 months ago)
- Language: C++
- Size: 12.7 KB
- Stars: 13
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SwiftSpriteBatch
SFML Sprite Batch# Example Usage
```cpp
#include
#include
#include#include "SpriteBatch.hpp"
#include "Sprite.hpp"int main(int argc, char **argv)
{
sf::RenderWindow window;
window.create({800, 600, 32}, "SFML");
sf::Texture texture;
if(!texture.loadFromFile("ftlGrizzly.png"))
{
std::cerr << "error loading texture\n";
}
swift::SpriteBatch batch(texture, 2);
swift::Sprite spriteOne(batch);
spriteOne.setOrigin({spriteOne.getLocalBounds().width / 2, spriteOne.getLocalBounds().height / 2});
spriteOne.setScale({2, 2});
spriteOne.setPosition({400, 400});
spriteOne.scale({0.5, 0.5});
swift::Sprite spriteTwo(batch);
spriteTwo.setPosition({400, 200});
while(window.isOpen())
{
sf::Event event;
while(window.pollEvent(event))
{
switch(event.type)
{
case sf::Event::Closed:
window.close();
break;
case sf::Event::KeyPressed:
if(event.key.code == sf::Keyboard::Escape)
window.close();
break;
default:
break;
}
}
window.clear();
window.draw(batch);
window.display();
}
return 0;
}
```