資源簡介
Visual C++回合制游戲demo
//設(shè)定玩家角色聲明值及上限
//設(shè)定玩家角色等級(jí)
//設(shè)定攻擊傷害加權(quán)值
//設(shè)定怪物角色生命值及上限
//設(shè)定怪物角色等級(jí)
//設(shè)定攻擊傷害加權(quán)值

代碼片段和文件信息
#include?“stdafx.h“
#include?
//Download?by?http://www.codefans.net
//定義一個(gè)結(jié)構(gòu)體
struct?chr
{
int nHp;
int fHp;
int lv;
int w;
int kind;
};
//全局變量聲明
HINSTANCE?hInst;
HBITMAP bgsheepgirlskillskillultslashmagicrecovergame;
HDC hdcmdcbufdc;
HWND hWnd;
DWORD tPretNow;
int pNumftxtNum;
bool attackover;
chr playermonster;
char text[5][100];
//全局函數(shù)聲明
ATOM MyRegisterClass(HINSTANCE?hInstance);
BOOL InitInstance(HINSTANCE?int);
LRESULT?CALLBACK WndProc(HWND?UINT?WPARAM?LPARAM);
void MyPaint(HDC?hdc);
void MsgInsert(char*);
void CheckDie(int?hpbool?player);
//****WinMain函數(shù),程序入口點(diǎn)函數(shù)**************************************
int?APIENTRY?WinMain(HINSTANCE?hInstance
?????????????????????HINSTANCE?hPrevInstance
?????????????????????LPSTR?????lpCmdLine
?????????????????????int???????nCmdShow)
{
MSG?msg;
MyRegisterClass(hInstance);
//初始化??
if?(!InitInstance?(hInstance?nCmdShow))?
{
return?FALSE;
}
//消息循環(huán)
GetMessage(&msgNULLNULLNULL);????????????//初始化msg????
????while(?msg.message!=WM_QUIT?)
????{
????????if(?PeekMessage(?&msg?NULL?00?PM_REMOVE)?)
????????{
????????????TranslateMessage(?&msg?);
????????????DispatchMessage(?&msg?);
????????}
else
{
tNow?=?GetTickCount();
if(tNow-tPre?>=?40)
MyPaint(hdc);
}
????}
return?msg.wParam;
}
//***設(shè)計(jì)一個(gè)窗口類,類似填空題,使用窗口結(jié)構(gòu)體*************************
ATOM?MyRegisterClass(HINSTANCE?hInstance)
{
WNDCLASSEX?wcex;
wcex.cbSize?=?sizeof(WNDCLASSEX);?
wcex.style =?CS_HREDRAW?|?CS_VREDRAW?|?CS_DBLCLKS;
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);
}
//****初始化函數(shù)************************************
//加載位圖并設(shè)定各種初始值?
BOOL?InitInstance(HINSTANCE?hInstance?int?nCmdShow)
{
HBITMAP?bmp;
hInst?=?hInstance;
hWnd?=?CreateWindow(“canvas“?“淺墨的繪圖窗口“??WS_OVERLAPPEDWINDOW
CW_USEDEFAULT?0?CW_USEDEFAULT?0?NULL?NULL?hInstance?NULL);
if?(!hWnd)
{
return?FALSE;
}
MoveWindow(hWnd1010640510true);
ShowWindow(hWnd?nCmdShow);
UpdateWindow(hWnd);
hdc?=?GetDC(hWnd);
mdc?=?CreateCompatibleDC(hdc);
bufdc?=?CreateCompatibleDC(hdc);
bmp?=?CreateCompatibleBitmap(hdc640510);
Selectobject(mdcbmp);
bg?=?(HBITMAP)LoadImage(NULL“bg.bmp“IMAGE_BITMAP640510LR_LOADFROMFILE);
sheep?=?(HBITMAP)LoadImage(NULL“sheep.bmp“IMAGE_BITMAP133220LR_LOADFROMFILE);
girl?=?(HBITMAP)LoadImage(NULL“girl.bmp“IMAGE_BITMAP480148LR_LOADFROMFILE);
skill?=?(HBITMAP)LoadImage(NULL“skill.bmp“IMAGE_BITMAP5050LR_LOADFROMFILE);
skillult?=?(HBITMAP)LoadImage(NULL“skillult.bmp“IMAGE_BITMAP5050LR_
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
-----------?---------??----------?-----??----
?????????????44314449????????????????????31
評(píng)論
共有 條評(píng)論