Guest User

Untitled

a guest
Dec 12th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. public void render(int xPos, int yPos, int tile, int color, boolean mirrorX, boolean mirrorY)
  2. {
  3.  
  4. xPos -= xOff;
  5. yPos -= yOff;
  6.  
  7. int xTile = tile % 32;
  8. int yTile = tile / 32;
  9. int tileOffset = (xTile << 3) + (yTile << 3) * sheet.width;
  10.  
  11. for (int y = 0; y < 8; y++)
  12. {
  13.  
  14. if (y + yPos < 0 || y + yPos >= height)
  15. {
  16. continue;
  17. }
  18. int ySheet = y;
  19. if (mirrorY)
  20. {
  21. ySheet = 7-y;
  22. }
  23. for (int x = 0; x < 8; x++)
  24. {
  25. if (x + xPos < 0 || x + xPos >= width)
  26. {
  27. continue;
  28. }
  29. int xSheet = x;
  30. if (mirrorX)
  31. {
  32. xSheet = 7-x;
  33. }
  34. int col = (color >> (sheet.pixels[xSheet + ySheet * sheet.width + tileOffset] * 8)) & 255;
  35. if (col < 255)
  36. {
  37. pixels[(x + xPos) + (y + yPos) * width] = col;
  38. }
  39. }
  40. }
  41. }
Add Comment
Please, Sign In to add comment