Production explosion effect

zhaozj2021-02-08  241

Production explosion effect

The explosion effect is indispensable in various games. Methods that produce this effect is diverse,

This article introduces a simpler algorithm to throw bricks :) Here only gives the necessary code,

Please understand your own. If you have a better algorithm, please also give the Yunfeng :) ~

Note:

In order to improve the speed, the head demo screen is 40x40x32 frames. The following algorithm will generate an image of 80x80x64 frames.

First, you have to create a palette, we need to use 16 colors (you can below)

# 000000 # 100000 # 2C0000 # 480000 # 650000 # 810000 # a10000 # c20000 # e20000 # ff0000 # ff6500 # ff9500 # ffc600 # fff00 # fff7d # fffff

The following is not an available program, what you want to do is to read it :)

#define frame number 64

#define picture size 80

#define rendering number 32

/ * The more rendering times, the larger the block area in the explosive picture will be larger * /

Void Creates an explosion effect ()

{

UNSIGNED CHAR screen [picture size] [picture size];

/ * In this array eventually stores an integer of 0 to 15, corresponding to 16 colors in the above coloring plate

* /

Long Int C, C2, X, Y, XX, YY, Color;

Struct {

Long Int x, Y, XC, YC;

} HOT [rendering];

For (c = 0; c

Hot [c] .x = hot [c] .y = (Screen Size / 2) << 16;

Hot [c] .xc = -0x7FFF to 0x8000 random number;

The random number between Hot [c] .yc = -0x7ffff to 0x8000;

}

FOR (c = 0; c

Empty screen;

Color = ((c <16)? C * 4: (80-c)) >> 2;

For (C2 = 0; C2

For (x = -6; x <= 6; x ) {

FOR (Y = -6; y <= 6; y ) {

XX = (Hot [C2] .x >> 16) x;

YY = (Hot [c2] .y >> 16) Y;

IF ((xx> 0) && (YY> 0) && (xx

Screen [YY] [XX] = (Color >> ((ABS (x) ABS (Y)) / 3));

IF (picture [yy] [xx]> 63)

Screen [yy] [xx] = 63;

}

}

}

Hot [c2] .x = hot [c2] .xc;

Hot [c2] .y = HOT [C2] .yc;

}

FOR (x = 0; x

FOR (Y = 0; Y

C2 = screen [y] [x];

IF (C2 <8)

Screen [Y] = 0;

Else

Screen [Y] = C2 / 4;

}

}

}

Storage screen to the explosion animation first CF frame;

}

A little suggestion:

You can use this algorithm to generate an explosive animation. Cyclic playback when needed.

Yunfeng studio production

转载请注明原文地址:https://www.9cbs.com/read-1308.html

New Post(0)