大家好,我是LCR。
这是升级的第一个版本,行数增加不多,但是却废了一整天改代码
如果大家喜欢的话,请留下你的一个赞吧~
关于1.29后版本的说明
这个版本将会使用c++图形库EasyX来编辑,整体的感觉较好
由于部分朋友没有EasyX,将直接发布应用程序
更新内容
- 修复启动界面启动后返回标题画面再次启动,界面不会变化的bug
- 启动界面的颜色优化,分为数据读取界面 和 新建世界界面
- 启动界面新增鼠标点击启动,游玩体验优化
更新代码
首先是修复启动界面不会变化bug及启动界面颜色优化的代码:
if(bj==1){
for(int i=5;i<=14;i++){
for(int j=45;j<=64;j+=2){
color(5);
gotoxy(j,i);
cout<<jiazai;
Sleep(60);
load++;
gotoxy(47,17);
color(0);
cout<<"数据读取中:"<<load<<'%';
}
}
Sleep(1000);
}
if(bj==0){
for(int i=5;i<=14;i++){
for(int j=45;j<=64;j+=2){
color(1);
gotoxy(j,i);
cout<<jiazai;
Sleep(80);
load++;
gotoxy(47,17);
color(5);
cout<<"新建世界中:"<<load<<'%';
}
}
Sleep(1000);
bj=1;
}
其次是关于显示图片及文字的代码:
void button(int x, int y, int w, int h, int big, const char* text){
LOGFONT f;
gettextstyle(&f);
f.lfQuality=ANTIALIASED_QUALITY;
settextstyle(&f);
setlinecolor(WHITE);//设置框边颜色
setbkmode(TRANSPARENT);//设置字体背景透明
setfillcolor(RGB(255, 0, 192));//设置填充颜色
fillroundrect(x, y, x + w, y + h, 10, 10);//画一个按钮框
char text_[50] = {0};
strcpy(text_, text);
settextcolor(WHITE);
settextstyle(big, 0, "黑体");
int tx = x + (w - textwidth(text_)) / 2;
int ty = y + (h - textheight(text_)) / 2;
outtextxy(tx, ty, text_);
}
最后是关于鼠标点击的代码:
void jinruyouxi(){
int load=0;
system("cls");
string jiazai="█ ";
initgraph(220,200,SHOWCONSOLE|NOCLOSE);
setbkcolor(YELLOW);
cleardevice();
button(10,4,200,80,25,"开始游戏");
button(10,104,200,80,25,"结束游戏");
ExMessage msg;
while(1){
if(peekmessage(&msg, EM_MOUSE)){//有鼠标消息返回真,没有返回假
switch(msg.message){
case WM_LBUTTONDOWN:{
if(msg.x>=10&&msg.x<=10+200&&msg.y>=4&&msg.y<=4+80){
if(bj==1){
for(int i=5;i<=14;i++){
for(int j=45;j<=64;j+=2){
color(5);
gotoxy(j,i);
cout<<jiazai;
Sleep(60);
load++;
gotoxy(47,17);
color(0);
cout<<"数据读取中:"<<load<<'%';
}
}
Sleep(1000);
}
if(bj==0){
for(int i=5;i<=14;i++){
for(int j=45;j<=64;j+=2){
color(1);
gotoxy(j,i);
cout<<jiazai;
Sleep(80);
load++;
gotoxy(47,17);
color(5);
cout<<"新建世界中:"<<load<<'%';
}
}
Sleep(1000);
bj=1;
}
color(0);
system("cls");
switch(panduan){//1:想干什么 2:商店 3:地面探索 4:恶龙谷 5:恶龙谷--自由探索 6:恶龙谷--地狱 7:末地
case 1:{
xiangganshenm();
break;
}
case 2:{
shangdian();
break;
}
case 3:{
dimiantansuo();
break;
}
case 4:{
elonggu();
break;
}
case 5:{
ziyoutansuo();
break;
}
case 6:{
diyumen();
break;
}
}
return;
}
if(msg.x>=10&&msg.x<=10+200&&msg.y>=104&&msg.y<=104+80){
jieshu();
break;
}
}
}
}
}
}
应用路径
https://ruibao.lanzoum.com/i7T9A0qtj3xg
谢谢大家~