资源简介
疯狂桌面贪吃蛇,操作桌面的图标组成贪吃蛇,非常好玩

代码片段和文件信息
////////////////////////////////////////////////
// KeyHookApp.cpp文件
#include “resource.h“
#include “KeyHookApp.h“
#include “KeyHookLib.h“
#include
#include
#include
#include
using namespace std;
#pragma comment(lib “09KeyHookLib“)
CMyApp theApp;
BOOL CMyApp::InitInstance()
{
CMainDialog dlg;
m_pMainWnd = &dlg;
dlg.DoModal();
return FALSE;
}
CMainDialog::CMainDialog(CWnd* pParentWnd):CDialog(IDD_MAIN pParentWnd)
{
}
BEGIN_MESSAGE_MAP(CMainDialog CDialog)
ON_MESSAGE(HM_KEY OnHookKey)
ON_WM_TIMER()
END_MESSAGE_MAP()
void CMainDialog::OnGetDesktopInfo()
{
HWND hDesk;
RECT rc;
hDesk=GetDesktopWindow()->GetSafeHwnd();
::GetWindowRect(hDesk&rc);
DeskWidth=rc.right-rc.left;
DeskHeight=rc.bottom-rc.top;
}
void CMainDialog::OnTimer(UINT nIDEvent)
{
int i;
for( i=HasEat;i>0;i--) //移动贪吃蛇除头部以外的部分
{
EatIconPos[i][0]=EatIconPos[i-1][0];
EatIconPos[i][1]=EatIconPos[i-1][1];
}
switch(Dir)
{
case 0:
EatIconPos[0][1]=(EatIconPos[0][1]-1 +DeskHeight / IconHeight) % (DeskHeight / IconHeight);
break;
case 1:
EatIconPos[0][1]=(EatIconPos[0][1]+1) % (DeskHeight / IconHeight);
break;
case 2:
EatIconPos[0][0]=(EatIconPos[0][0]-1+DeskWidth / IconWidth) % (DeskWidth / IconWidth);
break;
case 3:
EatIconPos[0][0]=(EatIconPos[0][0]+1) % (DeskWidth / IconWidth);
break;
}
if(EatIconPos[0][0]==EatIconPos[HasEat+1][0] && EatIconPos[0][1] ==EatIconPos[HasEat+1][1])
{ //吃到了食物
HasEat++;
if(HasEat==IconNum-1)
{
CDialog::OnCancel();
}
srand(time(NULL));
int xy;
con:
x=rand()%(DeskWidth / IconWidth);
y=rand()%(DeskHeight / IconHeight);
for(int i=0;i<=HasEat;i++)
{
if(x==EatIconPos[i][0] && y==EatIconPos[i][1])
{
goto con;
}
}
EatIconPos[HasEat+1][0]=x;
EatIconPos[HasEat+1][1]=y;
}
for( i=0;i<=HasEat+1;i++)
{
OnSetDeskIcon(hwndSysListView32iEatIconPos[i][0]*IconWidthEatIconPos[i][1] * IconHeight);
}
CDialog::OnTimer(nIDEvent);
}
BOOL CMainDialog::OnInitDialog()
{
CDialog::OnInitDialog();
SetIcon(theApp.LoadIcon(IDI_MAIN) FALSE);
OnGetDesktopInfo();
OnGetDeskIconInfo();
hwndParent = ::FindWindow( “Progman“ “Program Manager“ );
hwndSHELLDLL_DefView = ::FindWindowEx( hwndParent NULL “SHELLDLL_DefView“ NULL );
hwndSysListView32 = ::FindWindowEx( hwndSHELLDLL_DefView NULL “SysListView32“ “FolderView“ );
for(int i=0;i {
OnSetDeskIcon(hwndSysListView32i-1000);
}
Dir=1;
HasEat=0;
srand(time(NULL));
for(i=0;i<2;i++)
{
EatIconPos[i][0]=rand()%(DeskWidth / IconWidth);
EatIconPos[i][1]=rand()%(DeskHeight / DeskHeight);
}
// 安装钩子
if(!SetKeyHook(TRUE 0 m_hWnd))
MessageBox(“安装钩子失败!“);
SetTimer( 100 100 NULL);
return TRUE;
}
void CMainDialog::OnCancel()
{
// 卸载钩子
SetKeyHook(FALSE);
for(int i
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3913 2012-02-19 14:18 疯狂桌面图标贪吃蛇\09KeyHookApp.dsp
文件 547 2004-12-01 17:46 疯狂桌面图标贪吃蛇\09KeyHookApp.dsw
文件 1359972 2012-02-19 20:39 疯狂桌面图标贪吃蛇\09KeyHookApp.exe
文件 204872 2004-12-01 20:08 疯狂桌面图标贪吃蛇\09KeyHookLib.dll
文件 2134 2004-12-01 20:08 疯狂桌面图标贪吃蛇\09KeyHookLib.lib
文件 6984 2012-02-19 12:10 疯狂桌面图标贪吃蛇\KeyHookApp.cpp
文件 787 2012-02-18 22:55 疯狂桌面图标贪吃蛇\KeyHookApp.h
文件 3774 2004-12-01 19:01 疯狂桌面图标贪吃蛇\KeyHookApp.ICO
文件 2513 2012-02-18 21:56 疯狂桌面图标贪吃蛇\KeyHookApp.rc
文件 453 2004-12-01 20:07 疯狂桌面图标贪吃蛇\KeyHookLib.h
文件 1359972 2012-02-19 20:39 疯狂桌面图标贪吃蛇\Release\09KeyHookApp.exe
文件 204872 2004-12-01 20:08 疯狂桌面图标贪吃蛇\Release\09KeyHookLib.dll
文件 550 2004-12-01 19:01 疯狂桌面图标贪吃蛇\resource.h
文件 188 2012-02-19 19:36 疯狂桌面图标贪吃蛇\操作说明.txt
目录 0 2012-02-19 20:40 疯狂桌面图标贪吃蛇\Release
目录 0 2012-02-19 20:40 疯狂桌面图标贪吃蛇
----------- --------- ---------- ----- ----
3151531 16
相关资源
- 贪吃蛇源代码.fla
- 贪吃蛇游戏设计(汇编语言)
- Scratch 贪吃蛇 素材及代码
- Scratch 贪吃蛇 小游戏源码
- Scratch 好玩的贪吃蛇1.0
- Scratch 贪吃蛇.sb3 小游戏源码
- as3.0贪吃蛇源码 实现了基本功能
- unity3d制作贪吃蛇
- OpenGL 3D贪吃蛇程序,很小
- 桌面图标贪吃蛇游戏
- appinventor超简易贪吃蛇源码.rar
- stm32 贪吃蛇
- cocos-creator贪吃蛇
- 汇编贪吃蛇masm版本
- 贪吃蛇Verilog
- 基于VHDL的贪吃蛇小游戏
- STM32+lcd12864串行方式显示贪吃蛇代码
- 安卓贪吃蛇游戏开发源代码及开发文
- 贪吃蛇游戏的FPGA实现课程设计报告—
- 贪吃蛇.zip235508
- VERILOG语言编写的贪吃蛇小游戏
- 基于STM32的贪吃蛇
- VC做的贪吃蛇
- 用Verilog编写的贪吃蛇游戏
- QT4.8做的五彩贪吃蛇游戏
- 12864液晶带字库+不带字库+51单片机贪
- 基于qt实现的贪吃蛇游戏
- 安卓贪吃蛇小游戏
- 基于ARM STM32F429的红外遥控贪吃蛇游戏
- 智能寻路贪吃蛇 AI
评论
共有 条评论