-
大小: 9KB文件類型: .cpp金幣: 1下載: 0 次發(fā)布日期: 2023-12-24
- 語(yǔ)言: C/C++
- 標(biāo)簽:
資源簡(jiǎn)介
動(dòng)態(tài)效果,黑客帝國(guó)
#include
#define ID_TIMER 1
#define STRMAXLEN 25 //一個(gè)顯示列的最大長(zhǎng)度
#define STRMINLEN 8 //一個(gè)顯示列的最小長(zhǎng)度
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
typedef struct tagCharChain //整個(gè)當(dāng)作屏幕的一個(gè)顯示列,這是個(gè)雙向列表
{
struct tagCharChain *prev; //鏈表的前個(gè)元素
TCHAR ch; //一個(gè)顯示列中的一個(gè)字符
struct tagCharChain *next; //鏈表的后個(gè)元素
} CharChain, *pCharChain;
typedef struct tagCharColumn
{
CharChain *head, *current, *point;
int x, y, iStrLen; //顯示列的開始顯示的x,y坐標(biāo),iStrLen是這個(gè)列的長(zhǎng)度
int iStopTimes, iMustStopTimes; //已經(jīng)停滯的次數(shù)和必須停滯的次數(shù),必須停滯的次數(shù)是隨機(jī)的
} CharColumn, *pCharColumn;
/***********************/
.....................
...................
代碼片段和文件信息
#include?
#define?ID_TIMER????1
#define?STRMAXLEN??25?//一個(gè)顯示列的最大長(zhǎng)度
#define?STRMINLEN??8??//一個(gè)顯示列的最小長(zhǎng)度
LRESULT?CALLBACK?WndProc?(HWND?UINT?WPARAM?LPARAM)?;
typedef?struct?tagCharChain?//整個(gè)當(dāng)作屏幕的一個(gè)顯示列這是個(gè)雙向列表
{
????????struct?tagCharChain?*prev;?//鏈表的前個(gè)元素
????????TCHAR??ch;??????????????????//一個(gè)顯示列中的一個(gè)字符
????????struct?tagCharChain?*next;?//鏈表的后個(gè)元素
}?CharChain?*pCharChain;
typedef?struct?tagCharColumn
{
????????CharChain?*head?*current?*point;
????????int?x?y?iStrLen;?//顯示列的開始顯示的xy坐標(biāo)iStrLen是這個(gè)列的長(zhǎng)度
????????int?iStopTimes?iMustStopTimes;?//已經(jīng)停滯的次數(shù)和必須停滯的次數(shù)必須停滯的次數(shù)是隨機(jī)的
}?CharColumn?*pCharColumn;
int?main(HINSTANCE?hInstance?HINSTANCE?hPrevInstance
?????????PSTR?szCmdLine?int?iCmdShow)
{
????????static?TCHAR?szAppName[]?=?TEXT?(“matrix“)?;
????????HWND????????????hwnd?;
????????MSG????????????msg?;
????????WNDCLASS????wndclass?;
????????wndclass.style????????????????=?CS_HREDRAW?|?CS_VREDRAW?;
????????wndclass.lpfnWndProc????????=?WndProc?;
????????wndclass.cbClsExtra????????=?0?;
????????wndclass.cbWndExtra????????=?0?;
????????wndclass.hInstance????????=?hInstance?;
????????wndclass.hIcon????????????????=?LoadIcon?(NULL?IDI_APPLICATION)?;
????????wndclass.hCursor????????=?LoadCursor?(NULL?IDC_ARROW)?;
????????wndclass.hbrBackground????????=?(HBRUSH)?GetStockobject?(BLACK_BRUSH)?;
????????wndclass.lpszMenuName????????=?NULL?;
????????wndclass.lpszClassName????????=?szAppName?;
????????if?(!RegisterClass?(&wndclass))
????????{
????????????????MessageBox?(NULL?TEXT?(“此程序必須運(yùn)行在NT下!“)?szAppName?MB_IConerror)?;
????????????????return?0;
????????}
????????hwnd?=?CreateWindow?(szAppName?NULL
?????????????????????????????WS_DLGframe?|?WS_THICKframe?|?WS_POPUP
?????????????????????????????0?0
?????????????????????????????GetSystemMetrics(SM_CXSCREEN)?GetSystemMetrics(SM_CYSCREEN)
?????????????????????????????NULL?NULL?hInstance
?????????????????????????????NULL)?;
????????ShowWindow?(hwnd?SW_SHOWMAXIMIZED)?;?//最大化顯示
????????UpdateWindow?(hwnd)?;
????????ShowCursor(FALSE);?//隱藏鼠標(biāo)光標(biāo)
????????srand?((int)?GetCurrentTime?())?;?//初始化隨機(jī)數(shù)發(fā)生器
????????while?(GetMessage?(&msg?NULL?0?0))
????????{
????????????????TranslateMessage?(&msg)?;
????????????????DispatchMessage?(&msg)?;
????????}
????????ShowCursor(TRUE);?//顯示鼠標(biāo)光標(biāo)
????????return?msg.wParam?;
}
TCHAR?randomChar()?//隨機(jī)字符產(chǎn)生函數(shù)
{
????????return?(TCHAR)(rand()?%?(126?-?33)?+?33);?//33到126之間
}
int?init(CharColumn?*cc?int?cyScreen?int?x)?//初始化
{
????????int?j;
????????cc->iStrLen?=?rand()?%?(STRMAXLEN?-?STRMINLEN)?+?STRMINLEN;?//顯示列的長(zhǎng)度
????????cc->x?=?x?+?3?;??????//顯示列的開始顯示的x坐標(biāo)
????????cc->y?=?rand()?%?3???rand()?%?cyScreen?:?0;?//顯示列的開始顯示的y坐標(biāo)
????????cc->iMustStopTimes?=?rand()?%?6?;
????????cc->iStopTimes????=?0?;
????????cc->head?=?cc->current?=
???????????????????????????(pCharChain)calloc(cc->iStrLen?sizeof(CharChain));?//生成顯示列
????????for?(j?=?0;?j?iStrLen?-?1;?j++)
????????{
????????????
評(píng)論
共有 條評(píng)論