Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //tile.cpp
- class Tile
- {
- private:
- short ID;
- short SX,SY,SWidth,SHeight;
- sf::Image TileImage;
- public:
- Tile(sf::Image Source, int psx, int psy, int pwidth, int pheight)
- {
- SX = psx;
- SY = psy;
- SWidth = pwidth;
- SHeight = pheight;
- TileImage.Create(SWidth,SHeight);
- TileImage.Copy(Source,0,0,sf::IntRect(SX,SY,SWidth,SHeight));
- }
- sf::Image GetTileImage()
- {
- return TileImage;
- }
- };
- //main.cpp
- //
- //
- //SFML Init
- //
- //
- sf::Image Source;
- if(!Source.LoadFromFile("Content\\tileset.png"))
- {
- return 1;
- }
- Tile T(Source,0,0,50,50);
- //Tile zeichenen
- Window.Clear(sf::Color::Black);
- sf::Sprite S;
- S.SetImage(T.GetTileImage());
- Window.Draw(S);
- Window.Display();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement