| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 6047 人关注过本帖
标题:[原创]我用C写的类似劲舞团的东西(有点烂)
取消只看楼主 加入收藏
andyss
Rank: 1
等 级:新手上路
帖 子:189
专家分:0
注 册:2006-4-8
收藏
 问题点数:0 回复次数:3 
[原创]我用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
andyss
Rank: 1
等 级:新手上路
帖 子:189
专家分:0
注 册:2006-4-8
收藏
得分:0 
谢谢哈!程序设计还是有点不好,在时间延迟方面不怎么好!
还有界面不怎么好看.

幽幽黄桷兰----建四狼
2006-04-29 22:29
andyss
Rank: 1
等 级:新手上路
帖 子:189
专家分:0
注 册:2006-4-8
收藏
得分:0 

写出构架没花多少时间,但是改了比较久,差不多用了5个小时吧(比较长的).
现在正在用VC++对我以前写用C写的游戏进行改写.
发现VC++跟C差别还是很大啊!


幽幽黄桷兰----建四狼
2006-05-02 23:17
andyss
Rank: 1
等 级:新手上路
帖 子:189
专家分:0
注 册:2006-4-8
收藏
得分:0 
我会找个时间去对我的帖子在修改一下,加一些说明,你可以到时后去看我的这个帖子!

你可以去我的博客http://blog.sina.com.cn/u/1222756123去看一下,里面还有几个我写的代码!当然,也可以加我的QQ:274839490

幽幽黄桷兰----建四狼
2006-05-05 14:59
快速回复:[原创]我用C写的类似劲舞团的东西(有点烂)
数据加载中...
 
   



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

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