| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 6047 人关注过本帖
标题:[原创]我用C写的类似劲舞团的东西(有点烂)
只看楼主 加入收藏
andyss
Rank: 1
等 级:新手上路
帖 子:189
专家分:0
注 册:2006-4-8
收藏
 问题点数:0 回复次数:48 
[原创]我用C写的类似劲舞团的东西(有点烂)

主要为了检验一下自己!写的不好,希望大家指证呀!
#include<graphics.h> //图形库
#include<stdio.h>
#include<dos.h>
#include<bios.h>
#include<conio.h>
#include<stdlib.h>

#define up 72
#define left 75
#define right 77
#define enter 2
#define down 80
#define esc 1
#define space 57

void init_graph(); //初始化图形系统
void init(); //初始界面的绘制
int getkey(); //获取键盘动作
void drawbox(int total); //画圆圈箭头
void makebox(int total); //产生圆圈箭头(total为产生的个数)
void clearbox(); //消去界面上的圆圈
int timecome(); //定时
int testbox(int test); //测试你按的方向是否和界面上的相同
int timeout(); //总时间
void drawbar(); //绘制时间条
int timecome1(); //在TIMEOUT()函数中用到的时间函数
void clearbar(); //消去时间条
void outnum(int x,int y,int num); //输出数字用的函数
void scoretest(); //根据你完成的时间决定分数
void andyss(); //个人标识

int a[4][12];
int direct,b,c,temp,total=3,m[7],t,flag=1,score=0,i=0;
a[4][12]={{4,10,16,10,13,4,16,10,13,16,16,10},
{4,10,16,10,7,4,4,10,7,16,4,10},
{10,4,10,16,4,13,10,16,16,13,10,16},
{10,4,10,16,4,7,10,4,16,7,10,4}};
m[7]={0,0,0,0,0,0,0};


void init_graph(){
int gdrive=9,gmode=2,errorcode;
int i,j,flag,k,m,key;
initgraph(&gdrive,&gmode,"c:\\tc");
errorcode=graphresult();
if(errorcode!=0)
{printf("the graph error:%s",grapherrormsg(errorcode));
printf("press any key to halt");
getch();
exit(1);
}
}

void init(){
cleardevice();
andyss();
setbkcolor(GREEN);
setcolor(RED);
rectangle(200,40,400,440);
rectangle(300,260,400,280);
setfillstyle(1,4);
bar(375,260,385,280);
setfillstyle(1,6);
bar(201,150,399,300);
outtextxy(210,180,"would you like to ");
outtextxy(210,190," play the game?");
outtextxy(210,200," 'y' to start game");
outtextxy(210,210," 'n' to exit game");
c=getche();
if(c=='y'||c=='Y'){ i=1;
setfillstyle(1,2);
bar(201,150,399,300);}
else if(c=='n'||c=='N') i=0;
}

void outnum(int x,int y,int num){
char string[8];
itoa(num,string,10);
setcolor(RED);
outtextxy(x,y,string);
}

void scoretest(){
setcolor(RED);
if(b<75&&direct==total){
outtextxy(420,260,"very good!");
score=score+1000;
}
else if(b>=75&&b<=85&&direct==total){
outtextxy(420,260,"perfict");
score=score+1500;
}
else if(b>85&&b<100&&direct==total){
outtextxy(420,260,"bad");
score=score+500;
}
else outtextxy(420,260,"miss!");
}

int getkey(){
union REGS rg;
rg.h.ah=0;
int86(0x16,&rg,&rg);
return rg.h.ah;
}

void drawbox(int total){
int i;
temp=300-total*10;
for(i=0;i<total;i++){
circle(temp+10,310,10);
line(a[m[i]][0]+temp,a[m[i]][1]+300,a[m[i]][2]+temp,a[m[i]][3]+300);
line(a[m[i]][4]+temp,a[m[i]][5]+300,a[m[i]][6]+temp,a[m[i]][7]+300);
line(a[m[i]][8]+temp,a[m[i]][9]+300,a[m[i]][10]+temp,a[m[i]][11]+300);
temp=temp+20;
}
temp=300-total*10;
}

void makebox(int total){
int i;
for(i=0;i<total;i++){
m[i]=rand()%4;
}
setcolor(WHITE);
drawbox(total);
}

void clearbox(){
setfillstyle(1,2);
bar(201,300,399,340);
}

int timecome(){
static long tm,old;
tm=biostime(0,tm);
if(tm-old<1) return(0);
else{ old=tm;
return(1);
}
}
int timecome1(){
static long tm,old;
tm=biostime(0,tm);
if(tm-old<50) return(0);
else{ old=tm;return(1); }
}
int timecome2(){
static long tm,old;
tm=biostime(0,tm);
if(tm-old<25) return(0);
else{ old=tm;return(1);}
}

int testbox(int test){
if(m[direct]==test){
setcolor(RED);
circle(temp+10+20*direct,310,10);
line(a[m[direct]][0]+temp+20*direct,a[m[direct]][1]+300,a[m[direct]][2]+temp+20*direct,a[m[direct]][3]+300);
line(a[m[direct]][4]+temp+20*direct,a[m[direct]][5]+300,a[m[direct]][6]+temp+20*direct,a[m[direct]][7]+300);
line(a[m[direct]][8]+temp+20*direct,a[m[direct]][9]+300,a[m[direct]][10]+temp+20*direct,a[m[direct]][11]+300);
return(1);
}
else return(0);
}

int timeout(){
int j;
outtextxy(410,400,"time:");
j=timecome2();
if(j){
setfillstyle(1,2);
bar(450,400,480,420);
t--;
}
outnum(450,400,t);
return(t);
}

void drawbar(){
setfillstyle(1,15);
bar(300,260,300+b,280);
if(timecome()&&flag) b=b+2;
if(b>=100){
clearbar();
b=0;
}
}
void clearbar(){
setfillstyle(1,2);
bar(301,261,399,279);
bar(420,260,600,400);
setcolor(WHITE);
rectangle(300,260,400,280);
setfillstyle(1,4);
bar(375,260,385,280);
}

void andyss(){
outtextxy(0,200,"wrote by andyss in cqupt.");
outtextxy(0,220,"QQ:274839490");
outtextxy(0,240,"mail:ssvfhp21@163.com");
}

void gameover(){
setfillstyle(1,6);
bar(201,150,399,300);
outtextxy(210,180,"Gameover! Woule you");
outtextxy(210,190," like to continu?");
outtextxy(210,200," 'y' to restart game");
outtextxy(210,210," 'n' to exit game");
c=getche();
if(c=='y'||c=='Y'){
i=1;
setfillstyle(1,2);
bar(201,150,399,300);
b=0,c=27,direct=0,t=60,total=3,score=0;
clearbox();
makebox(3);
}
else if(c=='n'||c=='N') i=0;
}

void main(){
int key,test;
b=0,c=27,direct=0,t=60,total=3,score=0,i=1;
temp=300-total*10;
init_graph();
init();
while(i){
outnum(420,300,score);
test=timeout();
if(test==0){
gameover();
}
if(c<0) exit(0);
if(c<9&&c>0){
total=4;
if(c==8) total=7;
if(timecome1()){
direct=0;
clearbox();
makebox(4);
drawbar();
flag=1;
c--;
}
}
//产生BOX
if(c<12&&c>8){
total=7;
if(c==11) total=6;
if(timecome1()){
direct=0;
clearbox();
makebox(7);
clearbar();
drawbar();
flag=1;
c--;
}
}

if(c<15&&c>11)
{ total=6;
if(c==14) total=5;
if(timecome1()){
clearbox();
makebox(6);
direct=0;
clearbar();
drawbar();
flag=1;
c--;
}
}

if(c<19&&c>14){
total=5;
if(c==18) total=4;
if(timecome1()){
clearbox();
direct=0;
makebox(5);
clearbar();
drawbar();
flag=1;
c--;
}
}


if(c<24&&c>18){
total=4;
if(c==23) total=3;
if(timecome1()){
clearbox();
direct=0;
makebox(4);
clearbar();
drawbar();
flag=1;
c--;
}
}

if(c>23){
total=3;
if(timecome1()){
clearbox();
direct=0;
makebox(3);
clearbar();
drawbar();
flag=1;
c--;
}
}
drawbar();
if(bioskey(1)!=0)//获取键盘动作
{key=getkey();
switch(key)
{case left: if(testbox(1)) direct++;
else{ direct=0;
setcolor(WHITE);
drawbox(total); }
break;
case right:if(testbox(0)) direct++;
else{ direct=0;
setcolor(WHITE);
drawbox(total); }
break;
case up: if(testbox(3)) direct++;
else{ direct=0;
setcolor(WHITE);
drawbox(total); }
break;
case esc:exit(0);
case down: if(testbox(2)) direct++;
else{ direct=0;
setcolor(WHITE);
drawbox(total); }
break;
case space: clearbar();
scoretest();
flag=0;
b=0;
break;
default :break;
}
}

}

closegraph();
}

PCuHwuxJ.rar (25.36 KB) [原创]我用C写的类似劲舞团的东西(有点烂)


[此贴子已经被作者于2006-5-3 23:53:04编辑过]

搜索更多相关主题的帖子: 劲舞团 define include void 图形 
2006-04-29 21:21
论坛
Rank: 3Rank: 3
等 级:新手上路
威 望:6
帖 子:1372
专家分:0
注 册:2006-3-27
收藏
得分:0 
劲舞团


是什么啊!我没玩过游戏,说说好玩不

日出东方,唯我不败! 做任何东西都是耐得住寂寞,任何一个行业要有十年以上的积累才能成为专家
2006-04-29 21:30
cxwl3sxl
Rank: 3Rank: 3
等 级:论坛游侠
威 望:1
帖 子:495
专家分:129
注 册:2005-11-12
收藏
得分:0 
挺强的!

努力,哈哈,总有一天会变成高手~~~~~~因为我相信:没有办不到,只有想不到!http://t..cn/fpress
2006-04-29 21:33
等待
Rank: 1
等 级:新手上路
帖 子:173
专家分:0
注 册:2005-12-1
收藏
得分:0 

高人,佩服!


2006-04-29 21:48
andyss
Rank: 1
等 级:新手上路
帖 子:189
专家分:0
注 册:2006-4-8
收藏
得分:0 
谢谢哈!程序设计还是有点不好,在时间延迟方面不怎么好!
还有界面不怎么好看.

幽幽黄桷兰----建四狼
2006-04-29 22:29
努力寻找
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-4-30
收藏
得分:0 

打不开呀
看看
Turbo C For Windows 3.0 正在编译....
f:\edt~1\kankan1.c:
正在汇编文件: kankan1.ASM
出错信息: 无
警告信息: 无
通过: 1
剩余内存: 209k
未定义的符号 '_initgraph' in module f:\edt~1\kankan1.c
未定义的符号 '_graphresult' in module f:\edt~1\kankan1.c
未定义的符号 '_grapherrormsg' in module f:\edt~1\kankan1.c
未定义的符号 '_cleardevice' in module f:\edt~1\kankan1.c
未定义的符号 '_setbkcolor' in module f:\edt~1\kankan1.c
未定义的符号 '_setcolor' in module f:\edt~1\kankan1.c
未定义的符号 '_rectangle' in module f:\edt~1\kankan1.c
未定义的符号 '_setfillstyle' in module f:\edt~1\kankan1.c
未定义的符号 '_bar' in module f:\edt~1\kankan1.c
未定义的符号 '_outtextxy' in module f:\edt~1\kankan1.c
未定义的符号 '_circle' in module f:\edt~1\kankan1.c
未定义的符号 '_line' in module f:\edt~1\kankan1.c
未定义的符号 '_closegraph' in module f:\edt~1\kankan1.c


可用内存 339372

2006-04-30 08:26
gaga
Rank: 1
等 级:新手上路
威 望:2
帖 子:307
专家分:0
注 册:2006-4-5
收藏
得分:0 
强啊楼主,居然能写出劲舞团的游戏来
厉害啊最好 再写个劲乐团来
嘿嘿

明天的明天还有明天。 可是今天却只有一个。 public Copy from 无缘今生
2006-04-30 09:33
feng1256
Rank: 4
等 级:贵宾
威 望:14
帖 子:2899
专家分:0
注 册:2005-11-24
收藏
得分:0 

你这个比较有意思~哈哈 不过TC 的做出来图确实不好看


叁蓙大山:工謪、稅務、嗣發 抱歉:不回答女人的问题
2006-04-30 09:40
学习吧
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2006-4-28
收藏
得分:0 
牛B
2006-04-30 15:52
神vLinux飘飘
Rank: 13Rank: 13Rank: 13Rank: 13
来 自:浙江杭州
等 级:贵宾
威 望:91
帖 子:6140
专家分:217
注 册:2004-7-17
收藏
得分:0 
确认是原创的话就加精华阿
我是看不了的了
没DOS/WINDOWS操作系统

淘宝杜琨
2006-04-30 21:19
快速回复:[原创]我用C写的类似劲舞团的东西(有点烂)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013825 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved