设为首页 加入收藏

TOP

(Visual C++)游戏开发笔记十六 讲解一个完整的回合制游戏demo (五)
2014-11-23 19:48:53 】 浏览:1039
Tags:Visual 游戏 开发 笔记 十六 讲解 一个 完整 回合 demo
sprintf(str,"怪物使用梅肯斯姆...恢复了30点生命值",damage);
MsgInsert(str);
}
break;
case 4:
//在第30个画面时判断怪物是否逃跑成功
if(f == 30)
{
if(1== rand()%3 ) //逃跑几率1/3
{
over = true;
monster.nHp = 0;

sprintf(str,"怪物逃跑中...逃跑成功");
MsgInsert(str);
}
else
{
sprintf(str,"怪物逃跑中...逃跑失败");
MsgInsert(str);
}
}
break;
}
}

if(f == 30) //回合结束
{
attack = false;
f = 0;
}
}

BitBlt(hdc,0,0,640,510,mdc,0,0,SRCCOPY);

tPre = GetTickCount();

pNum++;
if(pNum == 8)
pNum = 0;
}

//****新增的对战消息函数********************************
void MsgInsert(char* str)
{
if(txtNum < 5)
{
sprintf(text[txtNum],str);
txtNum++;
}
else
{
for(int i=0;i sprintf(text[i],text[i+1]);

sprintf(text[4],str);
}
}

//****生命值判断函数*************************
void CheckDie(int hp,bool player)
{
char str[100];

if(hp <= 0)
{
over = true;
if(player)
{
sprintf(str,"胜败乃兵家常事,大侠请重新来过......");
MsgInsert(str);
}
else
{
sprintf(str,"少年,你赢了,有两下子啊~~~~~!!!!");
MsgInsert(str);
}
}
}

//****消息处理函数***********************************
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int x,y;

switch (message)
{
case WM_KEYDOWN: //键盘消息
if(wParam==VK_ESCAPE) //按下Esc键
PostQuitMessage(0);
break;
case WM_LBUTTONDOWN: //鼠标左键消息
if(!attack)
{
x = LOWORD(lParam); //X坐标
y = HIWORD(lParam); //Y坐标

if(x >= 500 && x <= 550 && y >= 350 && y <= 400)
attack = true;
}
break;
case WM_DESTROY: //窗口结束消息
DeleteDC(mdc);
DeleteDC(bufdc);
DeleteObject(bg);
DeleteObject(sheep);
DeleteObject(girl);
DeleteObject(skill);
DeleteObject(skillult);
DeleteObject(slash);
DeleteObject(magic);
DeleteObject(recover);
DeleteObject(game);

ReleaseDC(hWnd,hdc);

PostQuitMessage(0);
break;
default: //默认消息
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
#include "stdafx.h"
#include

//定义一个结构体
struct chr
{
int nHp;
int fHp;
int lv;
int w;
int kind;
};

//全局变量声明
HINSTANCE hInst;
HBITMAP bg,sheep,girl,skill,skillult,slash,magic,recover,game;
HDC hdc,mdc,bufdc;
HWND hW

首页 上一页 2 3 4 5 6 7 8 下一页 尾页 5/9/9
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇vc里实现不规则窗体 下一篇richedit研究04 ? 高效时钟

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目