資源簡介
動態效果,黑客帝國
#include
#define ID_TIMER 1
#define STRMAXLEN 25 //一個顯示列的最大長度
#define STRMINLEN 8 //一個顯示列的最小長度
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
typedef struct tagCharChain //整個當作屏幕的一個顯示列,這是個雙向列表
{
struct tagCharChain *prev; //鏈表的前個元素
TCHAR ch; //一個顯示列中的一個字符
struct tagCharChain *next; //鏈表的后個元素
} CharChain, *pCharChain;
typedef struct tagCharColumn
{
CharChain *head, *current, *point;
int x, y, iStrLen; //顯示列的開始顯示的x,y坐標,iStrLen是這個列的長度
int iStopTimes, iMustStopTimes; //已經停滯的次數和必須停滯的次數,必須停滯的次數是隨機的
} CharColumn, *pCharColumn;
/***********************/
.....................
...................
代碼片段和文件信息
#include?
#define?ID_TIMER????1
#define?STRMAXLEN??25?//一個顯示列的最大長度
#define?STRMINLEN??8??//一個顯示列的最小長度
LRESULT?CALLBACK?WndProc?(HWND?UINT?WPARAM?LPARAM)?;
typedef?struct?tagCharChain?//整個當作屏幕的一個顯示列這是個雙向列表
{
????????struct?tagCharChain?*prev;?//鏈表的前個元素
????????TCHAR??ch;??????????????????//一個顯示列中的一個字符
????????struct?tagCharChain?*next;?//鏈表的后個元素
}?CharChain?*pCharChain;
typedef?struct?tagCharColumn
{
????????CharChain?*head?*current?*point;
????????int?x?y?iStrLen;?//顯示列的開始顯示的xy坐標iStrLen是這個列的長度
????????int?iStopTimes?iMustStopTimes;?//已經停滯的次數和必須停滯的次數必須停滯的次數是隨機的
}?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?(“此程序必須運行在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);?//隱藏鼠標光標
????????srand?((int)?GetCurrentTime?())?;?//初始化隨機數發生器
????????while?(GetMessage?(&msg?NULL?0?0))
????????{
????????????????TranslateMessage?(&msg)?;
????????????????DispatchMessage?(&msg)?;
????????}
????????ShowCursor(TRUE);?//顯示鼠標光標
????????return?msg.wParam?;
}
TCHAR?randomChar()?//隨機字符產生函數
{
????????return?(TCHAR)(rand()?%?(126?-?33)?+?33);?//33到126之間
}
int?init(CharColumn?*cc?int?cyScreen?int?x)?//初始化
{
????????int?j;
????????cc->iStrLen?=?rand()?%?(STRMAXLEN?-?STRMINLEN)?+?STRMINLEN;?//顯示列的長度
????????cc->x?=?x?+?3?;??????//顯示列的開始顯示的x坐標
????????cc->y?=?rand()?%?3???rand()?%?cyScreen?:?0;?//顯示列的開始顯示的y坐標
????????cc->iMustStopTimes?=?rand()?%?6?;
????????cc->iStopTimes????=?0?;
????????cc->head?=?cc->current?=
???????????????????????????(pCharChain)calloc(cc->iStrLen?sizeof(CharChain));?//生成顯示列
????????for?(j?=?0;?j?iStrLen?-?1;?j++)
????????{
????????????
- 上一篇:C語言程序撲克發牌
- 下一篇:三維重建 特征點提取 立體匹配
評論
共有 條評論