#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <graphics.h>
#define LEFT 0x4b00
#define RIGHT 0x4d00
#define DOWN 0x5000
#define UP 0x4800
#define ESC 0x011b
#define SPACE 0x39
struct
{
int x;
int y;
}face;
void initgr(void)
{
int gd = DETECT, gm = 0;
initgraph(&gd, &gm, "");
}
void Draw();
void play();
void Drawgun(int x,int y);
int main(void)
{
initgr();
play();
closegraph();
getch();
return 0;
}
void Draw()
{
int i;
setcolor(11);
/* setlinestyle(SOLID_LINE,0,THICK_WIDTH);*/
for(i=50;i<=600;i+=10)
{
rectangle(i,40,i+10,49);
rectangle(i,451,i+10,460);
}
for(i=40;i<=450;i+=10)
{
rectangle(50,i,59,i+10);
rectangle(601,i,610,i+10);
}
}
void play()
{
int key;
face.x=450;
face.y=200;
cleardevice();
setcolor(GREEN);
circle(face.x,face.y,15);
Draw();
while(1)
{
key=bioskey(0);
setcolor(BLACK);
switch(key)
{
case LEFT: circle(face.x,face.y,15);
face.x-=5;
if(face.x<79)
face.x+=5;
break;
case RIGHT: circle(face.x,face.y,15);
face.x+=5;
if(face.x>583)
face.x-=5;
break;
case DOWN: circle(face.x,face.y,15);
face.y+=5;
if(face.y>433)
face.y-=5;
break;
case UP: circle(face.x,face.y,15);
face.y-=5;
if(face.y<67)
face.y+=5;
break;
case SPACE: Drawgun(face.x,face.y);
break;
case ESC: exit(0);
}
setcolor(GREEN);
circle(face.x,face.y,15);
}
}
void Drawgun(int x,int y)
{
int i;
setcolor(RED);
for(i=0;i<200;i++)
{
circle(x+i,y,3);
setcolor(BLACK);
delay(10000);
circle(x+i,y,3);
setcolor(RED);
}
}
好像执行不了Drawgun()这个函数.刚接触图形这方面的.
哪个大哥帮下啊.