![]() |
|
[Java]PixeloMatic - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Coding (https://sinister.li/Forum-Coding) +--- Forum: Java, JVM, & JRE (https://sinister.li/Forum-Java-JVM-JRE) +--- Thread: [Java]PixeloMatic (/Thread-Java-PixeloMatic) |
[Java]PixeloMatic - Psycho_Coder - 05-26-2013 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. 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 RE: [Java]PixeloMatic - TheDeceptionist - 05-27-2013 Thats a nice effect. I'm not understanding the code. I will soon understand java. Thank you. RE: [Java]PixeloMatic - ArkPhaze - 06-02-2013 Pretty cool 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.
RE: [Java]PixeloMatic - Psycho_Coder - 06-03-2013 (06-02-2013, 10:01 PM)ArkPhaze Wrote: Pretty cool Sir may I ask what is HeatHaze ? Is it your new project. Just asked out of curiosity. miling:
RE: [Java]PixeloMatic - ArkPhaze - 06-03-2013 (06-03-2013, 03:31 AM)Psycho_Coder Wrote:(06-02-2013, 10:01 PM)ArkPhaze Wrote: Pretty cool Take a look: http://devmaster.net/posts/3079/shader-effects-refraction This is heat haze: ![]()
RE: [Java]PixeloMatic - Psycho_Coder - 06-03-2013 (06-03-2013, 04:02 AM)ArkPhaze Wrote:(06-03-2013, 03:31 AM)Psycho_Coder Wrote:(06-02-2013, 10:01 PM)ArkPhaze Wrote: Pretty cool OOP's since it had "haze" so I thought it was some project of yours :lol: But these effects are awesome. Refraction is such an awesome thing. If I go through the algorithms of these effects then I can create some effects that we have in PS.
RE: [Java]PixeloMatic - ArkPhaze - 06-03-2013 Most of the time you see refraction with water. It's mainly caused by a difference in medium densities though. And in combination with light, it creates some optical effects. That's one of the reasons why I like game programming; applying real world concepts to the virtual world. RE: [Java]PixeloMatic - Deque - 06-03-2013 That looks pretty cool. I would probably call it LSD trip. ![]() But codingwise you did the some mistakes again that I already criticised in your last code: No access modifiers, magic numbers everywhere. Good: You took care to use @Override. RE: [Java]PixeloMatic - Buster - 08-01-2013 I really like your code, would you mind if I use your source code? RE: [Java]PixeloMatic - Psycho_Coder - 08-01-2013 (08-01-2013, 01:52 AM)Buster Wrote: I really like your code, would you mind if I use your source code? Yes you can use it. |