• 杰哥不要DEVC++小游戏


    1. #include<algorithm>
    2. #include<fstream>
    3. #include<iostream>
    4. #include<stdio.h>
    5. #include<cstdio>
    6. #include<iostream>
    7. #include<windows.h>
    8. #include<conio.h>
    9. #include <time.h>
    10. #include <stdlib.h>
    11. #include<bits/stdc++.h>
    12. #include<cstdio>
    13. #include<algorithm>
    14. #include <windows.h>
    15. #include <stdlib.h>
    16. #include <time.h>
    17. #define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0) //必要的,要背下来
    18. using namespace std;
    19. int game_map[20][20];
    20. int go;//判断杰哥是否能走
    21. int dj;
    22. int dj2;
    23. int dj3;
    24. int dm;//大门
    25. int x,y;//阿伟坐标
    26. int dx,dy;//杰哥坐标
    27. int HP=2;//血量
    28. int open() {
    29. SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
    30. cout<<"---------------"<<endl;
    31. cout<<"| 杰 哥 不 要 |"<<endl;
    32. cout<<"|任意键蹬dua郎|"<<endl;
    33. cout<<"--------------"<<endl;
    34. while(!kbhit()) {
    35. }
    36. system("cls");
    37. }
    38. int first() {
    39. x=0;
    40. y=0;
    41. dx=19;
    42. dy=19;
    43. HP=2;
    44. }
    45. int jdz(int number) {
    46. if(number<0) {
    47. number*=-1;
    48. }
    49. return number;
    50. }
    51. int out() {
    52. system("cls");
    53. for(int i=x-5; i<x+6; i++) {
    54. for(int j=y-5; j<y+6; j++) {
    55. if(i==x&&j==y) {
    56. SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);
    57. cout<<"o";
    58. } else if(i==dx&&j==dy) {
    59. SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY);
    60. cout<<"o";
    61. } else if(i==4&&j==9&&dj<15) {
    62. SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY);
    63. cout<<"L";
    64. } else if(i==9&&j==9&&dj2<15) {
    65. SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY);
    66. cout<<"L";
    67. } else if(i==14&&j==9&&dj3<15) {
    68. SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY);
    69. cout<<"L";
    70. } else if(i==9&&j==19) {
    71. SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);
    72. cout<<"n";
    73. } else if(i==-1||i==20) {
    74. SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);
    75. cout<<"+";
    76. } else if(j==-1||(j==20&&i!=9)) {
    77. SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);
    78. cout<<"+";
    79. } else {
    80. SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY);
    81. cout<<"*";
    82. }
    83. }
    84. cout<<endl;
    85. }
    86. }
    87. int AI() {
    88. if(go%5!=0) {
    89. return 0;
    90. }
    91. if(dx<x) {
    92. dx++;
    93. } else if(dx>x) {
    94. dx--;
    95. } else if(dy>y) {
    96. dy--;
    97. } else if(dy<y) {
    98. dy++;
    99. } else if(x==dy&&y==dy) {
    100. HP--;
    101. }
    102. }
    103. int play() {
    104. char c;
    105. if(kbhit()) {
    106. c=getch();
    107. if(c=='w'&&x>0) {
    108. x--;
    109. }
    110. if(c=='a'&&y>0) {
    111. y--;
    112. }
    113. if(c=='s'&&x<19) {
    114. x++;
    115. }
    116. if(c=='d'&&y<19) {
    117. y++;
    118. }
    119. if(c=='q'&&x==4&&y==9&&dj<15) {
    120. dj++;
    121. }
    122. if(c=='q'&&x==9&&y==9&&dj2<15) {
    123. dj2++;
    124. }
    125. if(c=='q'&&x==14&&y==9&&dj3<15) {
    126. dj3++;
    127. }
    128. if(c=='q'&&x==9&&y==19&&dj>=15&&dj2>=15&&dj3>=15) {
    129. dm++;
    130. }
    131. }
    132. }
    133. int main() {
    134. open();
    135. first();
    136. while(true) {
    137. out();
    138. play();
    139. AI();
    140. if(dm>=5) {
    141. SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
    142. system("cls");
    143. cout<<"逃过一杰";
    144. Sleep(2000);
    145. system("cls");
    146. return 0;
    147. }
    148. if(x==dx&&y==dy) {
    149. SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
    150. system("cls");
    151. cout<<"早知道,男生也会被性侵。";
    152. Sleep(2000);
    153. system("cls");
    154. return 0;
    155. }
    156. if(go%20==0&&HP<2) {
    157. HP++;
    158. }
    159. go++;
    160. Sleep(50);
    161. }
    162. }

  • 相关阅读:
    QT day2
    SQL面试题
    LangChain 推出 LangGraph Studio:首款用于可视化、交互和调试复杂代理应用的代理 IDE
    flutter系列之:builder为构造器而生
    什么是tomcat?tomcat是干什么用的?下面带你们认识tomcat!通俗易懂!
    windows的commonfiles
    华为机试真题实战应用【算法代码篇】-最大嵌套括号深度(附Java、python和C++代码)
    Python学习:类与实例
    Linux环境下RabbitMQ的安装与配置
    一文简单入门Node.js
  • 原文地址:https://blog.csdn.net/weixin_46995430/article/details/128202118