jump_1.1
来源:互联网 发布:速卖通行业数据分析 编辑:程序博客网 时间:2024/06/03 16:11
#include<time.h>#include<conio.h>#include<stdio.h>#include<string.h>#include<Windows.h>/**************************/const int PreSetMapHei=25;const int PreSetMapLen=25;const float PreSetJumpRef1=6;const float PreSetJumpRef2=0.6;const int PreSetMonPosi=10;const int PreSetMonHei=5;const int PreSetMonBan=7;const int PreSetSleep=20;/**************************/void back_move();void jump_func();int monst_create();void check();void print();void main_process();void enter_process();/**************************//*main time line*/int TIME;/*map*/const int MAP_HEI=PreSetMapHei,MAP_LEN=PreSetMapLen;char map[MAP_LEN];void back_move() {memcpy(map,map+1,sizeof(map)-1);map[MAP_LEN-1]=monst_create();}/*ground line */const char roll[]={"yyk is so strong "};int rolen=strlen(roll),front_r;void ground_init() {front_r=0;}void ground_move() {front_r=(front_r+1)%rolen;}void ground_print() {for(int i=0;i<MAP_LEN;i++) {putchar(roll[(front_r+i)%rolen]);}}/*player*/int player;int dead;/*jump*/const float J1=PreSetJumpRef1,J2=PreSetJumpRef2;int jump_v;void jump_func() {if(kbhit()) {while(kbhit()) getch();if(jump_v==-1) jump_v=0;}if(jump_v!=-1) {player=(J1-J2*(++jump_v))*(jump_v);if(player<0) {player=0;jump_v=-1;}}}/*monsters*/const int M_POSSI=PreSetMonPosi,M_HEI=PreSetMonHei,M_BAN=PreSetMonBan;int monst_create() {struct timeb timeSeed;ftime(&timeSeed);srand(timeSeed.time*1000+timeSeed.millitm);for(int i=1;i<=M_BAN;i++) {if(map[MAP_LEN-i]) return 0;}int tmp=rand()%M_POSSI;if(!tmp) return rand()%M_HEI+1;return 0;}void check() {if(player<map[0]) dead=1;}/*print*/void print() {printf("SCORES : %d\n",TIME);for(int i=MAP_HEI-1;i>=0;i--) {if(i==player+2) putchar(player>=map[0] ? 1 : 2);else {if(i==player+1) putchar(21);else {if(i==player) putchar(TIME&1 ? 47 : 20);else putchar(i>=map[0] ? 0 : '#');}}putchar((i==player)&&(TIME&1) ? 92 : (i>=map[1] ? 0 : '#') );for(int j=2;j<MAP_LEN;j++)putchar(i>=map[j] ? 0 : '#');putchar('\n');}ground_move();ground_print();putchar('\n');}/*main*/void main_process() { HANDLE hOutput; COORD coord={0,0}; hOutput=GetStdHandle(STD_OUTPUT_HANDLE); memset(map,0,sizeof map);for(TIME=0,dead=0,ground_init();!dead;TIME++) {SetConsoleCursorPosition(hOutput, coord);Sleep(PreSetSleep);back_move();jump_func();check();print();}}void enter_process() {for(int i=MAP_HEI-1;i>=0;i--) {puts(i==MAP_HEI/2 ? "ENTER" : "");}getch();for(char c='r';c=='r';c=getch()){main_process();puts("GAME OVER");puts("press R to play again");}}int main() {enter_process();}
阅读全文
0 0
- jump_1.1
- 1
- 1
- 1
- 1
- 1
- 1
- 1》
- 1
- 1
- 1
- 1
- (1)
- 1
- 1
- 1
- 1
- 1
- JavaWeb学习心得之JSP自定义标签
- MFC 控件自绘
- 日企SeCom:不想研发喂食机器人的无人机制造商不是好的安保公司 | 新智造
- myBatis jdbctype 0racle mysql对应
- 唯一中国企业精英——物灵科技联合创始人顾嘉唯,入选MIT科技创新35杰(MIT TR35人物评选)
- jump_1.1
- 深扒“东京8分钟”里AR特效的幕后团队:什么是科技与艺术的完美融合
- 从观看奥运说起 视频聚合类应用还能“火”多久?
- GeekPwn:人工智能和机器人对抗将成为极客终极目标
- 被亚马逊投资的温控器公司 Ecobee,有何过人之处?
- POJ 1661 Help Jimmy 最短路或者dp
- 打包签名相关知识点
- 360手机卫士发布微信漏洞红色预警:微信可被远程控制
- java类的加载机制