孤独的猫

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

#include "graphics.h"
#include "stdlib.h"
#include "conio.h"
#include "stdio.h"
#define IMAGE_SIZE 10
void draw_image();
void draw_stars();
void main()
{
  int gdriver=DETECT,gmode;
  void *pt_addr;
  int x,y,maxx,maxy,midx,midy,I;
  unsigned int size;
  initgraph(&gdriver,&gmode,"D:\\TC\\BGI");
  maxx=getmaxx();
  maxy=getmaxy();
  midx=maxx/2;
  midy=y=maxy/2;
  x=0;
  setcolor(YELLOW);
  settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);
  settextjustify(CENTER_TEXT,CENTER_TEXT);
  outtextxy(midx,400,"HELLO");
  setcolor(RED);
  setlinestyle(SOLID_LINE,0,THICK_WIDTH);
  ellipse(midx,midy,130,50,160,30);
  setlinestyle(SOLID_LINE,0,THICK_WIDTH);
  setcolor(LIGHTBLUE);
  for (I=0;I<13;I++)
  {
 ellipse(midx,midy,0,360,100,100-8*I);
 ellipse(midx,midy,0,360,100-8*I,100);
  }
  draw_image(x,y);
  size=imagesize(x,y-IMAGE_SIZE,x+(4*IMAGE_SIZE),y+IMAGE_SIZE);
  pt_addr=malloc(size);
  getimage(x,y-IMAGE_SIZE,x+(4*IMAGE_SIZE),y+IMAGE_SIZE,pt_addr);
  draw_stars();
  setcolor(GREEN);
  setlinestyle(SOLID_LINE,0,NORM_WIDTH);
  rectangle(0,0,maxx,maxy);
  while (!kbhit())
  {
 putimage(x,y-IMAGE_SIZE,pt_addr,XOR_PUT);
 x+=5;
 if (x>maxx) x=0;
 putimage(x,y-IMAGE_SIZE,pt_addr,XOR_PUT);
 delay(50);
  }
  free(pt_addr);
  closegraph();
}

void draw_image(int x,int y)
{
  moveto(x+10,y);
  setcolor(14);
  setfillstyle(1,4);
  linerel(-30,-20);
  moveto(x+25,y);
  linerel(-50,0);
  fillellipse(x+13,y,8,8);
}

void draw_stars()
{
  int dotx,doty,h,w,I;
  int color,maxcolor;
  maxcolor=getmaxcolor();
  w=getmaxx();
  h=getmaxy();
  srand(2000);
  for (I=0;I<5000;I++)
  {
 dotx=I+random(w-1);
 doty=I+random(h-1);
 color=random(maxcolor);
 putpixel(dotx,doty,color);
  }
}

posted on 2011-02-27 12:47  孤独的猫  阅读(487)  评论(0编辑  收藏  举报