📄 vcc49.htm
字号:
<html>
<head>
<title>c++系列</title>
<meta content="text/html; charset=gb2312" http-equiv=Content-Type>
</head>
<p align="center"><script src="../../1.js"></script></a>
<body bgcolor="#ffffff" leftmargin="5" topmargin="1" marginheight="5" marginwidth="5">
<div align=center>
<table border=0 cellpadding=0 cellspacing=0 width=680 align="center">
<tbody>
<tr>
<td width=200 height="59">
</tr>
</tbody>
</table>
<table border=1 bordercolordark=#ffffff bordercolorlight=#ffffff cellpadding=0
cellspacing=0 width=685 align="center" height="70">
<tbody>
<tr>
<td bgcolor=#F9D23C height=14>
<div align=center class=H1> <b><span class="unnamed1">实现爆炸后的振动效果</span></b></font></div>
</td>
</tr>
<tr valign=top>
<td class=H1 height=212>
<p align="right"><font color="#FF0000"> <br>
(长春 石琳) </font></span></font></p>
<p> 在许多游戏软件中,我们经常能看到这样的场面:当某一设施爆炸后,屏幕画面会伴随着轻微的振动,使人感到身临其境。笔者编写了一个函数void
MoveView(int x,int y);通过CRT控制器将屏幕视角左上角坐标移至 (x,y)处,使画面相对移动,从而产生振动效果。程序由Borland
C++ 2.0编写,采用VGA 12H模式,代码小、速度快、运行效果形象逼真。<br>
// filename: SHAKE.cpp<br>
// maker: ShiLin<br>
#include<br>
#include<br>
#include<br>
#include<br>
void MoveView(int x,int y);<br>
void main(void){<br>
int gdriver,gmode;<br>
gdriver=DETECT,gmode=0;<br>
initgraph(&gdriver,&gmode,"BORLANDCBGI");<br>
rectangle(100,100,200,200);<br>
outtextxy(100,250,"Press Any Key to SHAKE ...");<br>
getch();<br>
for(int i=0;i<20;i++){<br>
MoveView(10-random(20),5-random(10));<br>
delay(50);<br>
}<br>
MoveView(0,0);<br>
getch();<br>
closegraph();<br>
}<br>
void MoveView(int x,int y){<br>
union{<br>
unsigned int whole;<br>
char low;<br>
}adr;<br>
unsigned char high,low;<br>
adr.whole=y*80+x/8,<br>
low=adr.low,<br>
high=(unsigned char)(adr.whole>>8);<br>
outportb(0x3D4,0X0C);<br>
outportb(0x3D5,high);<br>
outportb(0x3D4,0x0D);<br>
outportb(0x3D5,low);<br>
} <br>
转载自中国程序员网站 </span></font>
</td>
</tr>
</tbody>
</table>
</div>
<p align="center"><script src="../../2.js"></script></a>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -