well.cc 604 B

1234567891011121314151617181920212223242526
  1. #include "well.hh"
  2. #include <iostream>
  3. Well::Well():
  4. data{0}
  5. {
  6. /*for(auto i=0;i<Constants::WIDTH; i++)
  7. for(auto j=0; j<Constants::HEIGHT; j++)
  8. data[i][j] = 6;*/
  9. }
  10. void Well::draw(SDL_Renderer* renderer, SDL_Texture* blocksTexture)
  11. {
  12. for(auto x=0; x<Constants::WIDTH; ++x)
  13. for(auto y=0; y<Constants::HEIGHT; ++y)
  14. {
  15. if(data[x][y] != 0)
  16. {
  17. SDL_Rect posRect{(x+1)*Constants::BLOCK_SIZE, y*Constants::BLOCK_SIZE, Constants::BLOCK_SIZE, Constants::BLOCK_SIZE};
  18. SDL_Rect texRect{(data[x][y]-1)*8, 0, 8, 8};
  19. SDL_RenderCopy(renderer, blocksTexture, &texRect, &posRect);
  20. }
  21. }
  22. }