游戏基础015---人工智能-追逐移动
代码下载 /2012/0118/20120118082045805.rar
/************************************************************************/
/*
人工智能理论:
类神经网络:以多个连结处理器负责不同单元处理,仿真人类大脑思考与学习
能力的人工智能理论。
基因算法:利用仿真自然界适者生存的进化原理,对于问题产生最佳解决方案
的人工智能理论。
模糊逻辑:以一种判断推理(if-else)方式来产生最佳猜测的决定,有别于一般
数易做图算为基础的人工智能理论。
*/
/************************************************************************//
#include "stdafx.h"
//全局变量声明
HINSTANCE hInst;
HBITMAP bg,ship,bird;
HDC hdc,mdc,bufdc;
HWND hWnd;
DWORD tPre,tNow;
int x,y,nowX,nowY;
int w=0;
POINT p[3];
//全局函数
void MyPaint(HDC);
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
//****程序入口**************************************
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
MSG msg;
MyRegisterClass(hInstance);
//运行初始化函数
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
//游戏循环 www.zzzyk.com
while (msg.message != WM_QUIT)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
tNow = GetTickCount();
if (tNow-tPre >= 40)
{
MyPaint(hdc);
}
}
}
return msg.wParam;
}
//****定义及注册窗口类别函数*************************
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = NULL;
wcex.hCursor = NULL;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = "canvas"; //类别名称
wcex.hIconSm = NULL;
return RegisterClassEx(&wcex);
}
//****初始化*************************************
// 1.设定飞机初始位置
// 2.设定鼠标光标位置及隐藏
// 3.限制鼠标光标移动区域
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HBITMAP bmp;
POINT pt,lt,rb;
RECT rect;
hInst = hInstance;
hWnd = CreateWindow("canvas", "绘图窗口" , WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
MoveWindow(hWnd,10,10,600,450,true);
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
hdc = GetDC(hWnd);
mdc = CreateCompatibleDC(hdc);
bufdc = CreateCompatibleDC(hdc);
bmp = CreateCompatibleBitmap(hdc,640,480);
SelectObject(mdc,bmp);
bg = (HBITMAP)LoadImage(NULL,"bg.bmp",IMAGE_BITMAP,648,480,LR_LOADFROMFILE);
ship = (HBITMAP)LoadImage(NULL,"ship.bmp",IMAGE_BITMAP,100,148,LR_LOADFROMFILE);
bird = (HBITMAP)LoadImage(NULL,"bird.bmp",IMAGE_BITMAP,122,122,LR_LOADFROMFILE);
x = 300;
y = 300;
nowX = 300;
nowY = 300;
//设定鼠标光标位置
pt.x = 300;
pt.y = 300;
ClientToScreen(hWnd,&pt);
SetCursorPos(pt.x,pt.y);
ShowCursor(false);//隐藏光标
//限制光标移动区域
GetClientRect(hWnd,&rect);
lt.x = rect.left;
lt.y = rect.top;
rb.x = rect.
/************************************************************************/
/*
人工智能理论:
类神经网络:以多个连结处理器负责不同单元处理,仿真人类大脑思考与学习
能力的人工智能理论。
基因算法:利用仿真自然界适者生存的进化原理,对于问题产生最佳解决方案
的人工智能理论。
模糊逻辑:以一种判断推理(if-else)方式来产生最佳猜测的决定,有别于一般
数易做图算为基础的人工智能理论。
*/
/************************************************************************//
#include "stdafx.h"
//全局变量声明
HINSTANCE hInst;
HBITMAP bg,ship,bird;
HDC hdc,mdc,bufdc;
HWND hWnd;
DWORD tPre,tNow;
int x,y,nowX,nowY;
int w=0;
POINT p[3];
//全局函数
void MyPaint(HDC);
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
//****程序入口**************************************
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
MSG msg;
MyRegisterClass(hInstance);
//运行初始化函数
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
//游戏循环 www.zzzyk.com
while (msg.message != WM_QUIT)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
tNow = GetTickCount();
if (tNow-tPre >= 40)
{
MyPaint(hdc);
}
}
}
return msg.wParam;
}
//****定义及注册窗口类别函数*************************
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = NULL;
wcex.hCursor = NULL;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = "canvas"; //类别名称
wcex.hIconSm = NULL;
return RegisterClassEx(&wcex);
}
//****初始化*************************************
// 1.设定飞机初始位置
// 2.设定鼠标光标位置及隐藏
// 3.限制鼠标光标移动区域
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HBITMAP bmp;
POINT pt,lt,rb;
RECT rect;
hInst = hInstance;
hWnd = CreateWindow("canvas", "绘图窗口" , WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
MoveWindow(hWnd,10,10,600,450,true);
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
hdc = GetDC(hWnd);
mdc = CreateCompatibleDC(hdc);
bufdc = CreateCompatibleDC(hdc);
bmp = CreateCompatibleBitmap(hdc,640,480);
SelectObject(mdc,bmp);
bg = (HBITMAP)LoadImage(NULL,"bg.bmp",IMAGE_BITMAP,648,480,LR_LOADFROMFILE);
ship = (HBITMAP)LoadImage(NULL,"ship.bmp",IMAGE_BITMAP,100,148,LR_LOADFROMFILE);
bird = (HBITMAP)LoadImage(NULL,"bird.bmp",IMAGE_BITMAP,122,122,LR_LOADFROMFILE);
x = 300;
y = 300;
nowX = 300;
nowY = 300;
//设定鼠标光标位置
pt.x = 300;
pt.y = 300;
ClientToScreen(hWnd,&pt);
SetCursorPos(pt.x,pt.y);
ShowCursor(false);//隐藏光标
//限制光标移动区域
GetClientRect(hWnd,&rect);
lt.x = rect.left;
lt.y = rect.top;
rb.x = rect.
补充:综合编程 , 其他综合 ,