標(biāo)題: 一些小游戲C++程序源碼(很經(jīng)典) [打印本頁]

作者: 草棚    時(shí)間: 2018-5-25 08:40
標(biāo)題: 一些小游戲C++程序源碼(很經(jīng)典)



部分源程序如下:
  1. #include <graphics.h>
  2. #include <time.h>
  3. #include <math.h>

  4. void paintstar(double x, double y, double r, double a)
  5. {
  6.     int pt[10];
  7.     for (int n = 0; n < 5; ++n)
  8.     {
  9.         pt[n*2] = (int)( -cos( PI * 4 / 5 * n + a ) * r + x );
  10.         pt[n*2+1] = (int)( sin( PI * 4 / 5 * n + a) * r + y );
  11.     }
  12.     fillpoly(5, pt);
  13. }

  14. int main()
  15. {
  16.     initgraph( 640, 480 );
  17.     setcolor( RGB(0xff, 0xff, 0xff) );
  18.     setfillcolor( RGB(0, 0, 0xff) );
  19.     setrendermode(RENDER_MANUAL);
  20.     double r = 0;
  21.     for ( ; is_run(); delay_fps(60) )
  22.     {
  23.         r += 0.02;
  24.         if (r > PI * 2) r -= PI * 2;

  25.         cleardevice();
  26.         paintstar(300, 200, 100, r);
  27.     }
  28.     return 0;
  29. }

復(fù)制代碼

所有資料51hei提供下載:
示例程序.7z (1.51 MB, 下載次數(shù): 69)



作者: 2234704778    時(shí)間: 2021-3-27 22:25
可惜沒有象棋的源代碼




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1