Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.mousemaze;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.image.BufferedImage;
- import javax.swing.ImageIcon;
- public class Textures {
- private int time = 0;
- public Image[] font7x7WhiteOnBlack;
- public Image[] font7x7BlackOnWhite;
- public Image[] platformWhite;
- public Image ButtonPlayNormal, ButtonPlayHover, ButtonPlayDown;
- public Image ButtonQuitNormal, ButtonQuitHover, ButtonQuitDown;
- private final boolean I = true, O = false;
- private final boolean[][] platformLetterAmap = {
- new boolean[] { O, O, I, I, I, O, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, I, I, I, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O } };
- private final boolean[][] platformLetterBmap = {
- new boolean[] { O, I, I, I, I, O, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, I, I, I, O, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, I, I, I, O, O } };
- private final boolean[][] platformLetterCmap = {
- new boolean[] { O, O, I, I, I, O, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, O, O },
- new boolean[] { O, I, O, O, O, O, O },
- new boolean[] { O, I, O, O, O, O, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, O, I, I, I, O, O } };
- private final boolean[][] platformLetterDmap = {
- new boolean[] { O, I, I, I, I, O, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, I, I, I, O, O } };
- private final boolean[][] platformLetterEmap = {
- new boolean[] { O, I, I, I, I, I, O },
- new boolean[] { O, I, O, O, O, O, O },
- new boolean[] { O, I, O, O, O, O, O },
- new boolean[] { O, I, I, I, I, O, O },
- new boolean[] { O, I, O, O, O, O, O },
- new boolean[] { O, I, O, O, O, O, O },
- new boolean[] { O, I, I, I, I, I, O } };
- private final boolean[][] platformLetterFmap = {
- new boolean[] { O, I, I, I, I, I, O },
- new boolean[] { O, I, O, O, O, O, O },
- new boolean[] { O, I, O, O, O, O, O },
- new boolean[] { O, I, I, I, I, O, O },
- new boolean[] { O, I, O, O, O, O, O },
- new boolean[] { O, I, O, O, O, O, O },
- new boolean[] { O, I, O, O, O, O, O } };
- private final boolean[][] platformLetterGmap = {
- new boolean[] { O, O, I, I, I, O, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, O, O },
- new boolean[] { O, I, O, O, O, O, O },
- new boolean[] { O, I, O, I, I, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, O, I, I, I, I, O } };
- private final boolean[][] platformLetterHmap = {
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, I, I, I, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O } };
- private final boolean[][] platformLetterImap = {
- new boolean[] { O, I, I, I, I, I, O },
- new boolean[] { O, O, O, I, O, O, O },
- new boolean[] { O, O, O, I, O, O, O },
- new boolean[] { O, O, O, I, O, O, O },
- new boolean[] { O, O, O, I, O, O, O },
- new boolean[] { O, O, O, I, O, O, O },
- new boolean[] { O, I, I, I, I, I, O } };
- private final boolean[][] platformLetterJmap = {
- new boolean[] { O, I, I, I, I, I, O },
- new boolean[] { O, O, O, O, I, O, O },
- new boolean[] { O, O, O, O, I, O, O },
- new boolean[] { O, O, O, O, I, O, O },
- new boolean[] { O, I, O, O, I, O, O },
- new boolean[] { O, I, O, O, I, O, O },
- new boolean[] { O, O, I, I, O, O, O } };
- private final boolean[][] platformLetterKmap = {
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, I, O, O },
- new boolean[] { O, I, O, I, O, O, O },
- new boolean[] { O, I, I, O, I, O, O },
- new boolean[] { O, I, O, O, I, O, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O } };
- private final boolean[][] platformLetterLmap = {
- new boolean[] { O, I, O, O, O, O, O },
- new boolean[] { O, I, O, O, O, O, O },
- new boolean[] { O, I, O, O, O, O, O },
- new boolean[] { O, I, O, O, O, O, O },
- new boolean[] { O, I, O, O, O, O, O },
- new boolean[] { O, I, O, O, O, O, O },
- new boolean[] { O, I, I, I, I, I, O } };
- private final boolean[][] platformLetterMmap = {
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, I, O, I, I, O },
- new boolean[] { O, I, O, I, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O } };
- private final boolean[][] platformLetterNmap = {
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, I, O, O, I, O },
- new boolean[] { O, I, O, I, O, I, O },
- new boolean[] { O, I, O, O, I, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O } };
- private final boolean[][] platformLetterOmap = {
- new boolean[] { O, O, I, I, I, O, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, O, I, I, I, O, O } };
- private final boolean[][] platformLetterPmap = {
- new boolean[] { O, I, I, I, I, O, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, I, I, I, O, O },
- new boolean[] { O, I, O, O, O, O, O },
- new boolean[] { O, I, O, O, O, O, O },
- new boolean[] { O, I, O, O, O, O, O } };
- private final boolean[][] platformLetterQmap = {
- new boolean[] { O, O, I, I, I, O, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, I, O, I, O },
- new boolean[] { O, I, O, O, I, O, O },
- new boolean[] { O, O, I, I, O, I, O } };
- private final boolean[][] platformLetterRmap = {
- new boolean[] { O, I, I, I, I, O, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, I, I, I, O, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O } };
- private final boolean[][] platformLetterSmap = {
- new boolean[] { O, O, I, I, I, O, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, O, O },
- new boolean[] { O, O, I, I, I, O, O },
- new boolean[] { O, O, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, O, I, I, I, O, O } };
- private final boolean[][] platformLetterTmap = {
- new boolean[] { O, I, I, I, I, I, O },
- new boolean[] { O, O, O, I, O, O, O },
- new boolean[] { O, O, O, I, O, O, O },
- new boolean[] { O, O, O, I, O, O, O },
- new boolean[] { O, O, O, I, O, O, O },
- new boolean[] { O, O, O, I, O, O, O },
- new boolean[] { O, O, O, I, O, O, O } };
- private final boolean[][] platformLetterUmap = {
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, O, I, I, I, I, O } };
- private final boolean[][] platformLetterVmap = {
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, O, I, O, I, O, O },
- new boolean[] { O, O, I, O, I, O, O },
- new boolean[] { O, O, I, O, I, O, O },
- new boolean[] { O, O, O, I, O, O, O } };
- private final boolean[][] platformLetterWmap = {
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, I, O, I, O },
- new boolean[] { O, I, I, O, I, I, O },
- new boolean[] { O, I, O, O, O, I, O } };
- private final boolean[][] platformLetterXmap = {
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, O, I, O, I, O, O },
- new boolean[] { O, O, O, I, O, O, O },
- new boolean[] { O, O, I, O, I, O, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O } };
- private final boolean[][] platformLetterYmap = {
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, I, O, O, O, I, O },
- new boolean[] { O, O, I, O, I, O, O },
- new boolean[] { O, O, O, I, O, O, O },
- new boolean[] { O, O, O, I, O, O, O },
- new boolean[] { O, O, O, I, O, O, O },
- new boolean[] { O, O, O, I, O, O, O } };
- private final boolean[][] platformLetterZmap = {
- new boolean[] { O, I, I, I, I, I, O },
- new boolean[] { O, O, O, O, O, I, O },
- new boolean[] { O, O, O, O, I, O, O },
- new boolean[] { O, O, O, I, O, O, O },
- new boolean[] { O, O, I, O, O, O, O },
- new boolean[] { O, I, O, O, O, O, O },
- new boolean[] { O, I, I, I, I, I, O } };
- public final Image[] whitePlatfomFont = new Image[26];
- public Textures() {
- BufferedImage fontSheet = createBufferedImage("Resource\\Font\\FontA.png");
- BufferedImage fontSheetb = createBufferedImage("Resource\\Font\\FontB.png");
- BufferedImage platformWhiteSheet = createBufferedImage("Resource\\TileSets\\TileBlueCoreV2.png");
- font7x7BlackOnWhite = parse(fontSheet, 7, 7, 7, 7);
- font7x7WhiteOnBlack = parse(fontSheetb, 7, 7, 7, 7);
- platformWhite = parse(platformWhiteSheet, 16, 16, 4, 4);
- whitePlatfomFont[0] = getPlatformMatrixFor(platformLetterAmap, platformWhite);
- whitePlatfomFont[1] = getPlatformMatrixFor(platformLetterBmap, platformWhite);
- whitePlatfomFont[2] = getPlatformMatrixFor(platformLetterCmap, platformWhite);
- whitePlatfomFont[3] = getPlatformMatrixFor(platformLetterDmap, platformWhite);
- whitePlatfomFont[4] = getPlatformMatrixFor(platformLetterEmap, platformWhite);
- whitePlatfomFont[5] = getPlatformMatrixFor(platformLetterFmap, platformWhite);
- whitePlatfomFont[6] = getPlatformMatrixFor(platformLetterGmap, platformWhite);
- whitePlatfomFont[7] = getPlatformMatrixFor(platformLetterHmap, platformWhite);
- whitePlatfomFont[8] = getPlatformMatrixFor(platformLetterImap, platformWhite);
- whitePlatfomFont[9] = getPlatformMatrixFor(platformLetterJmap, platformWhite);
- whitePlatfomFont[10] = getPlatformMatrixFor(platformLetterKmap, platformWhite);
- whitePlatfomFont[11] = getPlatformMatrixFor(platformLetterLmap, platformWhite);
- whitePlatfomFont[12] = getPlatformMatrixFor(platformLetterMmap, platformWhite);
- whitePlatfomFont[13] = getPlatformMatrixFor(platformLetterNmap, platformWhite);
- whitePlatfomFont[14] = getPlatformMatrixFor(platformLetterOmap, platformWhite);
- whitePlatfomFont[15] = getPlatformMatrixFor(platformLetterPmap, platformWhite);
- whitePlatfomFont[16] = getPlatformMatrixFor(platformLetterQmap, platformWhite);
- whitePlatfomFont[17] = getPlatformMatrixFor(platformLetterRmap, platformWhite);
- whitePlatfomFont[18] = getPlatformMatrixFor(platformLetterSmap, platformWhite);
- whitePlatfomFont[19] = getPlatformMatrixFor(platformLetterTmap, platformWhite);
- whitePlatfomFont[20] = getPlatformMatrixFor(platformLetterUmap, platformWhite);
- whitePlatfomFont[21] = getPlatformMatrixFor(platformLetterVmap, platformWhite);
- whitePlatfomFont[22] = getPlatformMatrixFor(platformLetterWmap, platformWhite);
- whitePlatfomFont[23] = getPlatformMatrixFor(platformLetterXmap, platformWhite);
- whitePlatfomFont[24] = getPlatformMatrixFor(platformLetterYmap, platformWhite);
- whitePlatfomFont[25] = getPlatformMatrixFor(platformLetterZmap, platformWhite);
- ButtonPlayNormal = parse(createBufferedImage("Resource\\Button\\Play.png"), 200, 50, 1, 3)[0];
- ButtonPlayHover = parse(createBufferedImage("Resource\\Button\\Play.png"), 200, 50, 1, 3)[1];
- ButtonPlayDown = parse(createBufferedImage("Resource\\Button\\Play.png"), 200, 50, 1, 3)[2];
- ButtonQuitNormal = parse(createBufferedImage("Resource\\Button\\Quit.png"), 200, 50, 1, 3)[0];
- ButtonQuitHover = parse(createBufferedImage("Resource\\Button\\Quit.png"), 200, 50, 1, 3)[1];
- ButtonQuitDown = parse(createBufferedImage("Resource\\Button\\Quit.png"), 200, 50, 1, 3)[2];
- }
- public Image parseString(Image[] font, String s) {
- Image _return = createBufferedImage(font[0].getWidth(null) * s.length(), font[0].getHeight(null));
- int i = 0;
- Graphics g = _return.getGraphics();
- while (i < s.length()) {
- if ((int) s.charAt(i) - 97 == -65) {
- i++;
- } else {
- g.drawImage(font[(int) s.charAt(i) - 97],
- font[0].getWidth(null) * i, 0, null);
- i++;
- }
- }
- return _return;
- }
- public Image getPlatformMatrixFor(boolean[][] b, Image[] blocks) {
- Image _return = createBufferedImage(112, 112);
- Graphics g = _return.getGraphics();
- int y = 0, x = 0;
- while (y < b.length) {
- while (x < b[0].length) {
- boolean top = false, right = false, bottom = false, left = false;
- try {
- if (b[x][y - 1]) {
- top = true;
- }
- } catch (Exception e) {
- }
- try {
- if (b[x + 1][y]) {
- right = true;
- }
- } catch (Exception e) {
- }
- try {
- if (b[x][y + 1]) {
- bottom = true;
- }
- } catch (Exception e) {
- }
- try {
- if (b[x - 1][y]) {
- left = true;
- }
- } catch (Exception e) {
- }
- if (b[x][y]) {
- if (top) {
- if (bottom) {
- if (right) {
- if (left) {
- g.drawImage(blocks[0], y * 16, x * 16, null);
- } else {
- g.drawImage(blocks[9], y * 16, x * 16, null);
- }
- } else {
- if (left) {
- g.drawImage(blocks[11], y * 16, x * 16,
- null);
- } else {
- g.drawImage(blocks[6], y * 16, x * 16, null);
- }
- }
- } else {
- if (right) {
- if (left) {
- g.drawImage(blocks[10], y * 16, x * 16,
- null);
- } else {
- g.drawImage(blocks[15], y * 16, x * 16,
- null);
- }
- } else {
- if (left) {
- g.drawImage(blocks[14], y * 16, x * 16,
- null);
- } else {
- g.drawImage(blocks[3], y * 16, x * 16, null);
- }
- }
- }
- } else {
- if (bottom) {
- if (right) {
- if (left) {
- g.drawImage(blocks[8], y * 16, x * 16, null);
- } else {
- g.drawImage(blocks[12], y * 16, x * 16,
- null);
- }
- } else {
- if (left) {
- g.drawImage(blocks[13], y * 16, x * 16,
- null);
- } else {
- g.drawImage(blocks[1], y * 16, x * 16, null);
- }
- }
- } else {
- if (right) {
- if (left) {
- g.drawImage(blocks[5], y * 16, x * 16, null);
- } else {
- g.drawImage(blocks[2], y * 16, x * 16, null);
- }
- } else {
- if (left) {
- g.drawImage(blocks[4], y * 16, x * 16, null);
- } else {
- g.drawImage(blocks[0], y * 16, x * 16, null);
- }
- }
- }
- }
- }
- x++;
- }
- x = 0;
- y++;
- }
- return _return;
- }
- private BufferedImage createBufferedImage(String directory) {
- Image img = new ImageIcon(directory).getImage();
- BufferedImage bimg = new BufferedImage(img.getWidth(null),
- img.getHeight(null), BufferedImage.TRANSLUCENT);
- Graphics g = bimg.getGraphics();
- g.drawImage(img, 0, 0, null);
- return bimg;
- }
- private BufferedImage createBufferedImage(int width, int height) {
- return new BufferedImage(width, height, BufferedImage.TRANSLUCENT);
- }
- private BufferedImage[] parse(BufferedImage imgIn, int width, int height,
- int imgWidth, int imgHeight) {
- BufferedImage[] _return = new BufferedImage[imgWidth * imgHeight];
- int i = 0, j = 0;
- while (i < imgHeight) {
- while (j < imgWidth) {
- BufferedImage temp = new BufferedImage(width, height,
- BufferedImage.TRANSLUCENT);
- Graphics g = temp.getGraphics();
- g.drawImage(imgIn, 0, 0, width, height, j * width, i * height,
- (j * width) + width, (i * height) + height, null);
- _return[(i * imgWidth) + j] = temp;
- j++;
- }
- j = 0;
- i++;
- }
- return _return;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement