赞
踩
目录
此游戏基于easyX,采取贪吃蛇和飞机大战的思想进行制作,游戏存在几个莫名扣血BUG,以下下为游戏内容(代码含详细注释):(底部含游戏及素材下载链接,制作不易,求赞)
- //头文件
- #include<stdio.h>
- #include<stdlib.h>
- #include<graphics.h>
- #include<conio.h>
- #include<time.h>
- #include <iostream>
- #include<mmsystem.h>//包含多媒体设备接口头文件,一定放在graphics.h下面
- #pragma comment(lib,"winmm.lib")//加载静态库
定义窗口和角色,方便记忆,直接调用数据
-
- //定义数据
- #define window_length 820//窗口长度
- #define window_width 600//窗口宽度
- #define juese_height 80//角色高度
- #define juese_width 70//角色宽度
制作游戏前将游戏分成不同类型进行编译会更清晰容易,本人在这里将游戏分为窗口、游戏、模块三类进行定义函数
-
- //自定义函数总览
- //窗口类
- void start_window();//开始窗口
- void running_window();//加载窗口
- int game_window();//游戏窗口
- void change_window();//难度窗口
- void introduce_window();//介绍窗口
- void victory_window();//胜利界面
-
-
- //游戏类
- void yun1();//支撑物1
- void yun2();//支撑物2
- void yun3();//支撑物3
- int check_top(int x, int y);//判定——上方
- void game_time(int now);//计时
- int gettime(clock_t start);
- void xuetiao(int blood);//血条
- void top_npc1(int fly1, int space1, int npc_x1);//天空龙 1
- void top_npc2(int fly2, int space2, int npc_x2);//天空龙 2
- void right_npc(int fly3, int space3, int npc_y3);//天空龙 3
- void ground_npc(int fly4, int space4, int npc_y4);//喷火龙
- void end_pkq(int fly5, int space5, int npc_y5);//结束道具
- int check_lose_blood(int x, int y, int npc_x, int npc_y);//判定扣血
- int check_lose_blood_cm(int x, int y, int npc_x, int npc_y);//判定扣血
- int check_lose_blood_g(int x, int y, int npc_x, int npc_y);//判定扣血
- int check_victory(int x, int y, int npc_x, int npc_y);//判定游戏胜利
- int zanting(HWND gamewindow);//游戏暂停
-
-
- //模块类
- void nomal_botton(int left, int top, int right, int bottom, const char* text);//正常状态按钮
- void abnomal_botton(int left, int top, int right, int bottom);//选中状态按钮
- int select();//点击选项
- int return_back();//返回选项
- int select_differ();//难度选择
- void menu(int choice, HWND start_window);//菜单中转
- void running(int i, int lunhuan);//进度条
- void music();//BGM
- void end_mode(HWND startwindow);//结束模块
- int check_jdt(int zhongzhuan);//进度条动画皮卡丘
-
定义全局变量,用于对游戏内参数进行调整,实现对难度的更改
- //全局变量
- int i = 0;//需要临时变量使使用
- int fly_down = 0;//飞行功能
- int gravity = 5;//重力
- int sudu = 20;//移速
- int differ = 0;//难度
- int now = 0;//当前时间
- void start_window()//开始窗口
- {
- music();
- initgraph(window_length, window_width);//启动窗口
- HWND startwindow = GetHWnd();//获取窗口句柄
- SetWindowText(startwindow, "小命要紧");//设置窗口标题
- while (1)
- {
- BeginBatchDraw();
- IMAGE start_bk;
- loadimage(&start_bk, _T("start_bk.png"));//设置背景
- putimage(0, 0, &start_bk);
- //设置按钮
- nomal_botton(25, 100, 200, 150, "开始游戏");//第一个按钮
- nomal_botton(25, 200, 200, 250, "选择难度");//第二个按钮
- nomal_botton(25, 300, 200, 350, "游戏介绍");//第三个按钮
- nomal_botton(25, 400, 200, 450, "退出游戏");//第四个按钮
- FlushBatchDraw();
- //选项循环模式
- int choice;//选项参数
- choice = select();//选择选项
- menu(choice, startwindow);//加载选项
- }
- }
- void running_window()//加载窗口
- {
- i = 1;
- int zhongzhuan = 0;
- int lunhuan = 0;
- while (1)
- {
- BeginBatchDraw();//开始绘图
- IMAGE running_bk;
- loadimage(&running_bk, _T("running_bk.png"));//设置背景
- putimage(0, 0, &running_bk);
- running(i, lunhuan);
- lunhuan++;
- FlushBatchDraw();//结束绘图
-
- if (i == 8 && lunhuan == 4)//判断皮卡丘动作
- {
-
- Sleep(1000);
- break;
- }
- if (lunhuan >= 4)
- {
- lunhuan = 0;
- }
- zhongzhuan++;
- i = check_jdt(zhongzhuan);//选择进度条进度
-
- Sleep(50);
- }
-
- }
- int game_window()//游戏窗口
- {
- srand((unsigned)time(NULL));//随机数前置动作
- char place = 'd';//起始方向
- int x = 25;//沙奈朵起始横坐标
- int y = 470;//沙奈朵起始纵坐标
- int n = 0;
- int m = 0;
- int blood = 3;//血条初始血量
- char ch1, ch2 = 'd', k1 = 'd', k2 = 'd', k3 = 'd', next1 = 'd', next2 = 'd';//控制跳跃次数
- clock_t start;//计时容量
- start = clock();//计时开始
- int fly1 = 0, fly2 = 0, fly3 = 0, fly4 = 0, fly5 = 0;//飞行高度
- int space1 = 0, space2 = 0, space3 = 0, space4 = 0, space5 = 0;//飞行动作参数
- int check_end1 = 0, check_end2 = 0, check_end3 = 0, check_end4 = 0, check_end5 = 1;//是否碰撞
- int check_next1 = 20, check_next2 = 20, check_next3 = 20, check_next4 = 20, check_next5 = 20;//判断是否需要扣血
- int lingshi1 = 0, lingshi2 = 0, lingshi3 = 0, lingshi4 = 15, lingshi5 = 400;//判断是否增加上空飞行小怪
- int npc_x1 = rand() % 201 + 30;//起始天空龙1横坐标
- int npc_x2 = rand() % 221 + 410;//起始天空龙2横坐标
- int npc_y3 = rand() % 481 + 0;//起始天空龙3纵坐标
- int npc_y4 = 480;//喷火龙纵坐标
- int npc_y5 = rand() % 411 + 100;//皮卡丘纵坐标
- int next_step = 1;//暂停游戏参数
- int huifu = 0;//BUG修复参数
- while (1)//开始游戏循环
- {
- if (y == 470)//落地刷新跳跃次数
- {
- k1 = 'd';
- k2 = 'd';
- }
- BeginBatchDraw();//开始绘图
- //设置地图
- IMAGE map_bk;//背景
- loadimage(&map_bk, _T("game_bk.png"));
- putimage(0, 0, &map_bk);
- IMAGE yun_yuan1, yun_bk1, yun_yuan2, yun_bk2;//外框
- //底层外框
- loadimage(&yun_yuan1, _T("yun1.jpg"), 50, 25);
- loadimage(&yun_bk1, _T("yun2.jpg"), 50, 25);
- for (i = 10; i < 810; i += 50)
- {
- putimage(i, 550, &yun_bk1, SRCAND);//添加位运算宏
- putimage(i, 550, &yun_yuan1, SRCPAINT);
- }
- //左右外框
- loadimage(&yun_yuan2, _T("yun1.jpg"), 25, 25);
- loadimage(&yun_bk2, _T("yun2.jpg"), 25, 25);
- for (i = 0; i < 530; i += 25)
- {
- putimage(10, i, &yun_bk2, SRCAND);//添加位运算宏
- putimage(10, i, &yun_yuan2, SRCPAINT);
- }
- for (i = 0; i < 530; i += 25)
- {
- putimage(785, i, &yun_bk2, SRCAND);//添加位运算宏
- putimage(785, i, &yun_yuan2, SRCPAINT);
- }
- //支撑点
- yun1();//大云
- yun2();//中云
- yun3();//小云
- //计时
- now = gettime(start);//获取游戏时间
- game_time(now);//显示游戏时间
- //血条
- xuetiao(blood);
- //npc小怪
- //天空龙1
- if (lingshi1 == 0)//判断是否刷新小怪
- {
- if (fly1 < 65)
- {
- top_npc1(fly1, space1, npc_x1);//生成天空龙1
- fly1++;
- space1++;
- if (space1 == 2)//选择动作
- {
- space1 = 0;
- }
- }
- }
- if (fly1 == 60)//天空龙1飞至底部
- {
- lingshi1 = rand() % 9 + 12;//间断生成小怪
- npc_x1 = rand() % 201 + 30;//随机天空龙1生成地点,位于地图左半边
- fly1 = 0;
- }
- if (lingshi1 > 0)//逼近生成时间
- {
- lingshi1--;
- }
- //天空龙2
- if (lingshi2 == 0)//判断是否生成小怪
- {
- if (fly2 < 65)
- {
- top_npc2(fly2, space2, npc_x2);//生成天空龙2
- fly2++;
- space2++;
- if (space2 == 2)//选择动作
- {
- space2 = 0;
- }
- }
- }
- if (fly2 == 60)//天空龙2飞至底部
- {
- lingshi2 = rand() % 9 + 12;//间断小怪生成时间
- npc_x2 = rand() % 221 + 410;//随机产生天空龙2生成地点,位于地图右半边
- fly2 = 0;
- }
- if (lingshi2 > 0)//逼近小怪生成时间
- {
- lingshi2--;
- }
- //天空龙3
- if (lingshi3 == 0)//判断是否生成小怪
- {
- if (fly3 < 50)
- {
- right_npc(fly3, space3, npc_y3);//生成天空龙3
- fly3++;
- space3++;
- if (space3 == 4)//选择动作
- {
- space3 = 0;
- }
- }
- }
- if (fly3 == 41)//天空龙3飞至左边
- {
- lingshi3 = rand() % 6 + 15;//间断小怪生成时间
- npc_y3 = rand() % 481 + 0;//随机产生天空龙3生成地点,位于地图右半边
- fly3 = 0;
- }
- if (lingshi3 > 0)//逼近小怪生成时间
- {
- lingshi3--;
- }
- //喷火龙
- if (lingshi4 == 0)//判断是否生成小怪
- {
- if (fly4 < 50)
- {
- ground_npc(fly4, space4, npc_y4);//生成喷火龙
- fly4++;
- space4++;
- if (space4 == 4)//选择动作
- {
- space4 = 0;
- }
- }
- }
- if (fly4 == 41)//喷火龙走至右边
- {
- lingshi4 = rand() % 6 + 15;//间断小怪生成时间
- fly4 = 0;
- }
- if (lingshi4 > 0)//逼近小怪生成时间
- {
- lingshi4--;
- }
- //皮卡丘
- if (lingshi5 == 0)//判断是否生成小怪
- {
- if (fly5 < 50)
- {
- end_pkq(fly5, space5, npc_y5);//生成皮卡丘
- fly5++;
- space5++;
- if (space5 == 4)//选择动作
- {
- space5 = 0;
- }
- }
- }
- if (fly5 == 41)//皮卡丘走至右边
- {
- lingshi5 = rand() % 51 + 100;//间断小怪生成时间
- npc_y5 = rand() % 411 + 100;
- fly5 = 0;
- }
- if (lingshi5 > 0)//逼近小怪生成时间
- {
- lingshi5--;
- }
- //角色(沙奈朵)
- IMAGE juese1, juese2, juese4, juese3;//沙奈朵行走图
- loadimage(&juese1, "snd1.png", 280, 160);
- loadimage(&juese2, "snd2.png", 280, 160);
- loadimage(&juese3, "snd3.png", 280, 160);
- loadimage(&juese4, "snd4.png", 280, 160);
- switch (ch2)//判定行走动作
- {
- case 'd':
- putimage(x, y, juese_width, juese_height, &juese2, n * juese_width, juese_height, SRCAND);
- putimage(x, y, juese_width, juese_height, &juese1, n * juese_width, juese_height, SRCPAINT);
- break;
- case 'a':
- putimage(x, y, juese_width, juese_height, &juese4, n * juese_width, juese_height, SRCAND);
- putimage(x, y, juese_width, juese_height, &juese3, n * juese_width, juese_height, SRCPAINT);
- break;
- }
- switch (place)//判断飞行降落和跳跃动作
- {
- case 'w'://飞行动作
- switch (ch2)//判断原行动方向
- {
- case 'a':
- putimage(x, y, juese_width, juese_height, &juese4, n * juese_width, juese_height, SRCAND);
- putimage(x, y, juese_width, juese_height, &juese3, n * juese_width, juese_height, SRCPAINT);
- break;
- case 'd':
- putimage(x, y, juese_width, juese_height, &juese2, n * juese_width, juese_height, SRCAND);
- putimage(x, y, juese_width, juese_height, &juese1, n * juese_width, juese_height, SRCPAINT);
- break;
- }
- case 's'://降落动作
- switch (ch2)//判断原行动方向
- {
- case 'a':
- putimage(x, y, juese_width, juese_height, &juese4, n * juese_width, juese_height, SRCAND);
- putimage(x, y, juese_width, juese_height, &juese3, n * juese_width, juese_height, SRCPAINT);
- break;
- case 'd':
- putimage(x, y, juese_width, juese_height, &juese2, n * juese_width, juese_height, SRCAND);
- putimage(x, y, juese_width, juese_height, &juese1, n * juese_width, juese_height, SRCPAINT);
- break;
- }
- case 'k'://跳跃动作
- switch (ch2)//判断原行动方向
- {
- case 'a':
- putimage(x, y, juese_width, juese_height, &juese4, n * juese_width, juese_height, SRCAND);
- putimage(x, y, juese_width, juese_height, &juese3, n * juese_width, juese_height, SRCPAINT);
- break;
- case 'd':
- putimage(x, y, juese_width, juese_height, &juese2, n * juese_width, juese_height, SRCAND);
- putimage(x, y, juese_width, juese_height, &juese1, n * juese_width, juese_height, SRCPAINT);
- break;
- }
- }
-
- if (_kbhit())//判断是否有输入
- {
- ch1 = _getch();//获取输入内容
- if (ch1 == 'k')//跳跃键
- {
- switch (ch1)
- {
- case 'k':
- place = 'k';
- //轮换历史键位
- next1 = k1;
- next2 = k2;
- k1 = 'k';
- k2 = next1;
- k3 = next2;
- //动作更换
- n++;
- if (n >= 4)
- {
- n = 0;
- }
- //判断跳跃次数
- if (y > 0 && k3 != 'k')//可以跳跃
- {
- if (m <= 20)
- {
- m += 20;
- y -= 120;
- break;
- }
- else
- {
- place = 's';
- //轮换动作
- n++;
- if (n >= 4)
- {
- n = 0;
- }
- //下降操作
- if (y <= 450)
- {
- y += 15;
- break;
- }
- }
- }
- else//二段跳后进入冷却
- {
- place = 's';
- //动作轮换
- n++;
- if (n >= 4)
- {
- n = 0;
- }
- //下降操作
- if (y <= 450)
- {
- y += 10;
- break;
- }
- break;
- }
- }
- }
- else if (ch1 == 's' || ch1 == 'w')//飞行键或降落键
- {
- switch (ch1)//判断飞行或降落
- {
- case 'w'://飞行
- if (fly_down == 0)
- {
- place = 'w';
- //动作轮换
- n++;
- if (n >= 4)
- {
- n = 0;
- }
- //飞行操作
- if (y > 250)
- {
- y -= 25;
- break;
- }
- }
- else
- {
- break;
- }
- case 's'://降落操作
- place = 's';
- //动作轮换
- n++;
- if (n >= 4)
- {
- n = 0;
- }
- //飞行操作
- if (y <= 450)
- {
- y += 15;
- break;
- }
- break;
- }
- }
- else if (ch1 == ' ')
- {
- HWND gamewindow = GetHWnd();//获取窗口句柄
- SetWindowText(gamewindow, "小命要紧");//设置窗口标题
- next_step = zanting(gamewindow);
- if (next_step == 1)
- {
- break;
- }
- }
- else//行走键或无效键位
- {
- switch (ch1)//判断行走键或无效键位
- {
- case 'a'://左走键
- case 'A':
- place = 'a';
- //历史键位轮换
- ch2 = 'a';
- next1 = k1;
- next2 = k2;
- k1 = 'a';
- k2 = next1;
- k3 = next2;
- //动作轮换
- n++;
- if (n >= 4)
- {
- n = 0;
- }
- //左走操作
- if (x >= 25)
- {
- x -= 20;
- break;
- }
- break;
-
- case 'd'://右走键
- case 'D':
- place = 'd';
- //历史键位轮换
- ch2 = 'd';
- next1 = k1;
- next2 = k2;
- k1 = 'd';
- k2 = next1;
- k3 = next2;
- //动作轮换
- n++;
- if (n >= 4)
- {
- n = 0;
- }
- //左走操作
- if (x <= 730)
- {
- x += 20;
- break;
- }
- break;
- default://无效键位
- break;//退出
- }
-
- }
- }
- //游戏内引力作用
- if (y <= 460)
- {
- y += gravity;
- }
- //跳跃冷却时间减小
- if (m > 0)
- {
- m--;
- }
- //判断沙奈朵是否站在支撑点位
- y = check_top(x, y);
-
- FlushBatchDraw();//结束绘画
- //判定碰撞
- //天空龙1
- if (check_next1 == 0)//非无敌时间
- {
- check_end1 = check_lose_blood(x, y, npc_x1, fly1 * 20);
- if (check_end1 == 1)//发生碰撞
- {
- blood--;//扣血
- //无敌时间,小怪无伤
- check_next1 = 10;
- check_next2 = 10;
- check_next3 = 10;
- check_next4 = 10;
- }
- }
- //天空龙2
- if (check_next2 == 0)//非无敌时间
- {
- check_end2 = check_lose_blood(x, y, npc_x2, fly2 * 10);
- if (check_end2 == 1)//发生碰撞
- {
- blood--;//扣血
- //无敌时间,小怪无伤
- check_next1 = 10;
- check_next2 = 10;
- check_next3 = 10;
- check_next4 = 10;
- }
- }
- //天空龙3
- if (check_next3 == 0)//非无敌时间
- {
- check_end3 = check_lose_blood_cm(x, y, 710 - fly3 * 20, npc_y3);
- if (check_end3 == 1)//发生碰撞
- {
- blood--;//扣血
- //无敌时间,小怪无伤
- check_next1 = 10;
- check_next2 = 10;
- check_next3 = 10;
- check_next4 = 10;
- }
- }
- //喷火龙
- if (check_next4 == 0)//非无敌时间
- {
- check_end4 = check_lose_blood_g(x, y, fly4 * 20, npc_y4);
- if (check_end4 == 1)//发生碰撞
- {
- blood--;//扣血
- //无敌时间,小怪无伤
- check_next1 = 10;
- check_next2 = 10;
- check_next3 = 10;
- check_next4 = 10;
- }
- }
- //判断无敌时间长短
- if (check_next1 > 0)
- {
- //无敌时间减少
- check_next1--;
- check_next2--;
- check_next3--;
- check_next4--;
- }
- //判断是否死亡
- if (blood == 0)//血条清零
- {
- Sleep(1000);//暂停游戏
- return 0;//回到游戏开始界面
- }
- //判断游戏胜利
- //皮卡丘
- huifu++;
- check_end5 = check_victory(x, y, fly5 * sudu, npc_y5);
- if (huifu > 100)
- {
- switch (check_end5)//发生碰撞
- {
- case 0:
- Sleep(1000);
- return 1;
- case 1:
- break;
- }
- }
- Sleep(75);//移动间断时间(ms)
- }
- return 0;
- }
- void change_window()//难度窗口
- {
-
- while (1)
- {
- BeginBatchDraw();//开始绘画
- IMAGE game_nd_bk;
- loadimage(&game_nd_bk, _T("game_nd_bk.png"), window_length, window_width);//设置背景
- putimage(0, 0, &game_nd_bk);
- nomal_botton(25, 60, 200, 110, "有手进行");//第一个按钮
- nomal_botton(25, 150, 200, 200, "就这水平");//第二个按钮
- nomal_botton(25, 240, 200, 290, "有的东西");//第三个按钮
- nomal_botton(25, 330, 200, 380, "有亿点难");//第四个按钮
- FlushBatchDraw();//暂停绘画
- differ = select_differ();
- switch (differ)
- {
- case 0:
- fly_down = 0;
- gravity = 5;
- sudu = 20;
- return;
- case 1:
- fly_down = 0;
- gravity = 5;
- sudu = 40;
- return;
- case 2:
- fly_down = 0;
- gravity = 10;
- sudu = 40;
- return;
- case 3:
- fly_down = 1;
- gravity = 5;
- sudu = 40;
- return;
- default:
- break;
- }
- }
- return;
- }
- void introduce_window()//游戏介绍窗口
- {
- int back;
- while (1)
- {
- BeginBatchDraw();//开始绘画
- IMAGE game_js_bk;
- loadimage(&game_js_bk, _T("game_js_bk.png"));//设置背景
- putimage(0, 0, &game_js_bk);
- nomal_botton(650, 500, 750, 550, "");//第一个按钮
-
- FlushBatchDraw();//停止绘画
-
- back = return_back();
- if (back == 4)
- {
- return;
- }
- }
- return;
- }
-
- void victory_window()//游戏结束,获得胜利
- {
- int back;
- char record[50];
- while (1)
- {
- BeginBatchDraw();//开始绘画
- IMAGE victory_bk;
- loadimage(&victory_bk, _T("victory_bk.png"), window_length, window_width);//设置背景
- putimage(0, 0, &victory_bk);
-
- _itoa(now, record, 10);
- //设置按钮
- nomal_botton(650, 500, 750, 550, "返回");//第一个按钮
- //输出记录
- nomal_botton(610, 440, 710, 510, "记录:");
- nomal_botton(680, 440, 780, 510, record);
-
- FlushBatchDraw();//停止绘画
-
- back = return_back();
- if (back == 4)
- {
- return;
- }
- }
-
- return;
- }
- void yun1()//大云朵
- {
- IMAGE yun_zcd1, yun_zcd2;
- //获取大云朵
- loadimage(&yun_zcd1, "yun_zcd1.png", 140, 30);
- loadimage(&yun_zcd2, "yun_zcd2.png", 140, 30);
- //云1
- putimage(180, 250, &yun_zcd2, SRCAND);
- putimage(180, 250, &yun_zcd1, SRCPAINT);
- //云2
- putimage(645, 440, &yun_zcd2, SRCAND);
- putimage(645, 440, &yun_zcd1, SRCPAINT);
- //云3
- putimage(420, 120, &yun_zcd2, SRCAND);
- putimage(420, 120, &yun_zcd1, SRCPAINT);
- return;
- }
-
-
- void yun2()//中云朵
- {
- IMAGE yun_yuan1, yun_bk1;
- //获取中云朵
- loadimage(&yun_yuan1, ("yun1.jpg"), 70, 35);
- loadimage(&yun_bk1, ("yun2.jpg"), 70, 35);
- //云1
- putimage(35, 350, &yun_bk1, SRCAND);
- putimage(35, 350, &yun_yuan1, SRCPAINT);
- //云2
- putimage(550, 330, &yun_bk1, SRCAND);
- putimage(550, 330, &yun_yuan1, SRCPAINT);
- //云3
- putimage(720, 280, &yun_bk1, SRCAND);
- putimage(720, 280, &yun_yuan1, SRCPAINT);
- //云4
- putimage(35, 160, &yun_bk1, SRCAND);
- putimage(35, 160, &yun_yuan1, SRCPAINT);
- return;
- }
-
-
- void yun3()//小云朵
- {
- IMAGE yun_yuan2, yun_bk2;
- //获取小云朵
- loadimage(&yun_yuan2, _T("yun1.jpg"), 40, 40);
- loadimage(&yun_bk2, _T("yun2.jpg"), 40, 40);
- //云1
- putimage(150, 420, &yun_bk2, SRCAND);
- putimage(150, 420, &yun_yuan2, SRCPAINT);
- //云2
- putimage(350, 180, &yun_bk2, SRCAND);
- putimage(350, 180, &yun_yuan2, SRCPAINT);
- //云3
- putimage(640, 200, &yun_bk2, SRCAND);
- putimage(640, 200, &yun_yuan2, SRCPAINT);
- //云4
- putimage(380, 410, &yun_bk2, SRCAND);
- putimage(380, 410, &yun_yuan2, SRCPAINT);
- return;
- }
- int check_top(int x, int y)//判断沙奈朵是否位于支撑点位
- {
- if (y < 200 && y > 150 && x > 140 && x < 280)//yun1.1
- {
- y = 170;//使不下落
- return y;
- }
- if (y < 380 && y > 340 && x > 605 && x < 745)//yun1.2
- {
- y = 360;//使不下落
- return y;
- }
- if (y < 60 && y > 20 && x > 380 && x < 520)//yun1.3
- {
- y = 40;//使不下落
- return y;
- }
- else if (y > 250 && y < 290 && x>0 && x < 80)//yun2.1
- {
- y = 270;//使不下落
- return y;
- }
- else if (y > 230 && y < 270 && x>515 && x < 600)//yun2.2
- {
- y = 250;//使不下落
- return y;
- }
- else if (y > 180 && y < 220 && x>685 && x < 750)//yun2.3
- {
- y = 200;//使不下落
- return y;
- }
- else if (y > 60 && y < 100 && x>0 && x < 65)//yun2.4
- {
- y = 80;//使不下落
- return y;
- }
- else if (y > 320 && y < 360 && x>110 && x < 150)//yun3.1
- {
- y = 340;//使不下落
- return y;
- }
- else if (y > 80 && y < 120 && x>310 && x < 350)//yun3.2
- {
- y = 100;//使不下落
- return y;
- }
- else if (y > 100 && y < 140 && x>600 && x < 640)//yun3.3
- {
- y = 120;//使不下落
- return y;
- }
- else if (y > 310 && y < 350 && x>340 && x < 380)//yun3.4
- {
- y = 330;//使不下落
- return y;
- }
- return y;
- }
- void game_time(int now)//显示游戏时间
- {
- setbkmode(TRANSPARENT);//设置字体背景透明
- char lingshi_text[50];//当前时间载体
- _itoa(now, lingshi_text, 10);//转化整型时间为字符串
- settextstyle(30, 15, "楷体");//设置字体
- settextcolor(BLACK);
- int text_x = 380;//内容横坐标
- int text_y = 0;//内容纵坐标
- outtextxy(text_x, text_y, lingshi_text);//输出时间
- return;
- }
-
-
- int gettime(clock_t start)//获得时间
- {
- clock_t end;
- int now;
- double now1;
- end = clock();//获取过去时间
- now1 = (double)(end - start) / CLOCKS_PER_SEC;//获取游戏开始时间
- now = int(now1);//转化为整数
- return now;//返回当前时间
-
- }
- void xuetiao(int blood)//血条
- {
- IMAGE tx, tx_bk, xt_k, xt_k_bk, xt_y, xt_y_bk, xt_er, xt_er_bk, xt_s, xt_s_bk;
- //头像
- loadimage(&tx, "tx.png", 55, 40);
- loadimage(&tx_bk, "tx_bk.png", 55, 40);
- //空血
- loadimage(&xt_k, "xt_k.png", 180, 20);
- loadimage(&xt_k_bk, "xt_k_bk.png", 180, 20);
- //一血
- loadimage(&xt_y, "xt_y.png", 180, 20);
- loadimage(&xt_y_bk, "xt_y_bk.png", 180, 20);
- //二血
- loadimage(&xt_er, "xt_er.png", 180, 20);
- loadimage(&xt_er_bk, "xt_er_bk.png", 180, 20);
- //三血(满血)
- loadimage(&xt_s, "xt_s.png", 180, 20);
- loadimage(&xt_s_bk, "xt_s_bk.png", 180, 20);
- //判断血量图
- switch (blood)
- {
- case 3://满血
- putimage(30, 0, &tx_bk, SRCAND);
- putimage(30, 0, &tx, SRCPAINT);
- putimage(90, 20, &xt_s_bk, SRCAND);
- putimage(90, 20, &xt_s, SRCPAINT);
- return;
- case 2://二血
- putimage(30, 0, &tx_bk, SRCAND);
- putimage(30, 0, &tx, SRCPAINT);
- putimage(90, 20, &xt_er_bk, SRCAND);
- putimage(90, 20, &xt_er, SRCPAINT);
- return;
- case 1://一血
- putimage(30, 0, &tx_bk, SRCAND);
- putimage(30, 0, &tx, SRCPAINT);
- putimage(90, 20, &xt_y_bk, SRCAND);
- putimage(90, 20, &xt_y, SRCPAINT);
- return;
- case 0://空血
- putimage(30, 0, &tx_bk, SRCAND);
- putimage(30, 0, &tx, SRCPAINT);
- putimage(90, 20, &xt_k_bk, SRCAND);
- putimage(90, 20, &xt_k, SRCPAINT);
- return;
- }
- }
- void top_npc1(int fly1, int space1, int npc_x1)//天空龙 1
- {
- IMAGE npc1, npc1_bk;
- //获取天空龙
- loadimage(&npc1, "top_npc1.png", 180, 70);
- loadimage(&npc1_bk, "top_npc1_bk.png", 180, 70);
- putimage(npc_x1, fly1 * 10, 90, 120, &npc1_bk, space1 * 85, 0, SRCAND);
- putimage(npc_x1, fly1 * 10, 90, 120, &npc1, space1 * 85, 0, SRCPAINT);
- return;
- }
-
-
- void top_npc2(int fly2, int space2, int npc_x2)//天空龙 2
- {
- IMAGE npc1, npc1_bk;
- //获取天空龙
- loadimage(&npc1, "top_npc1.png", 180, 70);
- loadimage(&npc1_bk, "top_npc1_bk.png", 180, 70);
- putimage(npc_x2, fly2 * 10, 90, 120, &npc1_bk, space2 * 85, 0, SRCAND);
- putimage(npc_x2, fly2 * 10, 90, 120, &npc1, space2 * 85, 0, SRCPAINT);
- return;
- }
-
-
- void right_npc(int fly3, int space3, int npc_y3)//天空龙 3
- {
- IMAGE npc, npc_bk;
- //获取天空龙
- loadimage(&npc, "left_npc.png", 360, 70);
- loadimage(&npc_bk, "left_npc_bk.png", 360, 70);
- putimage(710 - fly3 * 20, npc_y3, 90, 120, &npc_bk, space3 * 90, 0, SRCAND);
- putimage(710 - fly3 * 20, npc_y3, 90, 120, &npc, space3 * 90, 0, SRCPAINT);
- return;
- }
-
-
- void ground_npc(int fly4, int space4, int npc_y4)//喷火龙
- {
- IMAGE npc, npc_bk;
- //获取喷火龙
- loadimage(&npc, "ground_npc.png", 360, 70);
- loadimage(&npc_bk, "ground_npc_bk.png", 360, 70);
- putimage(fly4 * 20, npc_y4, 90, 120, &npc_bk, space4 * 90, 0, SRCAND);
- putimage(fly4 * 20, npc_y4, 90, 120, &npc, space4 * 90, 0, SRCPAINT);
- return;
- }
- void end_pkq(int fly5, int space5, int npc_y5)//皮卡丘——结束道具
- {
- IMAGE npc1, npc_bk1, npc2, npc_bk2, npc3, npc_bk3;
- //获取皮卡丘
- loadimage(&npc1, "pkq1.png", 50, 40);
- loadimage(&npc_bk1, "pkq2.png", 50, 40);
- loadimage(&npc2, "pkq3.png", 50, 40);
- loadimage(&npc_bk2, "pkq4.png", 50, 40);
- loadimage(&npc3, "pkq5.png", 50, 40);
- loadimage(&npc_bk3, "pkq6.png", 50, 40);
- switch (space5)
- {
- case 0:
- case 2:
- putimage(fly5 * sudu, npc_y5, &npc_bk1, SRCAND);
- putimage(fly5 * sudu, npc_y5, &npc1, SRCPAINT);
- break;
- case 1:
- putimage(fly5 * sudu, npc_y5, &npc_bk2, SRCAND);
- putimage(fly5 * sudu, npc_y5, &npc2, SRCPAINT);
- break;
- case 3:
- putimage(fly5 * sudu, npc_y5, &npc_bk3, SRCAND);
- putimage(fly5 * sudu, npc_y5, &npc3, SRCPAINT);
- break;
- }
- return;
- }
- int check_lose_blood_cm(int x, int y, int npc_x, int npc_y)//判定扣血——天空龙
- {
- //中心坐标
- int snd_center_x, snd_center_y, npc_center_x, npc_center_y;
- int a, b;
- //确定中心
- snd_center_x = x + 35;
- snd_center_y = y + 40;
- npc_center_x = npc_x + 45;
- npc_center_y = npc_y + 35;
- //判断位置以及碰撞关系
- if (snd_center_x < npc_center_x)//判断横坐标
- {
- if (snd_center_y < npc_center_y)//判断纵坐标
- {
- a = npc_center_x - snd_center_x;
- b = npc_center_y - snd_center_y;
- if (a < 40 && b < 50)//发生碰撞
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
- else if (snd_center_y > npc_center_y)//判断纵坐标
- {
- a = npc_center_x - snd_center_x;
- b = snd_center_y - npc_center_y;
- if (a < 40 && b < 50)//发生碰撞
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
-
- }
- else if (snd_center_x > npc_center_x)//判断横坐标
- {
- if (snd_center_y < npc_center_y)//判断纵坐标
- {
- a = snd_center_x - npc_center_x;
- b = npc_center_y - snd_center_y;
- if (a < 40 && b < 50)//发生碰撞
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
- else if (snd_center_y > npc_center_y)//判断纵坐标
- {
- a = snd_center_x - npc_center_x;
- b = snd_center_y - npc_center_y;
- if (a < 40 && b < 50)//发生碰撞
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
-
- }
- return 0;
- }
-
-
- int check_lose_blood_g(int x, int y, int npc_x, int npc_y)//判定扣血——喷火龙
- {
- //中心坐标
- int snd_center_x, snd_center_y, npc_center_x, npc_center_y;
- int a, b;
- //确定中心
- snd_center_x = x + 35;
- snd_center_y = y + 40;
- npc_center_x = npc_x + 45;
- npc_center_y = npc_y + 35;
- //判断位置以及碰撞关系
- if (snd_center_x < npc_center_x)//判断横坐标
- {
- if (snd_center_y < npc_center_y)//判断纵坐标
- {
- a = npc_center_x - snd_center_x;
- b = npc_center_y - snd_center_y;
- if (a < 60 && b < 60)//发生碰撞
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
- else if (snd_center_y > npc_center_y)//判断纵坐标
- {
- a = npc_center_x - snd_center_x;
- b = snd_center_y - npc_center_y;
- if (a < 60 && b < 60)//发生碰撞
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
-
- }
- else if (snd_center_x > npc_center_x)//判断横坐标
- {
- if (snd_center_y < npc_center_y)//判断纵坐标
- {
- a = snd_center_x - npc_center_x;
- b = npc_center_y - snd_center_y;
- if (a < 30 && b < 60)//发生碰撞
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
- else if (snd_center_y > npc_center_y)//判断纵坐标
- {
- a = snd_center_x - npc_center_x;
- b = snd_center_y - npc_center_y;
- if (a < 60 && b < 60)//发生碰撞
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
-
- }
- return 0;
- }
- int check_victory(int x, int y, int npc_x, int npc_y)//判定游戏胜利
- {
- //中心坐标
- int snd_center_x, snd_center_y, npc_center_x, npc_center_y;
- int a, b;
- //确定中心
- snd_center_x = x + 35;
- snd_center_y = y + 40;
- npc_center_x = npc_x + 25;
- npc_center_y = npc_y + 20;
- //判断位置以及碰撞关系
- if (snd_center_x < npc_center_x)//判断横坐标
- {
- if (snd_center_y < npc_center_y)//判断纵坐标
- {
- a = npc_center_x - snd_center_x;
- b = npc_center_y - snd_center_y;
- if (a < 30 && b < 30)//发生碰撞
- {
- return 0;
- }
- else
- {
- return 1;
- }
- }
- else if (snd_center_y > npc_center_y)//判断纵坐标
- {
- a = npc_center_x - snd_center_x;
- b = snd_center_y - npc_center_y;
- if (a < 30 && b < 30)//发生碰撞
- {
- return 0;
- }
- else
- {
- return 1;
- }
- }
-
- }
- else if (snd_center_x > npc_center_x)//判断横坐标
- {
- if (snd_center_y < npc_center_y)//判断纵坐标
- {
- a = snd_center_x - npc_center_x;
- b = npc_center_y - snd_center_y;
- if (a < 30 && b < 30)//发生碰撞
- {
- return 0;
- }
- else
- {
- return 1;
- }
- }
- else if (snd_center_y > npc_center_y)//判断纵坐标
- {
- a = snd_center_x - npc_center_x;
- b = snd_center_y - npc_center_y;
- if (a < 30 && b < 30)//发生碰撞
- {
- return 0;
- }
- else
- {
- return 1;
- }
- }
-
- }
- return 0;
- }
- int zanting(HWND gamewindow)//游戏暂停
- {
- int next_step;
- int answer = MessageBox(gamewindow, "是否继续游戏?", "小命要紧", MB_OKCANCEL);//添加选择框内容
- if (answer == IDOK)//继续游戏
- {
- next_step = 0;
- return next_step;;
-
- }
- else if (answer == IDCANCEL)//回到开始界面
- {
- next_step = 1;
- return next_step;;
- }
-
- }
- void nomal_botton(int left, int top, int right, int bottom, const char* text)//正常状态按钮
- {
- setbkmode(TRANSPARENT);//设置字体背景透明
-
-
- char lingshi_text[50] = { 0 };//按钮内容
- strcpy(lingshi_text, text);//获取内容
- settextstyle(20, 20, "宋体");//设置字体
- settextcolor(BLACK);
- int text_x = left + (right - left - textwidth(lingshi_text)) / 2;//内容横坐标
- int text_y = top + (bottom - top - textheight(lingshi_text)) / 2;//内容纵坐标
- outtextxy(text_x, text_y, lingshi_text);
- }
- void abnomal_botton(int left, int top, int right, int bottom)//选中状态按钮
- {
- BeginBatchDraw();
- setlinecolor(BLACK);//设置线条颜色
- setlinestyle(PS_SOLID, 1);//设置线条类型
- roundrect(left, top, right, bottom, 10, 10);//设置按钮
- FlushBatchDraw();
- }
- int select()//点击选项模块
- {
- ExMessage msg;
- while (1)
- {
- if (peekmessage(&msg, EM_MOUSE))//获取鼠标点击信息
- {
- switch (msg.message)//判断点击信息
- {
- case WM_LBUTTONDOWN://开始游戏
- if (msg.x > 25 && msg.x < 200 && msg.y>100 && msg.y < 150)
- {
- abnomal_botton(25, 100, 200, 150);//点击后按钮状态
- Sleep(500);
- return 0;
- }
- else if (msg.x > 25 && msg.x < 200 && msg.y>200 && msg.y < 250)//选择难度模式
- {
- abnomal_botton(25, 200, 200, 250);//点击后按钮状态
- Sleep(500);
- return 1;
- }
- else if (msg.x > 25 && msg.x < 200 && msg.y>300 && msg.y < 350)//游戏介绍
- {
- abnomal_botton(25, 300, 200, 350);//点击后按钮状态
- Sleep(500);
- return 3;
- }
- else if (msg.x > 20 && msg.x < 200 && msg.y>400 && msg.y < 450)//退出游戏
- {
- abnomal_botton(25, 400, 200, 450);//点击后按钮状态
- Sleep(500);
- return 4;
- }
- default:
- return 5;
- }
-
- }
- }
游戏介绍点击返回事件
- int return_back()//游戏介绍返回点击
- {
-
- ExMessage msg;
- while (1)
- {
- if (peekmessage(&msg, EM_MOUSE))//获取鼠标点击信息
- {
- switch (msg.message)//判断点击信息
- {
- case WM_LBUTTONDOWN://开始游戏
- if (msg.x > 550 && msg.x < 750 && msg.y>350 && msg.y < 550)
- {
- abnomal_botton(650, 500, 750, 550);//点击后按钮状态
- Sleep(500);
- return 4;
- }
-
- default:
- return 5;
- }
- }
- }
- }
- int select_differ()//难度选择
- {
- ExMessage msg;
- while (1)
- {
- if (peekmessage(&msg, EM_MOUSE))//获取鼠标点击信息
- {
- switch (msg.message)//判断点击信息
- {
- case WM_LBUTTONDOWN://开始游戏
- if (msg.x > 25 && msg.x < 200 && msg.y>60 && msg.y < 110)
- {
- abnomal_botton(25, 60, 200, 110);//点击后按钮状态
- Sleep(500);
- return 0;
- }
- else if (msg.x > 25 && msg.x < 200 && msg.y>150 && msg.y < 200)//选择难度模式
- {
- abnomal_botton(25, 150, 200, 200);//点击后按钮状态
- Sleep(500);
- return 1;
- }
- else if (msg.x > 25 && msg.x < 200 && msg.y>240 && msg.y < 290)//游戏介绍
- {
- abnomal_botton(25, 240, 200, 290);//点击后按钮状态
- Sleep(500);
- return 2;
- }
- else if (msg.x > 20 && msg.x < 200 && msg.y>330 && msg.y < 380)//退出游戏
- {
- abnomal_botton(25, 330, 200, 380);//点击后按钮状态
- Sleep(500);
- return 3;
- }
- default:
- return 4;
- }
-
- }
- }
- }
- void menu(int choice, HWND startwindow)//菜单中转
- {
- switch (choice)
- {
- case 0://开始游戏
- int result;
- running_window();
- cleardevice();
- result = game_window();
- if (result == 0)
- {
-
- start_window();
- }
- else if (result == 1)
- {
-
- victory_window();
- }
- return;
- case 1://选择模式
- change_window();
- return;
- case 3://游戏简介
- introduce_window();
- return;
- case 4://退出游戏
- end_mode(startwindow);
- start_window();
- return;
- case 5:
- return;
- }
- }
- void running(int i, int lunhuan)//进度条
- {
- //进度条
- IMAGE a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16;
- //皮卡丘
- IMAGE g1, g2, g3, g4, g7, g8;
- //获取资源
- //进度条
- loadimage(&a1, _T("jdt1.png"), 750, 40);
- loadimage(&a2, _T("jdt2.png"), 750, 40);
- loadimage(&a3, _T("jdt3.png"), 750, 40);
- loadimage(&a4, _T("jdt4.png"), 750, 40);
- loadimage(&a5, _T("jdt5.png"), 750, 40);
- loadimage(&a6, _T("jdt6.png"), 750, 40);
- loadimage(&a7, _T("jdt7.png"), 750, 40);
- loadimage(&a8, _T("jdt8.png"), 750, 40);
- loadimage(&a9, _T("jdt9.png"), 750, 40);
- loadimage(&a10, _T("jdt10.png"), 750, 40);
- loadimage(&a11, _T("jdt11.png"), 750, 40);
- loadimage(&a12, _T("jdt12.png"), 750, 40);
- loadimage(&a15, _T("jdt15.png"), 750, 40);
- loadimage(&a16, _T("jdt16.png"), 750, 40);
- loadimage(&a13, _T("jdt13.png"), 750, 40);
- loadimage(&a14, _T("jdt14.png"), 750, 40);
- //皮卡丘
- loadimage(&g1, _T("pkq1.png"), 70, 60);
- loadimage(&g2, _T("pkq2.png"), 70, 60);
- loadimage(&g3, _T("pkq3.png"), 70, 60);
- loadimage(&g4, _T("pkq4.png"), 70, 60);
- loadimage(&g7, _T("pkq5.png"), 70, 60);
- loadimage(&g8, _T("pkq6.png"), 70, 60);
-
- switch (i)//判断进程
- {
- case 1:
- if (lunhuan == 0 || lunhuan == 2)
- {
- putimage(35, 520, &a2, SRCAND);//添加位运算宏
- putimage(35, 520, &a1, SRCPAINT);
- putimage(25, 500, &g2, SRCAND);//添加位运算宏
- putimage(25, 500, &g1, SRCPAINT);
- break;
- }
- else if (lunhuan == 1)
- {
- putimage(35, 520, &a2, SRCAND);//添加位运算宏
- putimage(35, 520, &a1, SRCPAINT);
- putimage(25, 500, &g4, SRCAND);//添加位运算宏
- putimage(25, 500, &g3, SRCPAINT);
- break;
- }
- else if (lunhuan == 3)
- {
- putimage(35, 520, &a2, SRCAND);//添加位运算宏
- putimage(35, 520, &a1, SRCPAINT);
- putimage(25, 500, &g8, SRCAND);//添加位运算宏
- putimage(25, 500, &g7, SRCPAINT);
- break;
- }
- case 2:
- if (lunhuan == 0 || lunhuan == 2)
- {
- putimage(35, 520, &a4, SRCAND);//添加位运算宏
- putimage(35, 520, &a3, SRCPAINT);
- putimage(60, 500, &g2, SRCAND);//添加位运算宏
- putimage(60, 500, &g1, SRCPAINT);
- break;
- }
- else if (lunhuan == 1)
- {
- putimage(35, 520, &a4, SRCAND);//添加位运算宏
- putimage(35, 520, &a3, SRCPAINT);
- putimage(60, 500, &g4, SRCAND);//添加位运算宏
- putimage(60, 500, &g3, SRCPAINT);
- break;
- }
- else if (lunhuan == 3)
- {
- putimage(35, 520, &a4, SRCAND);//添加位运算宏
- putimage(35, 520, &a3, SRCPAINT);
- putimage(60, 500, &g8, SRCAND);//添加位运算宏
- putimage(60, 500, &g7, SRCPAINT);
- break;
- }
- case 3:
- if (lunhuan == 0 || lunhuan == 2)
- {
- putimage(35, 520, &a6, SRCAND);//添加位运算宏
- putimage(35, 520, &a5, SRCPAINT);
- putimage(110, 500, &g2, SRCAND);//添加位运算宏
- putimage(110, 500, &g1, SRCPAINT);
- break;
- }
- else if (lunhuan == 1)
- {
- putimage(35, 520, &a6, SRCAND);//添加位运算宏
- putimage(35, 520, &a5, SRCPAINT);
- putimage(110, 500, &g4, SRCAND);//添加位运算宏
- putimage(110, 500, &g3, SRCPAINT);
- break;
- }
- else if (lunhuan == 3)
- {
- putimage(35, 520, &a6, SRCAND);//添加位运算宏
- putimage(35, 520, &a5, SRCPAINT);
- putimage(110, 500, &g8, SRCAND);//添加位运算宏
- putimage(110, 500, &g7, SRCPAINT);
- break;
- }
- case 4:
- if (lunhuan == 0 || lunhuan == 2)
- {
- putimage(35, 520, &a8, SRCAND);//添加位运算宏
- putimage(35, 520, &a7, SRCPAINT);
- putimage(180, 500, &g2, SRCAND);//添加位运算宏
- putimage(180, 500, &g1, SRCPAINT);
- break;
- }
- else if (lunhuan == 1)
- {
- putimage(35, 520, &a8, SRCAND);//添加位运算宏
- putimage(35, 520, &a7, SRCPAINT);
- putimage(180, 500, &g4, SRCAND);//添加位运算宏
- putimage(180, 500, &g3, SRCPAINT);
- break;
- }
- else if (lunhuan == 1)
- {
- putimage(35, 520, &a8, SRCAND);//添加位运算宏
- putimage(35, 520, &a7, SRCPAINT);
- putimage(180, 500, &g8, SRCAND);//添加位运算宏
- putimage(180, 500, &g7, SRCPAINT);
- break;
- }
- case 5:
- if (lunhuan == 0 || lunhuan == 2)
- {
- putimage(35, 520, &a10, SRCAND);//添加位运算宏
- putimage(35, 520, &a9, SRCPAINT);
- putimage(345, 500, &g2, SRCAND);//添加位运算宏
- putimage(345, 500, &g1, SRCPAINT);
- break;
- }
- else if (lunhuan == 1)
- {
- putimage(35, 520, &a10, SRCAND);//添加位运算宏
- putimage(35, 520, &a9, SRCPAINT);
- putimage(345, 500, &g4, SRCAND);//添加位运算宏
- putimage(345, 500, &g3, SRCPAINT);
- break;
- }
- else if (lunhuan == 3)
- {
- putimage(35, 520, &a10, SRCAND);//添加位运算宏
- putimage(35, 520, &a9, SRCPAINT);
- putimage(345, 500, &g8, SRCAND);//添加位运算宏
- putimage(345, 500, &g7, SRCPAINT);
- break;
- }
- case 6:
- if (lunhuan == 0 || lunhuan == 2)
- {
- putimage(35, 520, &a12, SRCAND);//添加位运算宏
- putimage(35, 520, &a11, SRCPAINT);
- putimage(370, 500, &g2, SRCAND);//添加位运算宏
- putimage(370, 500, &g1, SRCPAINT);
- break;
- }
- else if (lunhuan == 1)
- {
- putimage(35, 520, &a12, SRCAND);//添加位运算宏
- putimage(35, 520, &a11, SRCPAINT);
- putimage(370, 500, &g4, SRCAND);//添加位运算宏
- putimage(370, 500, &g3, SRCPAINT);
- break;
- }
- else if (lunhuan == 3)
- {
- putimage(35, 520, &a12, SRCAND);//添加位运算宏
- putimage(35, 520, &a11, SRCPAINT);
- putimage(370, 500, &g8, SRCAND);//添加位运算宏
- putimage(370, 500, &g7, SRCPAINT);
- break;
- }
- case 7:
- if (lunhuan == 0 || lunhuan == 2)
- {
- putimage(35, 520, &a14, SRCAND);//添加位运算宏
- putimage(35, 520, &a13, SRCPAINT);
- putimage(520, 500, &g2, SRCAND);//添加位运算宏
- putimage(520, 500, &g1, SRCPAINT);
- break;
- }
- else if (lunhuan == 1)
- {
- putimage(35, 520, &a14, SRCAND);//添加位运算宏
- putimage(35, 520, &a13, SRCPAINT);
- putimage(520, 500, &g4, SRCAND);//添加位运算宏
- putimage(520, 500, &g3, SRCPAINT);
- break;
- }
- else if (lunhuan == 3)
- {
- putimage(35, 520, &a14, SRCAND);//添加位运算宏
- putimage(35, 520, &a13, SRCPAINT);
- putimage(520, 500, &g8, SRCAND);//添加位运算宏
- putimage(520, 500, &g7, SRCPAINT);
- break;
- }
- case 8:
- if (lunhuan == 0 || lunhuan == 2)
- {
- putimage(35, 520, &a16, SRCAND);//添加位运算宏
- putimage(35, 520, &a15, SRCPAINT);
- putimage(720, 500, &g2, SRCAND);//添加位运算宏
- putimage(720, 500, &g1, SRCPAINT);
- break;
- }
- else if (lunhuan == 1)
- {
- putimage(35, 520, &a16, SRCAND);//添加位运算宏
- putimage(35, 520, &a15, SRCPAINT);
- putimage(720, 500, &g4, SRCAND);//添加位运算宏
- putimage(720, 500, &g3, SRCPAINT);
- break;
- }
- else if (lunhuan == 3)
- {
- putimage(35, 520, &a16, SRCAND);//添加位运算宏
- putimage(35, 520, &a15, SRCPAINT);
- putimage(720, 500, &g8, SRCAND);//添加位运算宏
- putimage(720, 500, &g7, SRCPAINT);
- break;
- }
- default:
- break;
- }
- }
- int check_jdt(int zhongzhuan)//判断进度条位置,返回决定参数
- {
- if (zhongzhuan < 4)
- {
- i = 1;
- return i;
- }
- else if (zhongzhuan > 3 && zhongzhuan < 8)
- {
- i = 2;
- return i;
- }
- else if (zhongzhuan > 7 && zhongzhuan < 12)
- {
- i = 3;
- return i;
- }
- else if (zhongzhuan > 11 && zhongzhuan < 16)
- {
- i = 4;
- return i;
- }
- else if (zhongzhuan > 15 && zhongzhuan < 20)
- {
- i = 5;
- return i;
- }
- else if (zhongzhuan > 19 && zhongzhuan < 24)
- {
- i = 6;
- return i;
- }
- else if (zhongzhuan > 23 && zhongzhuan < 28)
- {
- i = 7;
- return i;
- }
- else if (zhongzhuan > 27 && zhongzhuan < 32)
- {
- i = 8;
- return i;
- }
- }
游戏总有离开的时候
- void end_mode(HWND startwindow)//结束模块
- {
- int answer = MessageBox(startwindow, "是否结束游戏?", "猫娘乐园", MB_OKCANCEL);//添加选择框内容
- if (answer == IDOK)
- {
- closegraph();//结束游戏
- mciSendString("close bgm.mp3 ", 0, 0, 0);
- exit(-1);
- }
- else if (answer == IDCANCEL)//回到游戏界面
- {
- return;
- }
-
- }
游戏自然少不了BGM
- void music()//背景音乐
- {
- mciSendString("open bgm.mp3 alias BGM", 0, 0, 0);
- mciSendString("play BGM repeat", 0, 0, 0);
- return;
- }
- //主程序
- int main()
- {
- start_window();//加载开始界面
- //游戏开始
- //游戏结束
- return 0;//退出游戏
- }
- #define _CRT_SECURE_NO_WARNINGS 1
- //头文件
- #include<stdio.h>
- #include<stdlib.h>
- #include<graphics.h>
- #include<conio.h>
- #include<time.h>
- #include <iostream>
- #include<mmsystem.h>//包含多媒体设备接口头文件,一定放在graphics.h下面
- #pragma comment(lib,"winmm.lib")//加载静态库
-
-
-
- //定义数据
- #define window_length 820//窗口长度
- #define window_width 600//窗口宽度
- #define juese_height 80//角色高度
- #define juese_width 70//角色宽度
-
-
-
- //自定义函数总览
- //窗口类
- void start_window();//开始窗口
- void running_window();//加载窗口
- int game_window();//游戏窗口
- void change_window();//难度窗口
- void introduce_window();//介绍窗口
- void victory_window();//胜利界面
-
-
- //游戏类
- void yun1();//支撑物1
- void yun2();//支撑物2
- void yun3();//支撑物3
- int check_top(int x, int y);//判定——上方
- void game_time(int now);//计时
- int gettime(clock_t start);
- void xuetiao(int blood);//血条
- void top_npc1(int fly1, int space1, int npc_x1);//天空龙 1
- void top_npc2(int fly2, int space2, int npc_x2);//天空龙 2
- void right_npc(int fly3, int space3, int npc_y3);//天空龙 3
- void ground_npc(int fly4, int space4, int npc_y4);//喷火龙
- void end_pkq(int fly5, int space5, int npc_y5);//结束道具
- int check_lose_blood(int x, int y, int npc_x, int npc_y);//判定扣血
- int check_lose_blood_cm(int x, int y, int npc_x, int npc_y);//判定扣血
- int check_lose_blood_g(int x, int y, int npc_x, int npc_y);//判定扣血
- int check_victory(int x, int y, int npc_x, int npc_y);//判定游戏胜利
- int zanting(HWND gamewindow);//游戏暂停
-
-
- //模块类
- void nomal_botton(int left, int top, int right, int bottom, const char* text);//正常状态按钮
- void abnomal_botton(int left, int top, int right, int bottom);//选中状态按钮
- int select();//点击选项
- int return_back();//返回选项
- int select_differ();//难度选择
- void menu(int choice, HWND start_window);//菜单中转
- void running(int i, int lunhuan);//进度条
- void music();//BGM
- void end_mode(HWND startwindow);//结束模块
- int check_jdt(int zhongzhuan);//进度条动画皮卡丘
-
-
- //全局变量
- int i = 0;//需要临时变量使使用
- int fly_down = 0;//飞行功能
- int gravity = 5;//重力
- int sudu = 20;//移速
- int differ = 0;//难度
- int now = 0;//当前时间
-
- //自定义函数
- // 窗口类
- void start_window()//开始窗口
- {
- music();
- initgraph(window_length, window_width);//启动窗口
- HWND startwindow = GetHWnd();//获取窗口句柄
- SetWindowText(startwindow, "小命要紧");//设置窗口标题
- while (1)
- {
- BeginBatchDraw();
- IMAGE start_bk;
- loadimage(&start_bk, _T("start_bk.png"));//设置背景
- putimage(0, 0, &start_bk);
- //设置按钮
- nomal_botton(25, 100, 200, 150, "开始游戏");//第一个按钮
- nomal_botton(25, 200, 200, 250, "选择难度");//第二个按钮
- nomal_botton(25, 300, 200, 350, "游戏介绍");//第三个按钮
- nomal_botton(25, 400, 200, 450, "退出游戏");//第四个按钮
- FlushBatchDraw();
- //选项循环模式
- int choice;//选项参数
- choice = select();//选择选项
- menu(choice, startwindow);//加载选项
- }
- }
-
-
- void running_window()//加载窗口
- {
- i = 1;
- int zhongzhuan = 0;
- int lunhuan = 0;
- while (1)
- {
- BeginBatchDraw();//开始绘图
- IMAGE running_bk;
- loadimage(&running_bk, _T("running_bk.png"));//设置背景
- putimage(0, 0, &running_bk);
- running(i, lunhuan);
- lunhuan++;
- FlushBatchDraw();//结束绘图
-
- if (i == 8 && lunhuan == 4)//判断皮卡丘动作
- {
-
- Sleep(1000);
- break;
- }
- if (lunhuan >= 4)
- {
- lunhuan = 0;
- }
- zhongzhuan++;
- i = check_jdt(zhongzhuan);//选择进度条进度
-
- Sleep(50);
- }
-
- }
-
-
- int game_window()//游戏窗口
- {
- srand((unsigned)time(NULL));//随机数前置动作
- char place = 'd';//起始方向
- int x = 25;//沙奈朵起始横坐标
- int y = 470;//沙奈朵起始纵坐标
- int n = 0;
- int m = 0;
- int blood = 3;//血条初始血量
- char ch1, ch2 = 'd', k1 = 'd', k2 = 'd', k3 = 'd', next1 = 'd', next2 = 'd';//控制跳跃次数
- clock_t start;//计时容量
- start = clock();//计时开始
- int fly1 = 0, fly2 = 0, fly3 = 0, fly4 = 0, fly5 = 0;//飞行高度
- int space1 = 0, space2 = 0, space3 = 0, space4 = 0, space5 = 0;//飞行动作参数
- int check_end1 = 0, check_end2 = 0, check_end3 = 0, check_end4 = 0, check_end5 = 1;//是否碰撞
- int check_next1 = 20, check_next2 = 20, check_next3 = 20, check_next4 = 20, check_next5 = 20;//判断是否需要扣血
- int lingshi1 = 0, lingshi2 = 0, lingshi3 = 0, lingshi4 = 15, lingshi5 = 400;//判断是否增加上空飞行小怪
- int npc_x1 = rand() % 201 + 30;//起始天空龙1横坐标
- int npc_x2 = rand() % 221 + 410;//起始天空龙2横坐标
- int npc_y3 = rand() % 481 + 0;//起始天空龙3纵坐标
- int npc_y4 = 480;//喷火龙纵坐标
- int npc_y5 = rand() % 411 + 100;//皮卡丘纵坐标
- int next_step = 1;//暂停游戏参数
- int huifu = 0;//BUG修复参数
- while (1)//开始游戏循环
- {
- if (y == 470)//落地刷新跳跃次数
- {
- k1 = 'd';
- k2 = 'd';
- }
- BeginBatchDraw();//开始绘图
- //设置地图
- IMAGE map_bk;//背景
- loadimage(&map_bk, _T("game_bk.png"));
- putimage(0, 0, &map_bk);
- IMAGE yun_yuan1, yun_bk1, yun_yuan2, yun_bk2;//外框
- //底层外框
- loadimage(&yun_yuan1, _T("yun1.jpg"), 50, 25);
- loadimage(&yun_bk1, _T("yun2.jpg"), 50, 25);
- for (i = 10; i < 810; i += 50)
- {
- putimage(i, 550, &yun_bk1, SRCAND);//添加位运算宏
- putimage(i, 550, &yun_yuan1, SRCPAINT);
- }
- //左右外框
- loadimage(&yun_yuan2, _T("yun1.jpg"), 25, 25);
- loadimage(&yun_bk2, _T("yun2.jpg"), 25, 25);
- for (i = 0; i < 530; i += 25)
- {
- putimage(10, i, &yun_bk2, SRCAND);//添加位运算宏
- putimage(10, i, &yun_yuan2, SRCPAINT);
- }
- for (i = 0; i < 530; i += 25)
- {
- putimage(785, i, &yun_bk2, SRCAND);//添加位运算宏
- putimage(785, i, &yun_yuan2, SRCPAINT);
- }
- //支撑点
- yun1();//大云
- yun2();//中云
- yun3();//小云
- //计时
- now = gettime(start);//获取游戏时间
- game_time(now);//显示游戏时间
- //血条
- xuetiao(blood);
- //npc小怪
- //天空龙1
- if (lingshi1 == 0)//判断是否刷新小怪
- {
- if (fly1 < 65)
- {
- top_npc1(fly1, space1, npc_x1);//生成天空龙1
- fly1++;
- space1++;
- if (space1 == 2)//选择动作
- {
- space1 = 0;
- }
- }
- }
- if (fly1 == 60)//天空龙1飞至底部
- {
- lingshi1 = rand() % 9 + 12;//间断生成小怪
- npc_x1 = rand() % 201 + 30;//随机天空龙1生成地点,位于地图左半边
- fly1 = 0;
- }
- if (lingshi1 > 0)//逼近生成时间
- {
- lingshi1--;
- }
- //天空龙2
- if (lingshi2 == 0)//判断是否生成小怪
- {
- if (fly2 < 65)
- {
- top_npc2(fly2, space2, npc_x2);//生成天空龙2
- fly2++;
- space2++;
- if (space2 == 2)//选择动作
- {
- space2 = 0;
- }
- }
- }
- if (fly2 == 60)//天空龙2飞至底部
- {
- lingshi2 = rand() % 9 + 12;//间断小怪生成时间
- npc_x2 = rand() % 221 + 410;//随机产生天空龙2生成地点,位于地图右半边
- fly2 = 0;
- }
- if (lingshi2 > 0)//逼近小怪生成时间
- {
- lingshi2--;
- }
- //天空龙3
- if (lingshi3 == 0)//判断是否生成小怪
- {
- if (fly3 < 50)
- {
- right_npc(fly3, space3, npc_y3);//生成天空龙3
- fly3++;
- space3++;
- if (space3 == 4)//选择动作
- {
- space3 = 0;
- }
- }
- }
- if (fly3 == 41)//天空龙3飞至左边
- {
- lingshi3 = rand() % 6 + 15;//间断小怪生成时间
- npc_y3 = rand() % 481 + 0;//随机产生天空龙3生成地点,位于地图右半边
- fly3 = 0;
- }
- if (lingshi3 > 0)//逼近小怪生成时间
- {
- lingshi3--;
- }
- //喷火龙
- if (lingshi4 == 0)//判断是否生成小怪
- {
- if (fly4 < 50)
- {
- ground_npc(fly4, space4, npc_y4);//生成喷火龙
- fly4++;
- space4++;
- if (space4 == 4)//选择动作
- {
- space4 = 0;
- }
- }
- }
- if (fly4 == 41)//喷火龙走至右边
- {
- lingshi4 = rand() % 6 + 15;//间断小怪生成时间
- fly4 = 0;
- }
- if (lingshi4 > 0)//逼近小怪生成时间
- {
- lingshi4--;
- }
- //皮卡丘
- if (lingshi5 == 0)//判断是否生成小怪
- {
- if (fly5 < 50)
- {
- end_pkq(fly5, space5, npc_y5);//生成皮卡丘
- fly5++;
- space5++;
- if (space5 == 4)//选择动作
- {
- space5 = 0;
- }
- }
- }
- if (fly5 == 41)//皮卡丘走至右边
- {
- lingshi5 = rand() % 51 + 100;//间断小怪生成时间
- npc_y5 = rand() % 411 + 100;
- fly5 = 0;
- }
- if (lingshi5 > 0)//逼近小怪生成时间
- {
- lingshi5--;
- }
- //角色(沙奈朵)
- IMAGE juese1, juese2, juese4, juese3;//沙奈朵行走图
- loadimage(&juese1, "snd1.png", 280, 160);
- loadimage(&juese2, "snd2.png", 280, 160);
- loadimage(&juese3, "snd3.png", 280, 160);
- loadimage(&juese4, "snd4.png", 280, 160);
- switch (ch2)//判定行走动作
- {
- case 'd':
- putimage(x, y, juese_width, juese_height, &juese2, n * juese_width, juese_height, SRCAND);
- putimage(x, y, juese_width, juese_height, &juese1, n * juese_width, juese_height, SRCPAINT);
- break;
- case 'a':
- putimage(x, y, juese_width, juese_height, &juese4, n * juese_width, juese_height, SRCAND);
- putimage(x, y, juese_width, juese_height, &juese3, n * juese_width, juese_height, SRCPAINT);
- break;
- }
- switch (place)//判断飞行降落和跳跃动作
- {
- case 'w'://飞行动作
- switch (ch2)//判断原行动方向
- {
- case 'a':
- putimage(x, y, juese_width, juese_height, &juese4, n * juese_width, juese_height, SRCAND);
- putimage(x, y, juese_width, juese_height, &juese3, n * juese_width, juese_height, SRCPAINT);
- break;
- case 'd':
- putimage(x, y, juese_width, juese_height, &juese2, n * juese_width, juese_height, SRCAND);
- putimage(x, y, juese_width, juese_height, &juese1, n * juese_width, juese_height, SRCPAINT);
- break;
- }
- case 's'://降落动作
- switch (ch2)//判断原行动方向
- {
- case 'a':
- putimage(x, y, juese_width, juese_height, &juese4, n * juese_width, juese_height, SRCAND);
- putimage(x, y, juese_width, juese_height, &juese3, n * juese_width, juese_height, SRCPAINT);
- break;
- case 'd':
- putimage(x, y, juese_width, juese_height, &juese2, n * juese_width, juese_height, SRCAND);
- putimage(x, y, juese_width, juese_height, &juese1, n * juese_width, juese_height, SRCPAINT);
- break;
- }
- case 'k'://跳跃动作
- switch (ch2)//判断原行动方向
- {
- case 'a':
- putimage(x, y, juese_width, juese_height, &juese4, n * juese_width, juese_height, SRCAND);
- putimage(x, y, juese_width, juese_height, &juese3, n * juese_width, juese_height, SRCPAINT);
- break;
- case 'd':
- putimage(x, y, juese_width, juese_height, &juese2, n * juese_width, juese_height, SRCAND);
- putimage(x, y, juese_width, juese_height, &juese1, n * juese_width, juese_height, SRCPAINT);
- break;
- }
- }
-
- if (_kbhit())//判断是否有输入
- {
- ch1 = _getch();//获取输入内容
- if (ch1 == 'k')//跳跃键
- {
- switch (ch1)
- {
- case 'k':
- place = 'k';
- //轮换历史键位
- next1 = k1;
- next2 = k2;
- k1 = 'k';
- k2 = next1;
- k3 = next2;
- //动作更换
- n++;
- if (n >= 4)
- {
- n = 0;
- }
- //判断跳跃次数
- if (y > 0 && k3 != 'k')//可以跳跃
- {
- if (m <= 20)
- {
- m += 20;
- y -= 120;
- break;
- }
- else
- {
- place = 's';
- //轮换动作
- n++;
- if (n >= 4)
- {
- n = 0;
- }
- //下降操作
- if (y <= 450)
- {
- y += 15;
- break;
- }
- }
- }
- else//二段跳后进入冷却
- {
- place = 's';
- //动作轮换
- n++;
- if (n >= 4)
- {
- n = 0;
- }
- //下降操作
- if (y <= 450)
- {
- y += 10;
- break;
- }
- break;
- }
- }
- }
- else if (ch1 == 's' || ch1 == 'w')//飞行键或降落键
- {
- switch (ch1)//判断飞行或降落
- {
- case 'w'://飞行
- if (fly_down == 0)
- {
- place = 'w';
- //动作轮换
- n++;
- if (n >= 4)
- {
- n = 0;
- }
- //飞行操作
- if (y > 250)
- {
- y -= 25;
- break;
- }
- }
- else
- {
- break;
- }
- case 's'://降落操作
- place = 's';
- //动作轮换
- n++;
- if (n >= 4)
- {
- n = 0;
- }
- //飞行操作
- if (y <= 450)
- {
- y += 15;
- break;
- }
- break;
- }
- }
- else if (ch1 == ' ')
- {
- HWND gamewindow = GetHWnd();//获取窗口句柄
- SetWindowText(gamewindow, "小命要紧");//设置窗口标题
- next_step = zanting(gamewindow);
- if (next_step == 1)
- {
- break;
- }
- }
- else//行走键或无效键位
- {
- switch (ch1)//判断行走键或无效键位
- {
- case 'a'://左走键
- case 'A':
- place = 'a';
- //历史键位轮换
- ch2 = 'a';
- next1 = k1;
- next2 = k2;
- k1 = 'a';
- k2 = next1;
- k3 = next2;
- //动作轮换
- n++;
- if (n >= 4)
- {
- n = 0;
- }
- //左走操作
- if (x >= 25)
- {
- x -= 20;
- break;
- }
- break;
-
- case 'd'://右走键
- case 'D':
- place = 'd';
- //历史键位轮换
- ch2 = 'd';
- next1 = k1;
- next2 = k2;
- k1 = 'd';
- k2 = next1;
- k3 = next2;
- //动作轮换
- n++;
- if (n >= 4)
- {
- n = 0;
- }
- //左走操作
- if (x <= 730)
- {
- x += 20;
- break;
- }
- break;
- default://无效键位
- break;//退出
- }
-
- }
- }
- //游戏内引力作用
- if (y <= 460)
- {
- y += gravity;
- }
- //跳跃冷却时间减小
- if (m > 0)
- {
- m--;
- }
- //判断沙奈朵是否站在支撑点位
- y = check_top(x, y);
-
- FlushBatchDraw();//结束绘画
- //判定碰撞
- //天空龙1
- if (check_next1 == 0)//非无敌时间
- {
- check_end1 = check_lose_blood(x, y, npc_x1, fly1 * 20);
- if (check_end1 == 1)//发生碰撞
- {
- blood--;//扣血
- //无敌时间,小怪无伤
- check_next1 = 10;
- check_next2 = 10;
- check_next3 = 10;
- check_next4 = 10;
- }
- }
- //天空龙2
- if (check_next2 == 0)//非无敌时间
- {
- check_end2 = check_lose_blood(x, y, npc_x2, fly2 * 10);
- if (check_end2 == 1)//发生碰撞
- {
- blood--;//扣血
- //无敌时间,小怪无伤
- check_next1 = 10;
- check_next2 = 10;
- check_next3 = 10;
- check_next4 = 10;
- }
- }
- //天空龙3
- if (check_next3 == 0)//非无敌时间
- {
- check_end3 = check_lose_blood_cm(x, y, 710 - fly3 * 20, npc_y3);
- if (check_end3 == 1)//发生碰撞
- {
- blood--;//扣血
- //无敌时间,小怪无伤
- check_next1 = 10;
- check_next2 = 10;
- check_next3 = 10;
- check_next4 = 10;
- }
- }
- //喷火龙
- if (check_next4 == 0)//非无敌时间
- {
- check_end4 = check_lose_blood_g(x, y, fly4 * 20, npc_y4);
- if (check_end4 == 1)//发生碰撞
- {
- blood--;//扣血
- //无敌时间,小怪无伤
- check_next1 = 10;
- check_next2 = 10;
- check_next3 = 10;
- check_next4 = 10;
- }
- }
- //判断无敌时间长短
- if (check_next1 > 0)
- {
- //无敌时间减少
- check_next1--;
- check_next2--;
- check_next3--;
- check_next4--;
- }
- //判断是否死亡
- if (blood == 0)//血条清零
- {
- Sleep(1000);//暂停游戏
- return 0;//回到游戏开始界面
- }
- //判断游戏胜利
- //皮卡丘
- huifu++;
- check_end5 = check_victory(x, y, fly5 * sudu, npc_y5);
- if (huifu > 100)
- {
- switch (check_end5)//发生碰撞
- {
- case 0:
- Sleep(1000);
- return 1;
- case 1:
- break;
- }
- }
- Sleep(75);//移动间断时间(ms)
- }
- return 0;
- }
-
-
- void change_window()//难度窗口
- {
-
- while (1)
- {
- BeginBatchDraw();//开始绘画
- IMAGE game_nd_bk;
- loadimage(&game_nd_bk, _T("game_nd_bk.png"), window_length, window_width);//设置背景
- putimage(0, 0, &game_nd_bk);
- nomal_botton(25, 60, 200, 110, "有手进行");//第一个按钮
- nomal_botton(25, 150, 200, 200, "就这水平");//第二个按钮
- nomal_botton(25, 240, 200, 290, "有的东西");//第三个按钮
- nomal_botton(25, 330, 200, 380, "有亿点难");//第四个按钮
- FlushBatchDraw();//暂停绘画
- differ = select_differ();
- switch (differ)
- {
- case 0:
- fly_down = 0;
- gravity = 5;
- sudu = 20;
- return;
- case 1:
- fly_down = 0;
- gravity = 5;
- sudu = 40;
- return;
- case 2:
- fly_down = 0;
- gravity = 10;
- sudu = 40;
- return;
- case 3:
- fly_down = 1;
- gravity = 5;
- sudu = 40;
- return;
- default:
- break;
- }
- }
- return;
- }
-
-
-
- void introduce_window()//游戏介绍窗口
- {
- int back;
- while (1)
- {
- BeginBatchDraw();//开始绘画
- IMAGE game_js_bk;
- loadimage(&game_js_bk, _T("game_js_bk.png"));//设置背景
- putimage(0, 0, &game_js_bk);
- nomal_botton(650, 500, 750, 550, "");//第一个按钮
-
- FlushBatchDraw();//停止绘画
-
- back = return_back();
- if (back == 4)
- {
- return;
- }
- }
- return;
- }
-
-
- void victory_window()//游戏结束,获得胜利
- {
- int back;
- char record[50];
- while (1)
- {
- BeginBatchDraw();//开始绘画
- IMAGE victory_bk;
- loadimage(&victory_bk, _T("victory_bk.png"), window_length, window_width);//设置背景
- putimage(0, 0, &victory_bk);
-
- _itoa(now, record, 10);
- //设置按钮
- nomal_botton(650, 500, 750, 550, "返回");//第一个按钮
- //输出记录
- nomal_botton(610, 440, 710, 510, "记录:");
- nomal_botton(680, 440, 780, 510, record);
-
- FlushBatchDraw();//停止绘画
-
- back = return_back();
- if (back == 4)
- {
- return;
- }
- }
-
- return;
- }
-
- //游戏类
- void yun1()//大云朵
- {
- IMAGE yun_zcd1, yun_zcd2;
- //获取大云朵
- loadimage(&yun_zcd1, "yun_zcd1.png", 140, 30);
- loadimage(&yun_zcd2, "yun_zcd2.png", 140, 30);
- //云1
- putimage(180, 250, &yun_zcd2, SRCAND);
- putimage(180, 250, &yun_zcd1, SRCPAINT);
- //云2
- putimage(645, 440, &yun_zcd2, SRCAND);
- putimage(645, 440, &yun_zcd1, SRCPAINT);
- //云3
- putimage(420, 120, &yun_zcd2, SRCAND);
- putimage(420, 120, &yun_zcd1, SRCPAINT);
- return;
- }
-
-
- void yun2()//中云朵
- {
- IMAGE yun_yuan1, yun_bk1;
- //获取中云朵
- loadimage(&yun_yuan1, ("yun1.jpg"), 70, 35);
- loadimage(&yun_bk1, ("yun2.jpg"), 70, 35);
- //云1
- putimage(35, 350, &yun_bk1, SRCAND);
- putimage(35, 350, &yun_yuan1, SRCPAINT);
- //云2
- putimage(550, 330, &yun_bk1, SRCAND);
- putimage(550, 330, &yun_yuan1, SRCPAINT);
- //云3
- putimage(720, 280, &yun_bk1, SRCAND);
- putimage(720, 280, &yun_yuan1, SRCPAINT);
- //云4
- putimage(35, 160, &yun_bk1, SRCAND);
- putimage(35, 160, &yun_yuan1, SRCPAINT);
- return;
- }
-
-
- void yun3()//小云朵
- {
- IMAGE yun_yuan2, yun_bk2;
- //获取小云朵
- loadimage(&yun_yuan2, _T("yun1.jpg"), 40, 40);
- loadimage(&yun_bk2, _T("yun2.jpg"), 40, 40);
- //云1
- putimage(150, 420, &yun_bk2, SRCAND);
- putimage(150, 420, &yun_yuan2, SRCPAINT);
- //云2
- putimage(350, 180, &yun_bk2, SRCAND);
- putimage(350, 180, &yun_yuan2, SRCPAINT);
- //云3
- putimage(640, 200, &yun_bk2, SRCAND);
- putimage(640, 200, &yun_yuan2, SRCPAINT);
- //云4
- putimage(380, 410, &yun_bk2, SRCAND);
- putimage(380, 410, &yun_yuan2, SRCPAINT);
- return;
- }
-
-
- int check_top(int x, int y)//判断沙奈朵是否位于支撑点位
- {
- if (y < 200 && y > 150 && x > 140 && x < 280)//yun1.1
- {
- y = 170;//使不下落
- return y;
- }
- if (y < 380 && y > 340 && x > 605 && x < 745)//yun1.2
- {
- y = 360;//使不下落
- return y;
- }
- if (y < 60 && y > 20 && x > 380 && x < 520)//yun1.3
- {
- y = 40;//使不下落
- return y;
- }
- else if (y > 250 && y < 290 && x>0 && x < 80)//yun2.1
- {
- y = 270;//使不下落
- return y;
- }
- else if (y > 230 && y < 270 && x>515 && x < 600)//yun2.2
- {
- y = 250;//使不下落
- return y;
- }
- else if (y > 180 && y < 220 && x>685 && x < 750)//yun2.3
- {
- y = 200;//使不下落
- return y;
- }
- else if (y > 60 && y < 100 && x>0 && x < 65)//yun2.4
- {
- y = 80;//使不下落
- return y;
- }
- else if (y > 320 && y < 360 && x>110 && x < 150)//yun3.1
- {
- y = 340;//使不下落
- return y;
- }
- else if (y > 80 && y < 120 && x>310 && x < 350)//yun3.2
- {
- y = 100;//使不下落
- return y;
- }
- else if (y > 100 && y < 140 && x>600 && x < 640)//yun3.3
- {
- y = 120;//使不下落
- return y;
- }
- else if (y > 310 && y < 350 && x>340 && x < 380)//yun3.4
- {
- y = 330;//使不下落
- return y;
- }
- return y;
- }
-
-
- void game_time(int now)//显示游戏时间
- {
- setbkmode(TRANSPARENT);//设置字体背景透明
- char lingshi_text[50];//当前时间载体
- _itoa(now, lingshi_text, 10);//转化整型时间为字符串
- settextstyle(30, 15, "楷体");//设置字体
- settextcolor(BLACK);
- int text_x = 380;//内容横坐标
- int text_y = 0;//内容纵坐标
- outtextxy(text_x, text_y, lingshi_text);//输出时间
- return;
- }
-
-
- int gettime(clock_t start)//获得时间
- {
- clock_t end;
- int now;
- double now1;
- end = clock();//获取过去时间
- now1 = (double)(end - start) / CLOCKS_PER_SEC;//获取游戏开始时间
- now = int(now1);//转化为整数
- return now;//返回当前时间
-
- }
-
-
- void xuetiao(int blood)//血条
- {
- IMAGE tx, tx_bk, xt_k, xt_k_bk, xt_y, xt_y_bk, xt_er, xt_er_bk, xt_s, xt_s_bk;
- //头像
- loadimage(&tx, "tx.png", 55, 40);
- loadimage(&tx_bk, "tx_bk.png", 55, 40);
- //空血
- loadimage(&xt_k, "xt_k.png", 180, 20);
- loadimage(&xt_k_bk, "xt_k_bk.png", 180, 20);
- //一血
- loadimage(&xt_y, "xt_y.png", 180, 20);
- loadimage(&xt_y_bk, "xt_y_bk.png", 180, 20);
- //二血
- loadimage(&xt_er, "xt_er.png", 180, 20);
- loadimage(&xt_er_bk, "xt_er_bk.png", 180, 20);
- //三血(满血)
- loadimage(&xt_s, "xt_s.png", 180, 20);
- loadimage(&xt_s_bk, "xt_s_bk.png", 180, 20);
- //判断血量图
- switch (blood)
- {
- case 3://满血
- putimage(30, 0, &tx_bk, SRCAND);
- putimage(30, 0, &tx, SRCPAINT);
- putimage(90, 20, &xt_s_bk, SRCAND);
- putimage(90, 20, &xt_s, SRCPAINT);
- return;
- case 2://二血
- putimage(30, 0, &tx_bk, SRCAND);
- putimage(30, 0, &tx, SRCPAINT);
- putimage(90, 20, &xt_er_bk, SRCAND);
- putimage(90, 20, &xt_er, SRCPAINT);
- return;
- case 1://一血
- putimage(30, 0, &tx_bk, SRCAND);
- putimage(30, 0, &tx, SRCPAINT);
- putimage(90, 20, &xt_y_bk, SRCAND);
- putimage(90, 20, &xt_y, SRCPAINT);
- return;
- case 0://空血
- putimage(30, 0, &tx_bk, SRCAND);
- putimage(30, 0, &tx, SRCPAINT);
- putimage(90, 20, &xt_k_bk, SRCAND);
- putimage(90, 20, &xt_k, SRCPAINT);
- return;
- }
- }
-
-
- void top_npc1(int fly1, int space1, int npc_x1)//天空龙 1
- {
- IMAGE npc1, npc1_bk;
- //获取天空龙
- loadimage(&npc1, "top_npc1.png", 180, 70);
- loadimage(&npc1_bk, "top_npc1_bk.png", 180, 70);
- putimage(npc_x1, fly1 * 10, 90, 120, &npc1_bk, space1 * 85, 0, SRCAND);
- putimage(npc_x1, fly1 * 10, 90, 120, &npc1, space1 * 85, 0, SRCPAINT);
- return;
- }
-
-
- void top_npc2(int fly2, int space2, int npc_x2)//天空龙 2
- {
- IMAGE npc1, npc1_bk;
- //获取天空龙
- loadimage(&npc1, "top_npc1.png", 180, 70);
- loadimage(&npc1_bk, "top_npc1_bk.png", 180, 70);
- putimage(npc_x2, fly2 * 10, 90, 120, &npc1_bk, space2 * 85, 0, SRCAND);
- putimage(npc_x2, fly2 * 10, 90, 120, &npc1, space2 * 85, 0, SRCPAINT);
- return;
- }
-
-
- void right_npc(int fly3, int space3, int npc_y3)//天空龙 3
- {
- IMAGE npc, npc_bk;
- //获取天空龙
- loadimage(&npc, "left_npc.png", 360, 70);
- loadimage(&npc_bk, "left_npc_bk.png", 360, 70);
- putimage(710 - fly3 * 20, npc_y3, 90, 120, &npc_bk, space3 * 90, 0, SRCAND);
- putimage(710 - fly3 * 20, npc_y3, 90, 120, &npc, space3 * 90, 0, SRCPAINT);
- return;
- }
-
-
- void ground_npc(int fly4, int space4, int npc_y4)//喷火龙
- {
- IMAGE npc, npc_bk;
- //获取喷火龙
- loadimage(&npc, "ground_npc.png", 360, 70);
- loadimage(&npc_bk, "ground_npc_bk.png", 360, 70);
- putimage(fly4 * 20, npc_y4, 90, 120, &npc_bk, space4 * 90, 0, SRCAND);
- putimage(fly4 * 20, npc_y4, 90, 120, &npc, space4 * 90, 0, SRCPAINT);
- return;
- }
-
-
- void end_pkq(int fly5, int space5, int npc_y5)//皮卡丘——结束道具
- {
- IMAGE npc1, npc_bk1, npc2, npc_bk2, npc3, npc_bk3;
- //获取皮卡丘
- loadimage(&npc1, "pkq1.png", 50, 40);
- loadimage(&npc_bk1, "pkq2.png", 50, 40);
- loadimage(&npc2, "pkq3.png", 50, 40);
- loadimage(&npc_bk2, "pkq4.png", 50, 40);
- loadimage(&npc3, "pkq5.png", 50, 40);
- loadimage(&npc_bk3, "pkq6.png", 50, 40);
- switch (space5)
- {
- case 0:
- case 2:
- putimage(fly5 * sudu, npc_y5, &npc_bk1, SRCAND);
- putimage(fly5 * sudu, npc_y5, &npc1, SRCPAINT);
- break;
- case 1:
- putimage(fly5 * sudu, npc_y5, &npc_bk2, SRCAND);
- putimage(fly5 * sudu, npc_y5, &npc2, SRCPAINT);
- break;
- case 3:
- putimage(fly5 * sudu, npc_y5, &npc_bk3, SRCAND);
- putimage(fly5 * sudu, npc_y5, &npc3, SRCPAINT);
- break;
- }
- return;
- }
-
-
- int check_lose_blood(int x, int y, int npc_x, int npc_y)//判定扣血
- {
- //中心坐标
- int snd_center_x, snd_center_y, npc_center_x, npc_center_y;
- int a, b;
- //确定中心
- snd_center_x = x + 35;
- snd_center_y = y + 40;
- npc_center_x = npc_x + 45;
- npc_center_y = npc_y - 300;
- //判断位置以及碰撞关系
- if (snd_center_x < npc_center_x)//判断横坐标
- {
- if (snd_center_y < npc_center_y)//判断纵坐标
- {
- a = npc_center_x - snd_center_x;
- b = npc_center_y - snd_center_y;
- if (a < 50 && b < 40)//发生碰撞
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
- else if (snd_center_y > npc_center_y)//判断纵坐标
- {
- a = npc_center_x - snd_center_x;
- b = snd_center_y - npc_center_y;
- if (a < 50 && b < 40)//发生碰撞
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
-
- }
- else if (snd_center_x > npc_center_x)//判断横坐标
- {
- if (snd_center_y < npc_center_y)//判断纵坐标
- {
- a = snd_center_x - npc_center_x;
- b = npc_center_y - snd_center_y;
- if (a < 50 && b < 40)//发生碰撞
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
- else if (snd_center_y > npc_center_y)//判断纵坐标
- {
- a = snd_center_x - npc_center_x;
- b = snd_center_y - npc_center_y;
- if (a < 50 && b < 40)//发生碰撞
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
-
- }
- return 0;
- }
-
-
- int check_lose_blood_cm(int x, int y, int npc_x, int npc_y)//判定扣血——天空龙
- {
- //中心坐标
- int snd_center_x, snd_center_y, npc_center_x, npc_center_y;
- int a, b;
- //确定中心
- snd_center_x = x + 35;
- snd_center_y = y + 40;
- npc_center_x = npc_x + 45;
- npc_center_y = npc_y + 35;
- //判断位置以及碰撞关系
- if (snd_center_x < npc_center_x)//判断横坐标
- {
- if (snd_center_y < npc_center_y)//判断纵坐标
- {
- a = npc_center_x - snd_center_x;
- b = npc_center_y - snd_center_y;
- if (a < 40 && b < 50)//发生碰撞
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
- else if (snd_center_y > npc_center_y)//判断纵坐标
- {
- a = npc_center_x - snd_center_x;
- b = snd_center_y - npc_center_y;
- if (a < 40 && b < 50)//发生碰撞
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
-
- }
- else if (snd_center_x > npc_center_x)//判断横坐标
- {
- if (snd_center_y < npc_center_y)//判断纵坐标
- {
- a = snd_center_x - npc_center_x;
- b = npc_center_y - snd_center_y;
- if (a < 40 && b < 50)//发生碰撞
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
- else if (snd_center_y > npc_center_y)//判断纵坐标
- {
- a = snd_center_x - npc_center_x;
- b = snd_center_y - npc_center_y;
- if (a < 40 && b < 50)//发生碰撞
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
-
- }
- return 0;
- }
-
-
- int check_lose_blood_g(int x, int y, int npc_x, int npc_y)//判定扣血——喷火龙
- {
- //中心坐标
- int snd_center_x, snd_center_y, npc_center_x, npc_center_y;
- int a, b;
- //确定中心
- snd_center_x = x + 35;
- snd_center_y = y + 40;
- npc_center_x = npc_x + 45;
- npc_center_y = npc_y + 35;
- //判断位置以及碰撞关系
- if (snd_center_x < npc_center_x)//判断横坐标
- {
- if (snd_center_y < npc_center_y)//判断纵坐标
- {
- a = npc_center_x - snd_center_x;
- b = npc_center_y - snd_center_y;
- if (a < 60 && b < 60)//发生碰撞
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
- else if (snd_center_y > npc_center_y)//判断纵坐标
- {
- a = npc_center_x - snd_center_x;
- b = snd_center_y - npc_center_y;
- if (a < 60 && b < 60)//发生碰撞
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
-
- }
- else if (snd_center_x > npc_center_x)//判断横坐标
- {
- if (snd_center_y < npc_center_y)//判断纵坐标
- {
- a = snd_center_x - npc_center_x;
- b = npc_center_y - snd_center_y;
- if (a < 30 && b < 60)//发生碰撞
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
- else if (snd_center_y > npc_center_y)//判断纵坐标
- {
- a = snd_center_x - npc_center_x;
- b = snd_center_y - npc_center_y;
- if (a < 60 && b < 60)//发生碰撞
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
-
- }
- return 0;
- }
-
-
- int check_victory(int x, int y, int npc_x, int npc_y)//判定游戏胜利
- {
- //中心坐标
- int snd_center_x, snd_center_y, npc_center_x, npc_center_y;
- int a, b;
- //确定中心
- snd_center_x = x + 35;
- snd_center_y = y + 40;
- npc_center_x = npc_x + 25;
- npc_center_y = npc_y + 20;
- //判断位置以及碰撞关系
- if (snd_center_x < npc_center_x)//判断横坐标
- {
- if (snd_center_y < npc_center_y)//判断纵坐标
- {
- a = npc_center_x - snd_center_x;
- b = npc_center_y - snd_center_y;
- if (a < 30 && b < 30)//发生碰撞
- {
- return 0;
- }
- else
- {
- return 1;
- }
- }
- else if (snd_center_y > npc_center_y)//判断纵坐标
- {
- a = npc_center_x - snd_center_x;
- b = snd_center_y - npc_center_y;
- if (a < 30 && b < 30)//发生碰撞
- {
- return 0;
- }
- else
- {
- return 1;
- }
- }
-
- }
- else if (snd_center_x > npc_center_x)//判断横坐标
- {
- if (snd_center_y < npc_center_y)//判断纵坐标
- {
- a = snd_center_x - npc_center_x;
- b = npc_center_y - snd_center_y;
- if (a < 30 && b < 30)//发生碰撞
- {
- return 0;
- }
- else
- {
- return 1;
- }
- }
- else if (snd_center_y > npc_center_y)//判断纵坐标
- {
- a = snd_center_x - npc_center_x;
- b = snd_center_y - npc_center_y;
- if (a < 30 && b < 30)//发生碰撞
- {
- return 0;
- }
- else
- {
- return 1;
- }
- }
-
- }
- return 0;
- }
-
-
- int zanting(HWND gamewindow)//游戏暂停
- {
- int next_step;
- int answer = MessageBox(gamewindow, "是否继续游戏?", "小命要紧", MB_OKCANCEL);//添加选择框内容
- if (answer == IDOK)//继续游戏
- {
- next_step = 0;
- return next_step;;
-
- }
- else if (answer == IDCANCEL)//回到开始界面
- {
- next_step = 1;
- return next_step;;
- }
-
- }
-
-
- //模块类
- void nomal_botton(int left, int top, int right, int bottom, const char* text)//正常状态按钮
- {
- setbkmode(TRANSPARENT);//设置字体背景透明
-
-
- char lingshi_text[50] = { 0 };//按钮内容
- strcpy(lingshi_text, text);//获取内容
- settextstyle(20, 20, "宋体");//设置字体
- settextcolor(BLACK);
- int text_x = left + (right - left - textwidth(lingshi_text)) / 2;//内容横坐标
- int text_y = top + (bottom - top - textheight(lingshi_text)) / 2;//内容纵坐标
- outtextxy(text_x, text_y, lingshi_text);
- }
-
-
- void abnomal_botton(int left, int top, int right, int bottom)//选中状态按钮
- {
- BeginBatchDraw();
- setlinecolor(BLACK);//设置线条颜色
- setlinestyle(PS_SOLID, 1);//设置线条类型
- roundrect(left, top, right, bottom, 10, 10);//设置按钮
- FlushBatchDraw();
- }
-
-
- int select()//点击选项模块
- {
- ExMessage msg;
- while (1)
- {
- if (peekmessage(&msg, EM_MOUSE))//获取鼠标点击信息
- {
- switch (msg.message)//判断点击信息
- {
- case WM_LBUTTONDOWN://开始游戏
- if (msg.x > 25 && msg.x < 200 && msg.y>100 && msg.y < 150)
- {
- abnomal_botton(25, 100, 200, 150);//点击后按钮状态
- Sleep(500);
- return 0;
- }
- else if (msg.x > 25 && msg.x < 200 && msg.y>200 && msg.y < 250)//选择难度模式
- {
- abnomal_botton(25, 200, 200, 250);//点击后按钮状态
- Sleep(500);
- return 1;
- }
- else if (msg.x > 25 && msg.x < 200 && msg.y>300 && msg.y < 350)//游戏介绍
- {
- abnomal_botton(25, 300, 200, 350);//点击后按钮状态
- Sleep(500);
- return 3;
- }
- else if (msg.x > 20 && msg.x < 200 && msg.y>400 && msg.y < 450)//退出游戏
- {
- abnomal_botton(25, 400, 200, 450);//点击后按钮状态
- Sleep(500);
- return 4;
- }
- default:
- return 5;
- }
-
- }
- }
- }
-
-
- int return_back()//游戏介绍返回点击
- {
-
- ExMessage msg;
- while (1)
- {
- if (peekmessage(&msg, EM_MOUSE))//获取鼠标点击信息
- {
- switch (msg.message)//判断点击信息
- {
- case WM_LBUTTONDOWN://开始游戏
- if (msg.x > 550 && msg.x < 750 && msg.y>350 && msg.y < 550)
- {
- abnomal_botton(650, 500, 750, 550);//点击后按钮状态
- Sleep(500);
- return 4;
- }
-
- default:
- return 5;
- }
- }
- }
- }
-
-
- int select_differ()//难度选择
- {
- ExMessage msg;
- while (1)
- {
- if (peekmessage(&msg, EM_MOUSE))//获取鼠标点击信息
- {
- switch (msg.message)//判断点击信息
- {
- case WM_LBUTTONDOWN://开始游戏
- if (msg.x > 25 && msg.x < 200 && msg.y>60 && msg.y < 110)
- {
- abnomal_botton(25, 60, 200, 110);//点击后按钮状态
- Sleep(500);
- return 0;
- }
- else if (msg.x > 25 && msg.x < 200 && msg.y>150 && msg.y < 200)//选择难度模式
- {
- abnomal_botton(25, 150, 200, 200);//点击后按钮状态
- Sleep(500);
- return 1;
- }
- else if (msg.x > 25 && msg.x < 200 && msg.y>240 && msg.y < 290)//游戏介绍
- {
- abnomal_botton(25, 240, 200, 290);//点击后按钮状态
- Sleep(500);
- return 2;
- }
- else if (msg.x > 20 && msg.x < 200 && msg.y>330 && msg.y < 380)//退出游戏
- {
- abnomal_botton(25, 330, 200, 380);//点击后按钮状态
- Sleep(500);
- return 3;
- }
- default:
- return 4;
- }
-
- }
- }
- }
-
-
-
- void menu(int choice, HWND startwindow)//菜单中转
- {
- switch (choice)
- {
- case 0://开始游戏
- int result;
- running_window();
- cleardevice();
- result = game_window();
- if (result == 0)
- {
-
- start_window();
- }
- else if (result == 1)
- {
-
- victory_window();
- }
- return;
- case 1://选择模式
- change_window();
- return;
- case 3://游戏简介
- introduce_window();
- return;
- case 4://退出游戏
- end_mode(startwindow);
- start_window();
- return;
- case 5:
- return;
- }
- }
-
-
- void running(int i, int lunhuan)//进度条
- {
- //进度条
- IMAGE a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16;
- //皮卡丘
- IMAGE g1, g2, g3, g4, g7, g8;
- //获取资源
- //进度条
- loadimage(&a1, _T("jdt1.png"), 750, 40);
- loadimage(&a2, _T("jdt2.png"), 750, 40);
- loadimage(&a3, _T("jdt3.png"), 750, 40);
- loadimage(&a4, _T("jdt4.png"), 750, 40);
- loadimage(&a5, _T("jdt5.png"), 750, 40);
- loadimage(&a6, _T("jdt6.png"), 750, 40);
- loadimage(&a7, _T("jdt7.png"), 750, 40);
- loadimage(&a8, _T("jdt8.png"), 750, 40);
- loadimage(&a9, _T("jdt9.png"), 750, 40);
- loadimage(&a10, _T("jdt10.png"), 750, 40);
- loadimage(&a11, _T("jdt11.png"), 750, 40);
- loadimage(&a12, _T("jdt12.png"), 750, 40);
- loadimage(&a15, _T("jdt15.png"), 750, 40);
- loadimage(&a16, _T("jdt16.png"), 750, 40);
- loadimage(&a13, _T("jdt13.png"), 750, 40);
- loadimage(&a14, _T("jdt14.png"), 750, 40);
- //皮卡丘
- loadimage(&g1, _T("pkq1.png"), 70, 60);
- loadimage(&g2, _T("pkq2.png"), 70, 60);
- loadimage(&g3, _T("pkq3.png"), 70, 60);
- loadimage(&g4, _T("pkq4.png"), 70, 60);
- loadimage(&g7, _T("pkq5.png"), 70, 60);
- loadimage(&g8, _T("pkq6.png"), 70, 60);
-
- switch (i)//判断进程
- {
- case 1:
- if (lunhuan == 0 || lunhuan == 2)
- {
- putimage(35, 520, &a2, SRCAND);//添加位运算宏
- putimage(35, 520, &a1, SRCPAINT);
- putimage(25, 500, &g2, SRCAND);//添加位运算宏
- putimage(25, 500, &g1, SRCPAINT);
- break;
- }
- else if (lunhuan == 1)
- {
- putimage(35, 520, &a2, SRCAND);//添加位运算宏
- putimage(35, 520, &a1, SRCPAINT);
- putimage(25, 500, &g4, SRCAND);//添加位运算宏
- putimage(25, 500, &g3, SRCPAINT);
- break;
- }
- else if (lunhuan == 3)
- {
- putimage(35, 520, &a2, SRCAND);//添加位运算宏
- putimage(35, 520, &a1, SRCPAINT);
- putimage(25, 500, &g8, SRCAND);//添加位运算宏
- putimage(25, 500, &g7, SRCPAINT);
- break;
- }
- case 2:
- if (lunhuan == 0 || lunhuan == 2)
- {
- putimage(35, 520, &a4, SRCAND);//添加位运算宏
- putimage(35, 520, &a3, SRCPAINT);
- putimage(60, 500, &g2, SRCAND);//添加位运算宏
- putimage(60, 500, &g1, SRCPAINT);
- break;
- }
- else if (lunhuan == 1)
- {
- putimage(35, 520, &a4, SRCAND);//添加位运算宏
- putimage(35, 520, &a3, SRCPAINT);
- putimage(60, 500, &g4, SRCAND);//添加位运算宏
- putimage(60, 500, &g3, SRCPAINT);
- break;
- }
- else if (lunhuan == 3)
- {
- putimage(35, 520, &a4, SRCAND);//添加位运算宏
- putimage(35, 520, &a3, SRCPAINT);
- putimage(60, 500, &g8, SRCAND);//添加位运算宏
- putimage(60, 500, &g7, SRCPAINT);
- break;
- }
- case 3:
- if (lunhuan == 0 || lunhuan == 2)
- {
- putimage(35, 520, &a6, SRCAND);//添加位运算宏
- putimage(35, 520, &a5, SRCPAINT);
- putimage(110, 500, &g2, SRCAND);//添加位运算宏
- putimage(110, 500, &g1, SRCPAINT);
- break;
- }
- else if (lunhuan == 1)
- {
- putimage(35, 520, &a6, SRCAND);//添加位运算宏
- putimage(35, 520, &a5, SRCPAINT);
- putimage(110, 500, &g4, SRCAND);//添加位运算宏
- putimage(110, 500, &g3, SRCPAINT);
- break;
- }
- else if (lunhuan == 3)
- {
- putimage(35, 520, &a6, SRCAND);//添加位运算宏
- putimage(35, 520, &a5, SRCPAINT);
- putimage(110, 500, &g8, SRCAND);//添加位运算宏
- putimage(110, 500, &g7, SRCPAINT);
- break;
- }
- case 4:
- if (lunhuan == 0 || lunhuan == 2)
- {
- putimage(35, 520, &a8, SRCAND);//添加位运算宏
- putimage(35, 520, &a7, SRCPAINT);
- putimage(180, 500, &g2, SRCAND);//添加位运算宏
- putimage(180, 500, &g1, SRCPAINT);
- break;
- }
- else if (lunhuan == 1)
- {
- putimage(35, 520, &a8, SRCAND);//添加位运算宏
- putimage(35, 520, &a7, SRCPAINT);
- putimage(180, 500, &g4, SRCAND);//添加位运算宏
- putimage(180, 500, &g3, SRCPAINT);
- break;
- }
- else if (lunhuan == 1)
- {
- putimage(35, 520, &a8, SRCAND);//添加位运算宏
- putimage(35, 520, &a7, SRCPAINT);
- putimage(180, 500, &g8, SRCAND);//添加位运算宏
- putimage(180, 500, &g7, SRCPAINT);
- break;
- }
- case 5:
- if (lunhuan == 0 || lunhuan == 2)
- {
- putimage(35, 520, &a10, SRCAND);//添加位运算宏
- putimage(35, 520, &a9, SRCPAINT);
- putimage(345, 500, &g2, SRCAND);//添加位运算宏
- putimage(345, 500, &g1, SRCPAINT);
- break;
- }
- else if (lunhuan == 1)
- {
- putimage(35, 520, &a10, SRCAND);//添加位运算宏
- putimage(35, 520, &a9, SRCPAINT);
- putimage(345, 500, &g4, SRCAND);//添加位运算宏
- putimage(345, 500, &g3, SRCPAINT);
- break;
- }
- else if (lunhuan == 3)
- {
- putimage(35, 520, &a10, SRCAND);//添加位运算宏
- putimage(35, 520, &a9, SRCPAINT);
- putimage(345, 500, &g8, SRCAND);//添加位运算宏
- putimage(345, 500, &g7, SRCPAINT);
- break;
- }
- case 6:
- if (lunhuan == 0 || lunhuan == 2)
- {
- putimage(35, 520, &a12, SRCAND);//添加位运算宏
- putimage(35, 520, &a11, SRCPAINT);
- putimage(370, 500, &g2, SRCAND);//添加位运算宏
- putimage(370, 500, &g1, SRCPAINT);
- break;
- }
- else if (lunhuan == 1)
- {
- putimage(35, 520, &a12, SRCAND);//添加位运算宏
- putimage(35, 520, &a11, SRCPAINT);
- putimage(370, 500, &g4, SRCAND);//添加位运算宏
- putimage(370, 500, &g3, SRCPAINT);
- break;
- }
- else if (lunhuan == 3)
- {
- putimage(35, 520, &a12, SRCAND);//添加位运算宏
- putimage(35, 520, &a11, SRCPAINT);
- putimage(370, 500, &g8, SRCAND);//添加位运算宏
- putimage(370, 500, &g7, SRCPAINT);
- break;
- }
- case 7:
- if (lunhuan == 0 || lunhuan == 2)
- {
- putimage(35, 520, &a14, SRCAND);//添加位运算宏
- putimage(35, 520, &a13, SRCPAINT);
- putimage(520, 500, &g2, SRCAND);//添加位运算宏
- putimage(520, 500, &g1, SRCPAINT);
- break;
- }
- else if (lunhuan == 1)
- {
- putimage(35, 520, &a14, SRCAND);//添加位运算宏
- putimage(35, 520, &a13, SRCPAINT);
- putimage(520, 500, &g4, SRCAND);//添加位运算宏
- putimage(520, 500, &g3, SRCPAINT);
- break;
- }
- else if (lunhuan == 3)
- {
- putimage(35, 520, &a14, SRCAND);//添加位运算宏
- putimage(35, 520, &a13, SRCPAINT);
- putimage(520, 500, &g8, SRCAND);//添加位运算宏
- putimage(520, 500, &g7, SRCPAINT);
- break;
- }
- case 8:
- if (lunhuan == 0 || lunhuan == 2)
- {
- putimage(35, 520, &a16, SRCAND);//添加位运算宏
- putimage(35, 520, &a15, SRCPAINT);
- putimage(720, 500, &g2, SRCAND);//添加位运算宏
- putimage(720, 500, &g1, SRCPAINT);
- break;
- }
- else if (lunhuan == 1)
- {
- putimage(35, 520, &a16, SRCAND);//添加位运算宏
- putimage(35, 520, &a15, SRCPAINT);
- putimage(720, 500, &g4, SRCAND);//添加位运算宏
- putimage(720, 500, &g3, SRCPAINT);
- break;
- }
- else if (lunhuan == 3)
- {
- putimage(35, 520, &a16, SRCAND);//添加位运算宏
- putimage(35, 520, &a15, SRCPAINT);
- putimage(720, 500, &g8, SRCAND);//添加位运算宏
- putimage(720, 500, &g7, SRCPAINT);
- break;
- }
- default:
- break;
- }
- }
-
-
- void end_mode(HWND startwindow)//结束模块
- {
- int answer = MessageBox(startwindow, "是否结束游戏?", "猫娘乐园", MB_OKCANCEL);//添加选择框内容
- if (answer == IDOK)
- {
- closegraph();//结束游戏
- mciSendString("close bgm.mp3 ", 0, 0, 0);
- exit(-1);
- }
- else if (answer == IDCANCEL)//回到游戏界面
- {
- return;
- }
-
- }
-
-
- int check_jdt(int zhongzhuan)//判断进度条位置,返回决定参数
- {
- if (zhongzhuan < 4)
- {
- i = 1;
- return i;
- }
- else if (zhongzhuan > 3 && zhongzhuan < 8)
- {
- i = 2;
- return i;
- }
- else if (zhongzhuan > 7 && zhongzhuan < 12)
- {
- i = 3;
- return i;
- }
- else if (zhongzhuan > 11 && zhongzhuan < 16)
- {
- i = 4;
- return i;
- }
- else if (zhongzhuan > 15 && zhongzhuan < 20)
- {
- i = 5;
- return i;
- }
- else if (zhongzhuan > 19 && zhongzhuan < 24)
- {
- i = 6;
- return i;
- }
- else if (zhongzhuan > 23 && zhongzhuan < 28)
- {
- i = 7;
- return i;
- }
- else if (zhongzhuan > 27 && zhongzhuan < 32)
- {
- i = 8;
- return i;
- }
- }
-
-
- void music()//背景音乐
- {
- mciSendString("open bgm.mp3 alias BGM", 0, 0, 0);
- mciSendString("play BGM repeat", 0, 0, 0);
- return;
- }
-
-
- //主程序
- int main()
- {
- start_window();//加载开始界面
- //游戏开始
- //游戏结束
- return 0;//退出游戏
- }
-
打包后:
链接:https://pan.baidu.com/s/1z3doEvnkdki555dBR3ywvQ?pwd=mzau
提取码:mzau
打包前(含素材):
链接:https://pan.baidu.com/s/10OgYAvB6AvBZcKGo6612tA?pwd=05je
提取码:05je
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。