Implement the vibration effect after the explosion

zhaozj2021-02-08  234

Implement the vibration effect after the explosion (Changchun Shilin)

In many game software, we can often see such a scene: When a facility explodes, the screen picture will be accompanied by a slight vibration, which makes people feel immersive. The author wrote a function void moveview (int x, int y); shift the upper left corner coordinate of the screen by the CRT controller to move the screen to move the screen to generate a vibration effect. The program is written by Borland C 2.0, using VGA 12H mode, small code, fast speed, and dynamic image. // filename: Shake.cpp // Maker: Shilin #include #include #include #include voidView (int X, int y); void main (void) {int GDRIVER, GMODE; gDriver = detect, gmode = 0; Initgraph (& Gdriver, & gmode, "borlandcbgi"); Rectangle (100, 100, 200, 200); Outtextxy (100, 250, "Press any key to shake ..."); getCh (); for (int i = 0; i <20; i ) {MoveView (10-random (20), 5-random (10)); DELAY (50);} moveview (0,0); getCh (); closegraph ();} voidmEView (int x, int y) {union { Unsigned int whole; car low;} adj; unsigned char high, low; adr.Whole = y * 80 x / 8, low = adr.low, high = (unsigned char) (ADR.WHOLE >> 8); OUTPORTB (0x3d4 , 0x0c); OUTPORTB (0x3d5, high); OUTPORTB (0x3D4, 0x0D); OUTPORTB (0x3d5, low);}

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

New Post(0)