[Java]PixeloMatic 05-26-2013, 07:45 PM
#1
Well I made something in Java but I don't know what this actually is ??. I was developing something and as a byproduct this came up. Don't know what to call but still I named this PixeloMatic since I am playing with pixels. If you come up with a better name do tell me.
Live Preview
http://javagamehc.comuv.com/#2
Code:
import java.awt.*;
import java.applet.*;
import java.awt.image.*;
public class PixeloMatic extends Applet implements Runnable {
int pixl2[] = new int[256];
Thread t = null;
final int width=500, height=500;
Image buffer = null;
int pixl1[],pixlook[];
@Override
public void init() {
setSize(500, 500);
int r, g, b, i;
pixl1 = new int[width * height];
pixlook = new int[width * height];
for (i = 0; i < 256; i++) {
r = (int) (128 + 128 * Math.sin(Math.PI * i / 32.0));
g = (int) (128 + 128 * Math.sin(Math.PI * i / 64.0));
b = (int) (128 + 128 * Math.sin(Math.PI * i / 128.0));
pixl2[i] = (255 << 24) | (r << 16) | (g << 8) | b;
}
for (r = 0; r < height; r++) {
for (g = 0; g < width; g++) {
i = (int) (128 + 128 * Math.sin(r / 16.0) + 128 + 128 * Math.sin(g / 16.0));
i = i / 2;
pixlook[g + r * height] = i;
}
}
}
@Override
public void start() {
t = new Thread(this);
t.start();
}
@Override
public void run() {
while(true) {
try {
repaint();
Thread.sleep(2);
} catch (InterruptedException e) {
}
}
}
@Override
public void stop() {
t = null;
}
@Override
public void paint(Graphics g) {
update(g);
}
@Override
public void update(Graphics g) {
int i, x, y, t;
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
t = x + y * height;
pixl1[t] = pixl2[pixlook[t]];
}
}
buffer = createImage(new MemoryImageSource(width, height, pixl1, 0, width));
g.drawImage(buffer, 0, 0, this);
int tmp;
tmp = pixl2[0];
for (i = 1; i < 256; i++) {
pixl2[i - 1] = pixl2[i];
}
pixl2[255] = tmp;
}
}Live Preview
http://javagamehc.comuv.com/#2
![[Image: OilyCostlyEwe.gif]](http://fat.gfycat.com/OilyCostlyEwe.gif)


![[+]](https://sinister.li/images/modern/collapse_collapsed.png)

Now you can get into water refraction and ripple effects for games. The theory is pretty cool behind all of that stuff. I was looking at formulas for heat haze a week ago.
miling:
![[Image: F-111.jpg]](http://devmaster.net/assets/post/3079/uploads/images/F-111.jpg)

![[Image: 2YpkRjy.png]](http://i.imgur.com/2YpkRjy.png)