(MFC)RPG角色生成器
2017-05-14 01:00
330 查看
角色生成器需要记录玩家输入的名字,选择的性别,种族,职业,并且根据不同职业所随机生产的属性也不相同。
编辑环境VC++6.0。
用MFC编辑过程中所应用到的知识点有编辑框,组合框,按钮,子窗口,变量关联,类的继承,子对话框类继承父对话类。
发放一些关键代码
编辑环境VC++6.0。
用MFC编辑过程中所应用到的知识点有编辑框,组合框,按钮,子窗口,变量关联,类的继承,子对话框类继承父对话类。
发放一些关键代码
//位图使用背景 void CRPGDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CPaintDC dc(this); CBitmap m_bitmap; m_bitmap.LoadBitmap(IDB_BJ); CDC memdc; memdc.CreateCompatibleDC(&dc); memdc.SelectObject(&m_bitmap); int width,height; BITMAP bmp; m_bitmap.GetBitmap(&bmp); width=bmp.bmWidth; height=bmp.bmHeight; CRect rect; this->GetClientRect(&rect); dc.StretchBlt(rect.left,rect.top,rect.Width(),rect.Height(),&memdc,0,0,width,height,SRCCOPY); } }
//不同种族对应不同职业的选择 void CRPGDlg::OnButton1() { // TODO: Add your control notification handler code here a=m_race.GetCurSel(); switch(a) { case 0: m_occupation.InsertString(0,_T("狂战士")); m_occupation.InsertString(1,_T("圣骑士")); m_occupation.InsertString(2,_T("刺客")); m_occupation.InsertString(3,_T("猎手")); m_occupation.InsertString(4,_T("祭司")); m_occupation.InsertString(5,_T("巫师")); break; case 1: m_occupation.InsertString(0,_T("刺客")); m_occupation.InsertString(1,_T("猎手")); m_occupation.InsertString(2,_T("祭司")); m_occupation.InsertString(3,_T("巫师")); break; case 2: m_occupation.InsertString(0,_T("狂战士")); m_occupation.InsertString(1,_T("猎手")); m_occupation.InsertString(2,_T("祭司")); break; case 3: m_occupation.InsertString(0,_T("狂战士")); m_occupation.InsertString(1,_T("圣骑士")); m_occupation.InsertString(2,_T("祭司")); break; case 4: m_occupation.InsertString(0,_T("祭司")); m_occupation.InsertString(1,_T("巫师")); break; } }
//不同职业不同属性 BOOL RPG2::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here SetDlgItemText(IDC_EDIT_ID1,str); SetDlgItemText(IDC_EDIT_Sex1,str1); SetDlgItemText(IDC_EDIT_RACE1,str2); SetDlgItemText(IDC_EDIT_OCCUPATION1,str3); //位图加载 HINSTANCE hInstance; HBITMAP hBitmap; hInstance = ::AfxGetInstanceHandle(); hBitmap = ::LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_touxiang) ); m_Button.SetBitmap(hBitmap); //属性生成 srand((unsigned)time(NULL)); liliang = rand() % 50; mingjie = rand() % 50; tili = rand() % 50; zhili = rand() % 50; zhihui = rand() % 50; xueliang=tili * 20; lanliang=(zhihui + zhili)*10; m_liliang.Format("%d",liliang); m_mingjie.Format("%d",mingjie); m_tili.Format("%d",tili); m_zhili.Format("%d",zhili); m_zhihui.Format("%d",zhihui); m_xueliang.Format("%d",xueliang); m_lanliang.Format("%d",lanliang); CWnd * h_liliang; CWnd * h_mingjie; CWnd * h_tili; CWnd * h_zhili; CWnd * h_zhihui; CWnd * h_xueliang; CWnd * h_lanliang; h_liliang=GetDlgItem(IDC_STATIC_liliang); h_liliang->SetWindowText(m_liliang); h_mingjie=GetDlgItem(IDC_STATIC_mingjie); h_mingjie->SetWindowText(m_mingjie); h_tili=GetDlgItem(IDC_STATIC_tili); h_tili->SetWindowText(m_tili); h_zhili=GetDlgItem(IDC_STATIC_zhili); h_zhili->SetWindowText(m_zhili); h_zhihui=GetDlgItem(IDC_STATIC_zhihui); h_zhihui->SetWindowText(m_zhihui); h_xueliang=GetDlgItem(IDC_STATIC_xueliang); h_xueliang->SetWindowText(m_xueliang); h_lanliang=GetDlgItem(IDC_STATIC_lanliang); h_lanliang->SetWindowText(m_lanliang); //血量,蓝量显示百分比 m_xl.SendMessage(PBM_SETBARCOLOR,0,(LPARAM)(COLORREF)RGB(255,0,255)); m_xl.SetPos(100); m_ll.SetPos(100); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
相关文章推荐
- RPG角色生成器
- 基于安卓的RPG角色生成器
- RPG角色生成器(C++)
- RPG角色生成器
- rpg角色生成器
- RPG角色生成器
- RPG角色游戏的创建
- 角色扮演游戏(RPG)-------之谈
- 奇幻RPG(角色技能 与 Strategy模式)
- Unity5.0 RPG角色扮演历险类游戏之 森林历险记
- cocos2dx3.2开发 RPG《Flighting》(六)角色的状态和控制效果
- [Unity&RPG]实现简单的鼠标点击移动 角色
- Unity3D-RPG项目实战(4):角色性能测试
- RPG游戏制作:(1)自定义角色
- cocos2dx3.2开发 RPG《Flighting》(七)回到战斗场景,更新角色的叠放次序
- Cocos2D实现RPG队伍菜单任意调整角色顺序的效果
- 开发rpg制作游戏用的角色人物素材图片,《石器时代》,共20张图片
- 基于cocos2dx的RPG简单实用算法之2 - 角色跟随移动
- Cocos2D实现RPG队伍菜单任意调整角色顺序的效果
- 奇幻RPG(角色技能 与 Strategy模式)