设为首页 加入收藏

TOP

C语言制作打蜜蜂游戏(一)
2014-11-23 21:38:06 来源: 作者: 【 】 浏览:9
Tags:语言 制作 蜜蜂 游戏

#include"stdio.h"

#include"graphics.h"

int tanke_size=30,star_size=30;

int guan_ka=1;

/*1:blue 2:green 3:light blue 4:red 5:fen red 6:zong 7:white 8:light white*/

int tanke_current_x,tanke_current_y;

int tanke_left=20,tanke_right=620,tanke_top=20,tanke_bottom=450;

int fist_star_x,fist_star_y;

int zidan_current_x=-1,zidan_current_y=-1,zidan_color=4;

int mifeng_x[6][18],mifeng_y[6][18];

int mifeng_count=0;

void main()

{

int i,j,k;

int first_star_x=50;

int first_star_y=50;

ChuShiHuaGraphics();

rectangle(tanke_left-1,tanke_top-1,tanke_right+1,tanke_bottom);

tanke_current_x=290; tanke_current_y=410;

CreateTanke(tanke_current_x,tanke_current_y);

/*CreateStar(100,100); */

for(i=0;i<6;i++)

{

for(j=0;j<18;j++)

{

CreateStar(first_star_x,first_star_y,-1);

mifeng_x[i][j]=first_star_x;

mifeng_y[i][j]=first_star_y;

/* printf("(%d,%d)",mifeng_x[i][j],mifeng_y[i][j]);*/

first_star_x+= star_size;

mifeng_count++;

}

first_star_x=50;

first_star_y+=star_size;

}

/*printf("%d",mifeng_count);*/

StartGame();

getchar();

}

CreateStar(int x,int y,int color)

{

int A_x=x+15,A_y=y;

int B_x=x+2,B_y=y+10;

int C_x=x+7,C_y=y+30;

int D_x=x+22,D_y=y+30;

int E_x=x+28,E_y=y+10;

int temp_color;

temp_color=getcolor();

if (color==-1)

{

setcolor(x%8==0 x+1:x%8);

}

else

{

setcolor(color);

}

line(A_x,A_y,C_x,C_y);

line(A_x,A_y,D_x,D_y);

line(B_x,B_y,D_x,D_y);

line(B_x,B_y,E_x,E_y);

line(C_x,C_y,E_x,E_y);

setcolor(temp_color);

}

CreateTanke(int x,int y)

{

int twidth=4,tem_color;

tem_color=getcolor();

if(getcolor()!=getbkcolor())

{

setcolor(2);

}

rectangle(x,y+10,x+tanke_size,y+tanke_size);

circle(x+tanke_size/2,y+10+tanke_size/2-5,tanke_size/2-7);

rectangle(x+tanke_size/2-twidth/2,y,x+tanke_size/2+twidth/2,y+10+tanke_size/2-5-(tanke_size/2-7)-2+10);

setcolor(tem_color);

/*CreateZidan(5,5,getbkcolor()) ;*/

/*CreateZidan(5,5,6) ;*/

CreateZidan(int x ,int y,int color)

{

int temcolor=getcolor();

setcolor(color);

circle(x+15,y+15,tanke_size/2);

setcolor(temcolor);

}

StartGame()

{

char sign=;

while(1)

{

while(!kbhit())

{

AUTO();

}

sign=getch();

switch(sign)

{

casea:turn_left();break;

cased:turn_right();break;

case p: exit(0);break;

}

}

}

turn_left()

{

int x=tanke_curren


t_x,y=tanke_current_y;/*dang qian wei zhi*/

int temcolor;

if(x==tanke_left)

{

return;

}

temcolor=getcolor();

setcolor(getbkcolor());

CreateTanke(x,y);

setcolor(2);

x=x-tanke_size;

CreateTanke(x,y);

tanke_current_x=x;

setcolor(temcolor);

}

turn_right()

{

int x=tanke_current_x,y=tanke_current_y;

int temcolor;

if(x==tanke_right-tanke_size)

{

return;

}

temcolor=getcolor();

setcolor(0);

CreateTanke(x,y);

setcolor(2);

x=x+tanke_size;

CreateTanke(x,y);

tanke_current_x=x;

setcolor(temcolor);

AUTO()

{

/

首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇谈String与StringBuilder的性能 下一篇Windows编程基础 - 概述

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: