View difference between Paste ID: KMVac7mg and dEZukDnG
SHOW: | | - or go back to the newest paste.
1
package net.mousemaze;
2
3
import java.awt.Graphics;
4
import java.awt.Image;
5
import java.awt.image.BufferedImage;
6
import javax.swing.ImageIcon;
7
8
public class Textures {
9
	private int time = 0;
10
	public Image[] font7x7WhiteOnBlack;
11
	public Image[] font7x7BlackOnWhite;
12
	public Image[] platformWhite;
13
	public Image ButtonPlayNormal, ButtonPlayHover, ButtonPlayDown;
14
	public Image ButtonQuitNormal, ButtonQuitHover, ButtonQuitDown;
15
	private final boolean I = true, O = false;
16
17
	private final boolean[][] platformLetterAmap = {
18
			new boolean[] { O, O, I, I, I, O, O },
19
			new boolean[] { O, I, O, O, O, I, O },
20
			new boolean[] { O, I, O, O, O, I, O },
21
			new boolean[] { O, I, I, I, I, I, O },
22
			new boolean[] { O, I, O, O, O, I, O },
23
			new boolean[] { O, I, O, O, O, I, O },
24
			new boolean[] { O, I, O, O, O, I, O } };
25
	private final boolean[][] platformLetterBmap = {
26
			new boolean[] { O, I, I, I, I, O, O },
27
			new boolean[] { O, I, O, O, O, I, O },
28
			new boolean[] { O, I, O, O, O, I, O },
29
			new boolean[] { O, I, I, I, I, O, O },
30
			new boolean[] { O, I, O, O, O, I, O },
31
			new boolean[] { O, I, O, O, O, I, O },
32
			new boolean[] { O, I, I, I, I, O, O } };
33
	private final boolean[][] platformLetterCmap = {
34
			new boolean[] { O, O, I, I, I, O, O },
35
			new boolean[] { O, I, O, O, O, I, O },
36
			new boolean[] { O, I, O, O, O, O, O },
37
			new boolean[] { O, I, O, O, O, O, O },
38
			new boolean[] { O, I, O, O, O, O, O },
39
			new boolean[] { O, I, O, O, O, I, O },
40
			new boolean[] { O, O, I, I, I, O, O } };
41
	private final boolean[][] platformLetterDmap = {
42
			new boolean[] { O, I, I, I, I, O, O },
43
			new boolean[] { O, I, O, O, O, I, O },
44
			new boolean[] { O, I, O, O, O, I, O },
45
			new boolean[] { O, I, O, O, O, I, O },
46
			new boolean[] { O, I, O, O, O, I, O },
47
			new boolean[] { O, I, O, O, O, I, O },
48
			new boolean[] { O, I, I, I, I, O, O } };
49
	private final boolean[][] platformLetterEmap = {
50
			new boolean[] { O, I, I, I, I, I, O },
51
			new boolean[] { O, I, O, O, O, O, O },
52
			new boolean[] { O, I, O, O, O, O, O },
53
			new boolean[] { O, I, I, I, I, O, O },
54
			new boolean[] { O, I, O, O, O, O, O },
55
			new boolean[] { O, I, O, O, O, O, O },
56
			new boolean[] { O, I, I, I, I, I, O } };
57
	private final boolean[][] platformLetterFmap = {
58
			new boolean[] { O, I, I, I, I, I, O },
59
			new boolean[] { O, I, O, O, O, O, O },
60
			new boolean[] { O, I, O, O, O, O, O },
61
			new boolean[] { O, I, I, I, I, O, O },
62
			new boolean[] { O, I, O, O, O, O, O },
63
			new boolean[] { O, I, O, O, O, O, O },
64
			new boolean[] { O, I, O, O, O, O, O } };
65
	private final boolean[][] platformLetterGmap = {
66
			new boolean[] { O, O, I, I, I, O, O },
67
			new boolean[] { O, I, O, O, O, I, O },
68
			new boolean[] { O, I, O, O, O, O, O },
69
			new boolean[] { O, I, O, O, O, O, O },
70
			new boolean[] { O, I, O, I, I, I, O },
71
			new boolean[] { O, I, O, O, O, I, O },
72
			new boolean[] { O, O, I, I, I, I, O } };
73
	private final boolean[][] platformLetterHmap = {
74
			new boolean[] { O, I, O, O, O, I, O },
75
			new boolean[] { O, I, O, O, O, I, O },
76
			new boolean[] { O, I, O, O, O, I, O },
77
			new boolean[] { O, I, I, I, I, I, O },
78
			new boolean[] { O, I, O, O, O, I, O },
79
			new boolean[] { O, I, O, O, O, I, O },
80
			new boolean[] { O, I, O, O, O, I, O } };
81
	private final boolean[][] platformLetterImap = {
82
			new boolean[] { O, I, I, I, I, I, O },
83
			new boolean[] { O, O, O, I, O, O, O },
84
			new boolean[] { O, O, O, I, O, O, O },
85
			new boolean[] { O, O, O, I, O, O, O },
86
			new boolean[] { O, O, O, I, O, O, O },
87
			new boolean[] { O, O, O, I, O, O, O },
88
			new boolean[] { O, I, I, I, I, I, O } };
89
	private final boolean[][] platformLetterJmap = {
90
			new boolean[] { O, I, I, I, I, I, O },
91
			new boolean[] { O, O, O, O, I, O, O },
92
			new boolean[] { O, O, O, O, I, O, O },
93
			new boolean[] { O, O, O, O, I, O, O },
94
			new boolean[] { O, I, O, O, I, O, O },
95
			new boolean[] { O, I, O, O, I, O, O },
96
			new boolean[] { O, O, I, I, O, O, O } };
97
	private final boolean[][] platformLetterKmap = {
98
			new boolean[] { O, I, O, O, O, I, O },
99
			new boolean[] { O, I, O, O, I, O, O },
100
			new boolean[] { O, I, O, I, O, O, O },
101
			new boolean[] { O, I, I, O, I, O, O },
102
			new boolean[] { O, I, O, O, I, O, O },
103
			new boolean[] { O, I, O, O, O, I, O },
104
			new boolean[] { O, I, O, O, O, I, O } };
105
	private final boolean[][] platformLetterLmap = {
106
			new boolean[] { O, I, O, O, O, O, O },
107
			new boolean[] { O, I, O, O, O, O, O },
108
			new boolean[] { O, I, O, O, O, O, O },
109
			new boolean[] { O, I, O, O, O, O, O },
110
			new boolean[] { O, I, O, O, O, O, O },
111
			new boolean[] { O, I, O, O, O, O, O },
112
			new boolean[] { O, I, I, I, I, I, O } };
113
	private final boolean[][] platformLetterMmap = {
114
			new boolean[] { O, I, O, O, O, I, O },
115
			new boolean[] { O, I, I, O, I, I, O },
116
			new boolean[] { O, I, O, I, O, I, O },
117
			new boolean[] { O, I, O, O, O, I, O },
118
			new boolean[] { O, I, O, O, O, I, O },
119
			new boolean[] { O, I, O, O, O, I, O },
120
			new boolean[] { O, I, O, O, O, I, O } };
121
	private final boolean[][] platformLetterNmap = {
122
			new boolean[] { O, I, O, O, O, I, O },
123
			new boolean[] { O, I, O, O, O, I, O },
124
			new boolean[] { O, I, I, O, O, I, O },
125
			new boolean[] { O, I, O, I, O, I, O },
126
			new boolean[] { O, I, O, O, I, I, O },
127
			new boolean[] { O, I, O, O, O, I, O },
128
			new boolean[] { O, I, O, O, O, I, O } };
129
	private final boolean[][] platformLetterOmap = {
130
			new boolean[] { O, O, I, I, I, O, O },
131
			new boolean[] { O, I, O, O, O, I, O },
132
			new boolean[] { O, I, O, O, O, I, O },
133
			new boolean[] { O, I, O, O, O, I, O },
134
			new boolean[] { O, I, O, O, O, I, O },
135
			new boolean[] { O, I, O, O, O, I, O },
136
			new boolean[] { O, O, I, I, I, O, O } };
137
	private final boolean[][] platformLetterPmap = {
138
			new boolean[] { O, I, I, I, I, O, O },
139
			new boolean[] { O, I, O, O, O, I, O },
140
			new boolean[] { O, I, O, O, O, I, O },
141
			new boolean[] { O, I, I, I, I, O, O },
142
			new boolean[] { O, I, O, O, O, O, O },
143
			new boolean[] { O, I, O, O, O, O, O },
144
			new boolean[] { O, I, O, O, O, O, O } };
145
	private final boolean[][] platformLetterQmap = {
146
			new boolean[] { O, O, I, I, I, O, O },
147
			new boolean[] { O, I, O, O, O, I, O },
148
			new boolean[] { O, I, O, O, O, I, O },
149
			new boolean[] { O, I, O, O, O, I, O },
150
			new boolean[] { O, I, O, I, O, I, O },
151
			new boolean[] { O, I, O, O, I, O, O },
152
			new boolean[] { O, O, I, I, O, I, O } };
153
	private final boolean[][] platformLetterRmap = {
154
			new boolean[] { O, I, I, I, I, O, O },
155
			new boolean[] { O, I, O, O, O, I, O },
156
			new boolean[] { O, I, O, O, O, I, O },
157
			new boolean[] { O, I, I, I, I, O, O },
158
			new boolean[] { O, I, O, O, O, I, O },
159
			new boolean[] { O, I, O, O, O, I, O },
160
			new boolean[] { O, I, O, O, O, I, O } };
161
	private final boolean[][] platformLetterSmap = {
162
			new boolean[] { O, O, I, I, I, O, O },
163
			new boolean[] { O, I, O, O, O, I, O },
164
			new boolean[] { O, I, O, O, O, O, O },
165
			new boolean[] { O, O, I, I, I, O, O },
166
			new boolean[] { O, O, O, O, O, I, O },
167
			new boolean[] { O, I, O, O, O, I, O },
168
			new boolean[] { O, O, I, I, I, O, O } };
169
	private final boolean[][] platformLetterTmap = {
170
			new boolean[] { O, I, I, I, I, I, O },
171
			new boolean[] { O, O, O, I, O, O, O },
172
			new boolean[] { O, O, O, I, O, O, O },
173
			new boolean[] { O, O, O, I, O, O, O },
174
			new boolean[] { O, O, O, I, O, O, O },
175
			new boolean[] { O, O, O, I, O, O, O },
176
			new boolean[] { O, O, O, I, O, O, O } };
177
	private final boolean[][] platformLetterUmap = {
178
			new boolean[] { O, I, O, O, O, I, O },
179
			new boolean[] { O, I, O, O, O, I, O },
180
			new boolean[] { O, I, O, O, O, I, O },
181
			new boolean[] { O, I, O, O, O, I, O },
182
			new boolean[] { O, I, O, O, O, I, O },
183
			new boolean[] { O, I, O, O, O, I, O },
184
			new boolean[] { O, O, I, I, I, I, O } };
185
	private final boolean[][] platformLetterVmap = {
186
			new boolean[] { O, I, O, O, O, I, O },
187
			new boolean[] { O, I, O, O, O, I, O },
188
			new boolean[] { O, I, O, O, O, I, O },
189
			new boolean[] { O, O, I, O, I, O, O },
190
			new boolean[] { O, O, I, O, I, O, O },
191
			new boolean[] { O, O, I, O, I, O, O },
192
			new boolean[] { O, O, O, I, O, O, O } };
193
	private final boolean[][] platformLetterWmap = {
194
			new boolean[] { O, I, O, O, O, I, O },
195
			new boolean[] { O, I, O, O, O, I, O },
196
			new boolean[] { O, I, O, O, O, I, O },
197
			new boolean[] { O, I, O, O, O, I, O },
198
			new boolean[] { O, I, O, I, O, I, O },
199
			new boolean[] { O, I, I, O, I, I, O },
200
			new boolean[] { O, I, O, O, O, I, O } };
201
	private final boolean[][] platformLetterXmap = {
202
			new boolean[] { O, I, O, O, O, I, O },
203
			new boolean[] { O, I, O, O, O, I, O },
204
			new boolean[] { O, O, I, O, I, O, O },
205
			new boolean[] { O, O, O, I, O, O, O },
206
			new boolean[] { O, O, I, O, I, O, O },
207
			new boolean[] { O, I, O, O, O, I, O },
208
			new boolean[] { O, I, O, O, O, I, O } };
209
	private final boolean[][] platformLetterYmap = {
210
			new boolean[] { O, I, O, O, O, I, O },
211
			new boolean[] { O, I, O, O, O, I, O },
212
			new boolean[] { O, O, I, O, I, O, O },
213
			new boolean[] { O, O, O, I, O, O, O },
214
			new boolean[] { O, O, O, I, O, O, O },
215
			new boolean[] { O, O, O, I, O, O, O },
216
			new boolean[] { O, O, O, I, O, O, O } };
217
	private final boolean[][] platformLetterZmap = {
218
			new boolean[] { O, I, I, I, I, I, O },
219
			new boolean[] { O, O, O, O, O, I, O },
220
			new boolean[] { O, O, O, O, I, O, O },
221
			new boolean[] { O, O, O, I, O, O, O },
222
			new boolean[] { O, O, I, O, O, O, O },
223
			new boolean[] { O, I, O, O, O, O, O },
224
			new boolean[] { O, I, I, I, I, I, O } };
225
	public final Image[] whitePlatfomFont = new Image[26];
226
227
	public Textures() {
228
		BufferedImage fontSheet = createBufferedImage("Resource\\Font\\FontA.png");
229-
		BufferedImage fontSheetb = createBufferedImage("/run/media/marcus/Toshiba Ext HDD/MAndWorks/Commons/Font/FontB.png");
229+
		BufferedImage fontSheetb = createBufferedImage("Resource\\Font\\FontB.png");
230-
		BufferedImage platformWhiteSheet = createBufferedImage("/run/media/marcus/Toshiba Ext HDD/MAndWorks/Commons/Font/FontA.png");
230+
		BufferedImage platformWhiteSheet = createBufferedImage("Resource\\TileSets\\TileBlueCoreV2.png");
231
		font7x7BlackOnWhite = parse(fontSheet, 7, 7, 7, 7);
232
		font7x7WhiteOnBlack = parse(fontSheetb, 7, 7, 7, 7);
233
		platformWhite = parse(platformWhiteSheet, 16, 16, 4, 4);
234
		whitePlatfomFont[0] = getPlatformMatrixFor(platformLetterAmap, platformWhite);
235
		whitePlatfomFont[1] = getPlatformMatrixFor(platformLetterBmap, platformWhite);
236
		whitePlatfomFont[2] = getPlatformMatrixFor(platformLetterCmap, platformWhite);
237
		whitePlatfomFont[3] = getPlatformMatrixFor(platformLetterDmap, platformWhite);
238
		whitePlatfomFont[4] = getPlatformMatrixFor(platformLetterEmap, platformWhite);
239
		whitePlatfomFont[5] = getPlatformMatrixFor(platformLetterFmap, platformWhite);
240
		whitePlatfomFont[6] = getPlatformMatrixFor(platformLetterGmap, platformWhite);
241
		whitePlatfomFont[7] = getPlatformMatrixFor(platformLetterHmap, platformWhite);
242
		whitePlatfomFont[8] = getPlatformMatrixFor(platformLetterImap, platformWhite);
243
		whitePlatfomFont[9] = getPlatformMatrixFor(platformLetterJmap, platformWhite);
244
		whitePlatfomFont[10] = getPlatformMatrixFor(platformLetterKmap, platformWhite);
245
		whitePlatfomFont[11] = getPlatformMatrixFor(platformLetterLmap, platformWhite);
246
		whitePlatfomFont[12] = getPlatformMatrixFor(platformLetterMmap, platformWhite);
247
		whitePlatfomFont[13] = getPlatformMatrixFor(platformLetterNmap, platformWhite);
248
		whitePlatfomFont[14] = getPlatformMatrixFor(platformLetterOmap, platformWhite);
249
		whitePlatfomFont[15] = getPlatformMatrixFor(platformLetterPmap, platformWhite);
250
		whitePlatfomFont[16] = getPlatformMatrixFor(platformLetterQmap, platformWhite);
251
		whitePlatfomFont[17] = getPlatformMatrixFor(platformLetterRmap, platformWhite);
252
		whitePlatfomFont[18] = getPlatformMatrixFor(platformLetterSmap, platformWhite);
253
		whitePlatfomFont[19] = getPlatformMatrixFor(platformLetterTmap, platformWhite);
254
		whitePlatfomFont[20] = getPlatformMatrixFor(platformLetterUmap, platformWhite);
255
		whitePlatfomFont[21] = getPlatformMatrixFor(platformLetterVmap, platformWhite);
256
		whitePlatfomFont[22] = getPlatformMatrixFor(platformLetterWmap, platformWhite);
257
		whitePlatfomFont[23] = getPlatformMatrixFor(platformLetterXmap, platformWhite);
258
		whitePlatfomFont[24] = getPlatformMatrixFor(platformLetterYmap, platformWhite);
259
		whitePlatfomFont[25] = getPlatformMatrixFor(platformLetterZmap, platformWhite);
260-
		ButtonPlayNormal = parse(createBufferedImage("/run/media/marcus/Toshiba Ext HDD/MAndWorks/Commons/Buttons/Play.png"), 200, 50, 1, 3)[0];
260+
261-
		ButtonPlayHover = parse(createBufferedImage("/run/media/marcus/Toshiba Ext HDD/MAndWorks/Commons/Buttons/Play.png"), 200, 50, 1, 3)[1];
261+
		ButtonPlayNormal = parse(createBufferedImage("Resource\\Button\\Play.png"), 200, 50, 1, 3)[0];
262-
		ButtonPlayDown = parse(createBufferedImage("/run/media/marcus/Toshiba Ext HDD/MAndWorks/Commons/Buttons/Play.png"), 200, 50, 1, 3)[2];
262+
		ButtonPlayHover = parse(createBufferedImage("Resource\\Button\\Play.png"), 200, 50, 1, 3)[1];
263-
		ButtonQuitNormal = parse(createBufferedImage("/run/media/marcus/Toshiba Ext HDD/MAndWorks/Commons/Buttons/Quit.png"), 200, 50, 1, 3)[0];
263+
		ButtonPlayDown = parse(createBufferedImage("Resource\\Button\\Play.png"), 200, 50, 1, 3)[2];
264-
		ButtonQuitHover = parse(createBufferedImage("/run/media/marcus/Toshiba Ext HDD/MAndWorks/Commons/Buttons/Quit.png"), 200, 50, 1, 3)[1];
264+
		ButtonQuitNormal = parse(createBufferedImage("Resource\\Button\\Quit.png"), 200, 50, 1, 3)[0];
265-
		ButtonQuitDown = parse(createBufferedImage("/run/media/marcus/Toshiba Ext HDD/MAndWorks/Commons/Buttons/Quit.png"), 200, 50, 1, 3)[2];
265+
		ButtonQuitHover = parse(createBufferedImage("Resource\\Button\\Quit.png"), 200, 50, 1, 3)[1];
266
		ButtonQuitDown = parse(createBufferedImage("Resource\\Button\\Quit.png"), 200, 50, 1, 3)[2];
267
	}
268
269
	public Image parseString(Image[] font, String s) {
270
		Image _return = createBufferedImage(font[0].getWidth(null) * s.length(), font[0].getHeight(null));
271
		int i = 0;
272
		Graphics g = _return.getGraphics();
273
		while (i < s.length()) {
274
			if ((int) s.charAt(i) - 97 == -65) {
275
				i++;
276
			} else {
277
				g.drawImage(font[(int) s.charAt(i) - 97],
278
					font[0].getWidth(null) * i, 0, null);
279
				i++;
280
			}
281
		}
282
		return _return;
283
	}
284
285
	public Image getPlatformMatrixFor(boolean[][] b, Image[] blocks) {
286
		Image _return = createBufferedImage(112, 112);
287
		Graphics g = _return.getGraphics();
288
		int y = 0, x = 0;
289
		while (y < b.length) {
290
			while (x < b[0].length) {
291
				boolean top = false, right = false, bottom = false, left = false;
292
				try {
293
					if (b[x][y - 1]) {
294
						top = true;
295
					}
296
				} catch (Exception e) {
297
				}
298
				try {
299
					if (b[x + 1][y]) {
300
						right = true;
301
					}
302
				} catch (Exception e) {
303
				}
304
				try {
305
					if (b[x][y + 1]) {
306
						bottom = true;
307
					}
308
				} catch (Exception e) {
309
				}
310
				try {
311
					if (b[x - 1][y]) {
312
						left = true;
313
					}
314
				} catch (Exception e) {
315
				}
316
				if (b[x][y]) {
317
					if (top) {
318
						if (bottom) {
319
							if (right) {
320
								if (left) {
321
									g.drawImage(blocks[0], y * 16, x * 16, null);
322
								} else {
323
									g.drawImage(blocks[9], y * 16, x * 16, null);
324
								}
325
							} else {
326
								if (left) {
327
									g.drawImage(blocks[11], y * 16, x * 16,
328
											null);
329
								} else {
330
									g.drawImage(blocks[6], y * 16, x * 16, null);
331
								}
332
							}
333
						} else {
334
							if (right) {
335
								if (left) {
336
									g.drawImage(blocks[10], y * 16, x * 16,
337
											null);
338
								} else {
339
									g.drawImage(blocks[15], y * 16, x * 16,
340
											null);
341
								}
342
							} else {
343
								if (left) {
344
									g.drawImage(blocks[14], y * 16, x * 16,
345
											null);
346
								} else {
347
									g.drawImage(blocks[3], y * 16, x * 16, null);
348
								}
349
							}
350
						}
351
					} else {
352
						if (bottom) {
353
							if (right) {
354
								if (left) {
355
									g.drawImage(blocks[8], y * 16, x * 16, null);
356
								} else {
357
									g.drawImage(blocks[12], y * 16, x * 16,
358
											null);
359
								}
360
							} else {
361
								if (left) {
362
									g.drawImage(blocks[13], y * 16, x * 16,
363
											null);
364
								} else {
365
									g.drawImage(blocks[1], y * 16, x * 16, null);
366
								}
367
							}
368
						} else {
369
							if (right) {
370
								if (left) {
371
									g.drawImage(blocks[5], y * 16, x * 16, null);
372
								} else {
373
									g.drawImage(blocks[2], y * 16, x * 16, null);
374
								}
375
							} else {
376
								if (left) {
377
									g.drawImage(blocks[4], y * 16, x * 16, null);
378
								} else {
379
									g.drawImage(blocks[0], y * 16, x * 16, null);
380
								}
381
							}
382
						}
383
					}
384
				}
385
				x++;
386
			}
387
			x = 0;
388
			y++;
389
		}
390
		return _return;
391
	}
392
393
	private BufferedImage createBufferedImage(String directory) {
394
		Image img = new ImageIcon(directory).getImage();
395
		BufferedImage bimg = new BufferedImage(img.getWidth(null),
396
				img.getHeight(null), BufferedImage.TRANSLUCENT);
397
		Graphics g = bimg.getGraphics();
398
		g.drawImage(img, 0, 0, null);
399
		return bimg;
400
	}
401
402
	private BufferedImage createBufferedImage(int width, int height) {
403
		return new BufferedImage(width, height, BufferedImage.TRANSLUCENT);
404
	}
405
406
	private BufferedImage[] parse(BufferedImage imgIn, int width, int height,
407
			int imgWidth, int imgHeight) {
408
		BufferedImage[] _return = new BufferedImage[imgWidth * imgHeight];
409
		int i = 0, j = 0;
410
		while (i < imgHeight) {
411
			while (j < imgWidth) {
412
				BufferedImage temp = new BufferedImage(width, height,
413
						BufferedImage.TRANSLUCENT);
414
				Graphics g = temp.getGraphics();
415
				g.drawImage(imgIn, 0, 0, width, height, j * width, i * height,
416
						(j * width) + width, (i * height) + height, null);
417
				_return[(i * imgWidth) + j] = temp;
418
				j++;
419
			}
420
			j = 0;
421
			i++;
422
		}
423
		return _return;
424
	}
425
}