C语言基于graphics.h实现圣诞树

  #pragma once

  #ifndef _ICON_H_

  #define _ICON_H_

  #include

  #include

  #include

  #include

  #include

  #include

  #include

  #pragma comment(lib,"winmm.lib")

  using namespace std;

  void init()

  {

  initgraph(600, 720);

  setbkcolor(RGB(255, 255, 255));

  cleardevice();

  }

  void drawTree()

  {

  IMAGE tree;

  setfillcolor(RGB(255, 255, 255));

  setbkcolor(RGB(255, 255, 255));

  loadimage(&tree, "tree.jpg", 600, 580, true);

  putimage(0, 150, &tree);

  }

  void drawDelc()

  {

  IMAGE delc;

  setfillcolor(RGB(255, 255, 255));

  setbkcolor(RGB(255, 255, 255));

  loadimage(&delc, "delc.jpg", 150, 150, true);

  putimage(220, 0, &delc);

  }

  void Star(int x,int y)

  {

  IMAGE star;

  setfillcolor(RGB(255, 255, 255));

  setbkcolor(RGB(255, 255, 255));

  loadimage(&star, "star.jpg", 50, 50, true);

  putimage(x, y, &star);

  }

  void Shining(int x,int y)

  {

  setbkcolor(RGB(255, 255, 255));

  clearrectangle(x, y, x+50, y+50);

  Sleep(400);

  Star(x, y);

  }

  void music()

  {

  mciSendString(TEXT("open Christmas.wav alias bgm"), NULL, 0, NULL);

  mciSendString(TEXT("play bgm"), NULL, 0, NULL);

  }

  void close()

  {

  getchar();

  closegraph();

  }

  #endif // !_ICON_H_