Guest User

Untitled

a guest
Dec 14th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.06 KB | None | 0 0
  1.     public void drawSprite(int i, int k, int color) {
  2.         int tempWidth = myWidth + 2;
  3.         int tempHeight = myHeight + 2;
  4.         int[] tempArray = new int[tempWidth * tempHeight];
  5.         for(int x = 0; x < myWidth; x++) {
  6.             for(int y = 0; y < myHeight; y++) {
  7.                 if(myPixels[x + y * myWidth] != 0)
  8.                     tempArray[(x + 1) + (y + 1) * tempWidth] = myPixels[x + y * myWidth];
  9.             }
  10.         }
  11.         for(int x = 0; x < tempWidth; x++) {
  12.             for(int y = 0; y < tempHeight; y++) {
  13.                 if(tempArray[(x) + (y) * tempWidth] == 0) {
  14.                     if(x < tempWidth - 1 && tempArray[(x + 1) + ((y) * tempWidth)] > 0 && tempArray[(x + 1) + ((y) * tempWidth)] != 0xffffff) {
  15.                         tempArray[(x) + (y) * tempWidth] = color;
  16.                     }
  17.                     if(x > 0 && tempArray[(x - 1) + ((y) * tempWidth)] > 0 && tempArray[(x - 1) + ((y) * tempWidth)] != 0xffffff) {
  18.                         tempArray[(x) + (y) * tempWidth] = color;
  19.                     }
  20.                     if(y < tempHeight - 1 && tempArray[(x) + ((y + 1) * tempWidth)] > 0 && tempArray[(x) + ((y + 1) * tempWidth)] != 0xffffff) {
  21.                         tempArray[(x) + (y) * tempWidth] = color;
  22.                     }
  23.                     if(y > 0 && tempArray[(x) + ((y - 1) * tempWidth)] > 0 && tempArray[(x) + ((y - 1) * tempWidth)] != 0xffffff) {
  24.                         tempArray[(x) + (y) * tempWidth] = color;
  25.                     }
  26.                 }
  27.             }
  28.         }
  29.         i--;
  30.         k--;
  31.         i += drawOffsetX;
  32.         k += drawOffsetY;
  33.         int l = i + k * DrawingArea.width;
  34.         int i1 = 0;
  35.         int j1 = tempHeight;
  36.         int k1 = tempWidth;
  37.         int l1 = DrawingArea.width - k1;
  38.         int i2 = 0;
  39.         if (k < DrawingArea.topY) {
  40.             int j2 = DrawingArea.topY - k;
  41.             j1 -= j2;
  42.             k = DrawingArea.topY;
  43.             i1 += j2 * k1;
  44.             l += j2 * DrawingArea.width;
  45.         }
  46.         if (k + j1 > DrawingArea.bottomY) {
  47.             j1 -= (k + j1) - DrawingArea.bottomY;
  48.         }
  49.         if (i < DrawingArea.topX) {
  50.             int k2 = DrawingArea.topX - i;
  51.             k1 -= k2;
  52.             i = DrawingArea.topX;
  53.             i1 += k2;
  54.             l += k2;
  55.             i2 += k2;
  56.             l1 += k2;
  57.         }
  58.         if (i + k1 > DrawingArea.bottomX) {
  59.             int l2 = (i + k1) - DrawingArea.bottomX;
  60.             k1 -= l2;
  61.             i2 += l2;
  62.             l1 += l2;
  63.         }
  64.         if (!(k1 <= 0 || j1 <= 0)) {
  65.             method349(DrawingArea.pixels, tempArray, i1, l, k1, j1, l1, i2);
  66.         }
Add Comment
Please, Sign In to add comment