How to write a play. Volume 3
Part Two
(C) Konstantin Dronov
Item 4: Special Effects ... so here is difficult to say
anything specific, but try it. Let's talk about the two special
effects. Immediately make a reservation, usually in a raster
schedule all the visual effects be reduced to pre-proschitanoy
animation, but I'll talk about what is being done without the
animation and used in 3D games, but with interference
applicable here in 2D.
1. Lighting in real time.
We will not dwell on the static lighting, as it so clearly
defined in advance example provide coverage of DOOM'a, but
there is besides the static and dynamic similarity of the
shots. But here we consider only the simplest way to dynamic
lighting.
Lights in the game, usually presented in
the form of static images. But how
be with the light of the shots or the torch?
A very easy course to do even
less realistic picture without
ray tracing is not possible, something like the same
You can paint the picture. For example,
light propagates in all directions, but
in a circle. That is, you create a change in light raschityvaya
the following formulas:
X: = SIN a * R
Y: = COS a * R
where X, Y - coordinates, a - angle, R - radius
Changing R, we obtain the trajectory of change in the
intensity of light. You can pre- a table of values in memory
and work with it without wasting time on the calculation.
The circumference of the pixel to be selected manually at the
maximum radius. Radius also pick up on the basis of changes in
light intensity, which you ask. For example, the maximum
intensity of 64, mean radius of 64 is not particularly want
(although this is not correct for color illumination, which
necessary to consider not one but three composes colors).
1.pust a = 0 is the angle, l-intensivnost light,
m-circumference in pixels cintensivnost in the previous one
point, k = 1vybrany you rate, Xy / Yy-Center Light source
2.pust r = 0 is the radius, c = l
3.berem data X, Y (according to formulas or
table if the table is better if
table would look like:
angle a
radius r
X00, Y00, X01, Y01, X02, Y02, ... ..., X0r, Y0r
X10, Y10, X11, Y11, X12, Y12, ... ..., X1r, Y1r
.......................................
Xa0, Ya0, Xa1, Ya1, Xa2, Ya2, ... ..., Xar, Yar
...)
4.u = pixel color coordinate in the X + Xy, Y + Yy
5.c = c-k
6.u = c + u or try since u = (c + u) / 2,
that will give an interesting result, but then
Delete paragraph 5. This will emulate a shadow, the higher the
object, the less he color code, but make sure whatever color
composes gradually changed color from
to color (R1G1B1 = R0 +1, G0 +1, B0 +1)
7.u-> Record the coordinates of X + Xy, Y + Yy
8.r = r +1
9.esli r