Bad graphics programming graphics?

I'm currently working on a tile-based game in Java2D, and I was thinking of adding some cheap candy.

For example, the introduction of a simple particle system (perhaps something like this ) for explosions and / or smoke.

Do you have any suggestions regarding relatively simple software effects that do not require much to draw (or even) new art?

Tutorials and code examples for the mentioned effects will also be most welcome!

-Ido.

PS - if absolutely necessary, I could switch to something like LWJGL / JOGL or even Slick - but I would rather stay with Java2D.

+3
source share
5

.

, BufferedImage, ConvolveOp , Kernel:

BufferedImageOp op = new ConvolveOp(new Kernel(3, 3,
    new float[] { 
        1/9f, 1/9f, 1/9f,
        1/9f, 1/9f, 1/9f,
        1/9f, 1/9f, 1/9f
    }
));

BufferedImage resultImg = op.filter(originalImg, resultImage);

, , . , .

. , , , .

+6

- BufferedImage.

:

  • .
  • .

1: :

public static Color determineColor(BufferedImage img, int x, int y, int w, int h) {
    int cx = x + (int)(w / 2);
    int cy = y + (int)(h / 2);
    return new Color(img.getRGB(cx, cy), true);
}

determineColor BufferedImage .

2: :

BufferedImage sourceImg = ...;  // Source Image.
BufferedImage destimg = ...;    // Destination Image.
Graphics g = destImg.createGraphics();

int blockSize = 8;
for (int i = 0; i < sourceImg.getWidth(); i += blockSize) {
    for (int j = 0; j < sourceImg.getHeight(); j += blockSize) {
        Color c = determineColor(sourceImg, i, j, blockSize, blockSize);
        g.setColor(c);
        g.fillRect(i, j, blockSize, blockSize);
    }
}
g.dispose();

, , - , . . , .

:

http://coobird.net/img/grad64.png http://coobird.net/img/grad64p.png

+5

Filthy Rich Java2D/Swing. . , , .

, - -. - Timing Framework. , - .

+1

(, ) . , Java2d.

0

Everything that looks realistic, things bouncing off other things, slipping, etc., can be cool, and if your game is a 2D scroll, and not top-down 2D, you can use a ready-made physics engine like Box2D. to do something cool with minimal effort. Here's the Java Box2D port that you could use for it.

0
source

Source: https://habr.com/ru/post/1710165/


All Articles