daily pastebin goal
50%
SHARE
TWEET

Untitled

a guest Jun 19th, 2017 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //tile.cpp
  2. class Tile
  3. {
  4. private:
  5.     short ID;
  6.     short SX,SY,SWidth,SHeight;
  7.     sf::Image TileImage;
  8.  
  9. public:
  10.     Tile(sf::Image Source, int psx, int psy, int pwidth, int pheight)
  11.     {
  12.         SX      = psx;
  13.         SY      = psy;
  14.         SWidth  = pwidth;
  15.         SHeight = pheight;
  16.        
  17.         TileImage.Create(SWidth,SHeight);
  18.  
  19.         TileImage.Copy(Source,0,0,sf::IntRect(SX,SY,SWidth,SHeight));
  20.     }
  21.     sf::Image GetTileImage()
  22.     {
  23.         return TileImage;
  24.     }
  25. };
  26.  
  27.  
  28. //main.cpp
  29. //
  30. //
  31. //SFML Init
  32. //
  33. //
  34.     sf::Image Source;
  35.     if(!Source.LoadFromFile("Content\\tileset.png"))
  36.     {
  37.         return 1;
  38.     }
  39.  
  40.     Tile T(Source,0,0,50,50);
  41.  
  42. //Tile zeichenen
  43.         Window.Clear(sf::Color::Black);
  44.  
  45.         sf::Sprite S;
  46.         S.SetImage(T.GetTileImage());
  47.         Window.Draw(S);
  48.  
  49.         Window.Display();
RAW Paste Data
Top