打砖块
来源:互联网 发布:双系统怎样重装ubuntu 编辑:程序博客网 时间:2024/06/02 23:44
先上图表示敬意
main.cpp源码
为更好的学习知识,下载资源,play.h设置两个积分,谢谢支持
#include <conio.h>#include <graphics.h>#include <Windows.h>#include "Play.h"int main(){InitPlay();::CreateThread(0, 0, GameMove, 0, 0, 0);while (GameWin){DrawMap();BallMove();if (number == 0){cleardevice();DrawMap();MessageBox(GetHWnd(), "你赢了", "提示", MB_OK);break;}Sleep(400);cleardevice();}getch();return 0;}void DrawMap(){LPTSTR PrintfNumber = new TCHAR[1024];LPTSTR PrintfNumber2 = new TCHAR[1024];wsprintf(PrintfNumber, "砖块数:%d", number);wsprintf(PrintfNumber2, "余剩数:%d", (50-number));settextcolor(WHITE);settextstyle(24, 0, "黑体");outtextxy(80, 280, PrintfNumber);outtextxy(80, 320, PrintfNumber2);for (int i = 0; i < 40;i++){for (int j = 0; j < 20; j++){switch (map[i][j]){case 1:setfillcolor(YELLOW);setlinecolor(BLACK);fillrectangle(j * 16, i * 16, j * 16 + 16, i * 16 + 16);break;case 2:setfillcolor(BLUE);solidcircle(j * 16 + 8, i * 16 + 8, 8);break;case 3:setfillcolor(RED);setlinecolor(WHITE);fillrectangle(j * 16, i * 16, j * 16 + 16, i * 16 + 8);break;default:break;}}}}void InitPlay(){initgraph(20 * 16, 40 * 16);number = 50;}void BallMove(){int BallR, BallC;for (int i = 0; i < 40; i++){for (int j = 0; j < 20; j++){if (map[i][j] == 2){BallR = i; BallC = j;map[i][j] = 0;}}}BallR += ball.r;BallC += ball.c;map[BallR][BallC] = 2;if (BallC + ball.c<0 || BallC + ball.c>19){ball.c = -ball.c;return;}if (BallR + ball.r < 0){ball.r = -ball.r;return;}if (map[BallR + ball.r][BallC] == 1){map[BallR + ball.r][BallC] = 0;number--;ball.r = -ball.r;return;}if (map[BallR][BallC + ball.c] == 1){map[BallR][BallC + ball.c] = 0;number--;ball.c = -ball.c;return;}if (map[BallR + ball.r][BallC] == 3){ball.r = -ball.r;return;}if (BallR == 39){GameOver();}}DWORD WINAPI GameMove(LPVOID lParam){char ch;while (1){ch = getch();switch (ch){case 'A':case 'a':if (map[39][0] == 3){break;}for (int i = 0; i < 20; i++){if (map[39][i] == 3){map[39][i] = 0;map[39][i - 1] = 3;}}/*setfillcolor(BLACK);solidrectangle(0, 640 - 16, 320, 640);Sleep(20);for (int i = 0; i < 20; i++){if (map[39][i] == 3){setfillcolor(RED);setlinecolor(WHITE);fillrectangle(i * 16, 640 - 16, i * 16 - 16, 640 - 8);}if (map[39][i] == 2){DrawMap();}}*/cleardevice();DrawMap();break;case 'D':case 'd':if (map[39][19] == 3){break;}for (int i = 19; i >= 0; i--){if (map[39][i] == 3){map[39][i] = 0;map[39][i + 1] = 3;}}/*setfillcolor(BLACK);solidrectangle(0, 640 - 16, 320, 640);Sleep(20);for (int i = 0; i < 20; i++){if (map[39][i] == 3){setfillcolor(RED);setlinecolor(WHITE);fillrectangle(i * 16, 640 - 16, i * 16 - 16, 640 - 8);}if (map[39][i] == 2){DrawMap();}}*/cleardevice();DrawMap();break;default:break;}}}void GameOver(){cleardevice();DrawMap();GameWin = false;MessageBox(GetHWnd(), "你输了", "提示", MB_OK);}
play.h点击下载
阅读全文
0 0
- 打砖块
- 打砖块
- 打砖块
- 打砖块游戏源码
- HNOI2004 打砖块
- Qt打砖块游戏
- android 打砖块游戏
- Linux C 打砖块
- 【HNOI2004】打砖块
- wiki 1257 打砖块
- unity3D__球打砖块
- 【codevs1257】打砖块 DP
- 【codevs1257】 打砖块
- 洛谷 P1174 打砖块
- 洛谷 P1174 打砖块
- 打砖块Demo
- 洛谷 P1174 打砖块
- 打砖块小游戏1.0
- 可选操作和UnsupportedOperationException
- css 手风琴菜单效果,图片动画
- 软考错题合集之14-11-AM
- 本周互动留言抽奖结果公布!!
- @Controller和@RestController的区别
- 打砖块
- [Unity]简单的socket客户端和服务器
- java.nio.channels.IllegalBlockingModeException
- 在windows下运行Measuring the objectness of image windows的代码objectness-release-v2.2的方法
- CentOS中Mysql定时备份
- maysql_having
- 【Go】协程
- Sql 数据查询区分大小写方法
- python Global和Return用法