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