Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int[] dots()throws FileNotFoundException, IOException {
- int[] rez = new int[64 * 128];
- DataInputStream ds = new DataInputStream(new FileInputStream("game.map"));
- byte[] intData = new byte[4];
- ds.readFully(intData);
- System.out.println("" + (char) intData[0] + (char) intData[1] + (char) intData[2] + (char) intData[3]);
- for (int i = 0; i < 3; i++) { //version, width, height
- ds.readFully(intData);
- System.out.println(ByteBuffer.wrap(intData).order(ByteOrder.LITTLE_ENDIAN).getInt());
- }
- //reading texture info ULE16
- for (int i = 0; i < 64 * 128; i++) {
- System.out.println("----byte#" + (i + 1));
- intData = new byte[2];
- ds.readFully(intData);
- System.out.println(ByteBuffer.wrap(intData).order(ByteOrder.LITTLE_ENDIAN).getShort());
- // reading Height(Z depth) or the tile ULE8
- intData = new byte[1];
- ds.readFully(intData);
- rez[i] = ByteBuffer.wrap(intData).order(ByteOrder.LITTLE_ENDIAN).get();
- System.out.println(ByteBuffer.wrap(intData).order(ByteOrder.LITTLE_ENDIAN).get());
- }
- ds.close();
- return rez;
- }
- +++++++++++++++++++++++++++++++++++++++++OUTPUT TO GUI+++++++++++++++++++++++++
- Graphics g = jPanel1.getGraphics();
- int dots[] = null;
- dots = MapParser.dots();
- int counter = 0;
- for (int i = 0; i < 64; i++) {
- for (int j = 0; j < 128; j++) {
- float color = 0.00f;
- color = (dots[counter] + 128) / 2.56f / 100;
- g.setColor(Color.getHSBColor(0, 0, color));
- g.fillRect(j * 5, i * 5, 5, 5);
- counter++;
- }
- }
- jPanel1.paintComponents(g);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement