943,923 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 435
  • C++ RSS
Nov 21st, 2008
0

please help, this is what i have done so far

Expand Post »
C++ Syntax (Toggle Plain Text)
  1.  
  2.  
  3.  
  4. #include <conio.h>
  5. #include <graphics.h>
  6. #include <math.h>
  7. #include <stdlib.h>
  8. #include <dos.h>
  9. void serp(int level, int Ax, int Ay, int Bx, int By)
  10. {
  11. int poly[4]={Ax,Ay,Bx,By};
  12.  
  13. setfillstyle(SOLID_FILL,YELLOW);
  14.  
  15. if (level>0)
  16. {
  17.  
  18. serp(level-1, Ax,Ay ,(2*Ax+Bx)/3,(2*Ay+By)/3);
  19. serp(level-1,(2*Ax+Bx)/3,(2*Ay+By)/3,(Ax+Bx)/2+sqrt(3)*(Ay-By)/6,(Ay+By)/2+sqrt(3)*(Bx-Ax)/6);
  20. serp(level-1,(Ax+Bx)/2+sqrt(3)*(Ay-By)/6,(Ay+By)/2+sqrt(3)*(Bx-Ax)/6,(Ax+2*Bx)/3,(Ay+2*By)/3);
  21. serp(level-1,(Ax+2*Bx)/3,(Ay+2*By)/3,Bx,By);
  22. }
  23. else fillpoly(2,poly);
  24. }
  25.  
  26. int main(void)
  27. {
  28. int graphdriver=DETECT, graphmode;
  29. initgraph(&graphdriver, &graphmode, "");
  30.  
  31. int i, N=8, Bx=0, By=235, Ax=635, Ay=235;
  32.  
  33. for (i=0; i<N; i++)
  34. {
  35.  
  36. serp(0,Ax,Ay,Bx,By);
  37.  
  38. serp(1,Ax,Ay,Bx,By);
  39. serp(2,Ax,Ay,Bx,By);
  40. serp(3,Ax,Ay,Bx,By);
  41. serp(4,Ax,Ay,Bx,By);
  42. serp(5,Ax,Ay,Bx,By);
  43. serp(6,Ax,Ay,Bx,By);
  44. serp(7,Ax,Ay,Bx,By);
  45.  
  46. delay(1000);
  47. cleardevice();
  48. }
  49.  
  50. getch();
  51. closegraph();
  52. return 0;
  53. }

what i could like to know is how do i fill each object with different colours?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bids is offline Offline
3 posts
since Nov 2008
Nov 22nd, 2008
0

Re: please help, this is what i have done so far

I don't test it yet ..Try it..
C++ Syntax (Toggle Plain Text)
  1. setfillstyle(SOLID_FILL,level);
  2. // or
  3. fillpoly(level,poly);
Reputation Points: 47
Solved Threads: 69
Posting Whiz
cikara21 is offline Offline
340 posts
since Jul 2008
Nov 22nd, 2008
0

Re: please help, this is what i have done so far

thanks for your help
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bids is offline Offline
3 posts
since Nov 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Space Invaders - Game
Next Thread in C++ Forum Timeline: ordering arrays





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC