Java-Gaming.org Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (612)
Games in Android Showcase (172)
games submitted by our members
Games in WIP (658)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
  JavaGaming.org - Pastebin



Author: davedes (posted 2013-01-02 15:40:11, viewed 319 times)

1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   24   25   26   27   28   29   30   31   32   33   34   35   36   37   38   39   40   41   42   43   44   45   46   47   48   49   50   51   52   53   54   55   56  
//TYPE_INT_ARGB color table
public static final int[] TABLE = new int[] {
   0x0,   //transparent
   0xff1a1a1a,   //R=26, G=26, B=26, A=255
   0xffbfbfbf,   //R=191, G=191, B=191, A=255
   0xffa29446,   //R=162, G=148, B=70, A=255
   0xfff7e26b,   //R=247, G=226, B=107, A=255
   0xffc20000,   //R=194, G=0, B=0, A=255
   0xffff0000,   //R=255, G=0, B=0, A=255
   0xff9d9d9d,   //R=157, G=157, B=157, A=255
   0xff6f4417,   //R=111, G=68, B=23, A=255
   0xffa46422   //R=164, G=100, B=34, A=255
};

//sprite array properties
public static final int SPRITE_WIDTH = 11;
public static final int SPRITE_HEIGHT = 9;
public static final int SPRITE_COUNT = 6;
public static final int SPRITE_STRIDE = SPRITE_WIDTH * SPRITE_HEIGHT;
public static final int SPRITE_ARRAY_LEN = SPRITE_STRIDE * SPRITE_COUNT;

//offsets to different sprite indices
public static final int SPRITE_PIRATE1_ATTACK = 0;
public static final int SPRITE_PIRATE1_WALK1 = 1;
public static final int SPRITE_PIRATE1_WALK2 = 2;
public static final int SPRITE_PIRATE2_ATTACK = 3;
public static final int SPRITE_PIRATE2_WALK1 = 4;
public static final int SPRITE_PIRATE2_WALK2 = 5;

//////// ENCODING METHOD: Simple Indexed Color Encoding
public static final BufferedImage SPRITE_SHEET = new BufferedImage(SPRITE_WIDTH, SPRITE_HEIGHT * SPRITE_COUNT, BufferedImage.TYPE_INT_ARGB);
public static final int[] SPRITE_PIXELS = ((DataBufferInt)SPRITE_SHEET.getRaster().getDataBuffer()).getData();
public static final BufferedImage[] SPRITES = new BufferedImage[SPRITE_COUNT];

for (int i=0; i<SPRITE_ARRAY_LEN; i++) {
   SPRITE_PIXELS[i] = TABLE["000000000001111212000011111110000034141000000344430000255666502220411171400000888880000008000800000000000000001111212020011111110200034141002000344430200055666540000411171000000888880000008000800000111121202001111111020003414100200034443020005566654000041117100000088888000000888880000008000800000000000000006066600000006666600000634141000000344430000288999802220411171400000888880000008000800000000000000006066600020006666600200634141002000344430200088999840000411171000000888880000008000800000606660002000666660020063414100200034443020008899984000041117100000088888000000888880000008000800000".charAt(i)-48];
   if (i%SPRITE_STRIDE == SPRITE_STRIDE-1) {
      SPRITES[i/(SPRITE_WIDTH*SPRITE_HEIGHT)] = SPRITE_SHEET.getSubimage(
         0, i/(SPRITE_WIDTH*SPRITE_HEIGHT)*SPRITE_HEIGHT, 
         SPRITE_WIDTH, SPRITE_HEIGHT);
   }
}

//////// ENCODING METHOD: PNG Encoding
// You can remove the color table and some of the constants defined earlier
BufferedImage SPRITE_SHEET = null;
BufferedImage[] SPRITES = new BufferedImage[SPRITE_COUNT];
try {
   SPRITE_SHEET = ImageIO.read(new ByteArrayInputStream(DatatypeConverter.parseBase64Binary(
      "iVBORw0KGgoAAAANSUhEUgAAAAsAAAA2CAYAAAARSGNVAAAAvUlEQVR42mNgIAVISUn9R8b79++H0wQVI2Ospi+a4vb/+6NssAIYjdMpMMUwDOKjqwE76xADw38Q/o+EQXyYAhgG64BZC8Nz586FOwerM/JdxP+jY5xuRpfEq5hqkYISOYQiBSMm8UUKTsXokYKhEFekYA1nXJGCN5ypHymj4UxxOA9wTvkPzfbIoUFQAzrGqZA2xRcsqJakKMExLDSGRfFFKFIw0jS+SEFRTChSyM9WuCJlMBdfo+E8+IovAE/bY0jTK+k2AAAAAElFTkSuQmCC"
      )));
   for (int i=0; i<SPRITE_COUNT; i++) 
      SPRITES[i] = SPRITE_SHEET.getSubimage(0, i*SPRITE_HEIGHT, SPRITE_WIDTH, SPRITE_HEIGHT);
} catch (Exception e) {
   // TODO Auto-generated catch block
}





Dump your java code here :



Special syntax:
  • To highlight a line (yellow background), prefix it with '@@'
  • To indicate that a line should be removed (red background), prefix it with '-'
  • To indicate that a line should be added (green background), prefix it with '+'
  • To post multiple snippets, seperate them by '~~~~'
  EOF
 
Roquen (16 views)
2015-08-29 11:30:54

GamerC4 (26 views)
2015-08-22 20:38:50

GamerC4 (24 views)
2015-08-22 20:37:18

GamerC4 (28 views)
2015-08-22 20:37:01

Kefwar (33 views)
2015-08-22 18:07:24

GamerC4 (26 views)
2015-08-22 01:00:24

GamerC4 (38 views)
2015-08-22 01:00:17

GamerC4 (25 views)
2015-08-22 00:57:35

GamerC4 (26 views)
2015-08-22 00:56:59

BurntPizza (32 views)
2015-08-21 01:38:01
HotSpot Options
by Roquen
2015-08-29 11:33:11

Rendering resources
by Roquen
2015-08-17 12:42:29

Rendering resources
by Roquen
2015-08-17 09:36:56

Rendering resources
by Roquen
2015-08-13 07:40:51

Networking Resources
by Roquen
2015-08-13 07:40:43

List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!