Recent Posts


Home » » Animated Name Printer in C++ Programming

Animated Name Printer in C++ Programming

This program generates pattern of ‘*’ of given input string.It has also chessboard type background. It is animated and continuously changes colour.

  1. /*This Program Makes Pattern Of String You Enter.

  2. Input must be string without numbers and capital letters.*/


  3. /* Variable info

  4. r = radius of curve in characters like B and O

  5. bkp = horisontal position of cursor

  6. hkp = vertical position of cursor

  7. dly = time delay in miliseconds between to animation screens

  8. name = input string

  9. other are temporary variables

  10. */


  11. #include

  12. #include

  13. #define r 5

  14. #include

  15. #include


  16. void main()

  17. {

  18. clrscr();

  19. int i,bkp=0,hkp=1,x,y,k=30,dly,cc,j,m=0;

  20. char name[12],p;

  21. //textbackground(BLACK);

  22. cprintf("Enter Your name(only small chars eg. hello): ");

  23. scanf("%s",name);

  24. cprintf("Enter color change speed(eg. 30) : ");

  25. scanf("%d",&dly);

  26. gotoxy(40,1);

  27. cprintf("\tBhargav Patel");

  28. _setcursortype(_NOCURSOR);

  29. bkp:

  30. bkp=0;

  31. hkp=1;

  32. clrscr();

  33. //klp:

  34. for(cc=0;cc<24;cc++)

  35. {

  36. for(j=0;j<72;j++)

  37. {

  38. if(cc%8<4)

  39. {

  40. if(j%16<8)

  41. {

  42. textcolor(m);

  43. }

  44. else

  45. {

  46. textcolor(m+1);

  47. }

  48. }

  49. else

  50. {

  51. if(j%16>=8)

  52. {


  53. textcolor(m);

  54. }

  55. else

  56. {

  57. textcolor(m+1);

  58. }


  59. }


  60. cprintf("%c",219);


  61. }

  62. printf("\n");

  63. }

  64. m++;

  65. delay(500);

  66. //goto klp;



  67. for(i=0;name[i]!='\0';i++)

  68. {

  69. textcolor(k-(i%9));

  70. //cprintf("%c",name[i]);


  71. switch(name[i])

  72. {


  73. case 'a':


  74. for(x=1;x<=8;x++)

  75. {

  76. y=x;

  77. delay(dly);

  78. gotoxy(bkp+(7+y),hkp+(x));

  79. cprintf("**");

  80. delay(dly);

  81. gotoxy(bkp+(9-x),hkp+(y));

  82. cprintf("**");

  83. }

  84. gotoxy(bkp+(6),hkp+(5));

  85. for(x=1;x<=7;x++)

  86. {

  87. delay(dly);

  88. cprintf("*");

  89. }

  90. bkp+=17;

  91. break;



  92. case 'b':


  93. for(x=1;x<=4;x++)

  94. {

  95. y=2*sqrt((r*r)-(x*x));

  96. gotoxy(bkp+(y-3),hkp+(3+x));

  97. delay(dly);

  98. cprintf("***");

  99. gotoxy(bkp+(y-3),hkp+(5-x));

  100. delay(dly);

  101. cprintf("***");

  102. gotoxy(bkp+(y-3),hkp+(9+x));

  103. delay(dly);cprintf("***");

  104. gotoxy(bkp+(y-3),hkp+(11-x));

  105. delay(dly);cprintf("***");

  106. }

  107. for(x=1;x<=13;x++)

  108. {

  109. gotoxy(bkp+(1),hkp+(x));

  110. delay(dly);cprintf("**");

  111. }

  112. bkp+=9;

  113. break;



  114. case 'c':


  115. for(x=1;x<=4;x++)

  116. {

  117. y=4*sqrt((r*r)-(x*x));

  118. gotoxy(bkp+(20-y),hkp+(4+x));

  119. delay(dly);cprintf("***");

  120. gotoxy(bkp+(20-y),hkp+(6-x));

  121. delay(dly);cprintf("***");

  122. }

  123. bkp+=11;

  124. break;




  125. case 'd':



  126. for(x=1;x<=5;x++)

  127. {

  128. y=4*sqrt((100)-(x*x));

  129. gotoxy(bkp+(y-31),hkp+(4+x));

  130. delay(dly);cprintf("***");

  131. gotoxy(bkp+(y-31),hkp+(6-x));

  132. delay(dly);cprintf("***");

  133. }

  134. for(x=1;x<=9;x++)

  135. {

  136. gotoxy(bkp+(1),hkp+(x));

  137. delay(dly);cprintf("**");

  138. }


  139. bkp+=11;

  140. break;





  141. case 'e':


  142. for(x=1;x<=10;x++)

  143. {

  144. gotoxy(bkp+1,hkp+x);

  145. delay(dly);cprintf("**");

  146. }

  147. for(x=3;x<=7;x++)

  148. {

  149. gotoxy(bkp+x,hkp+1);

  150. delay(dly);cprintf("*");

  151. gotoxy(bkp+x,hkp+2);

  152. delay(dly);cprintf("*");

  153. gotoxy(bkp+x,hkp+5);

  154. delay(dly);cprintf("*");

  155. gotoxy(bkp+x,hkp+6);

  156. delay(dly);cprintf("*");

  157. gotoxy(bkp+x,hkp+9);

  158. delay(dly);cprintf("*");

  159. gotoxy(bkp+x,hkp+10);

  160. delay(dly);cprintf("*");

  161. }

  162. bkp+=8;


  163. break;




  164. case 'f':


  165. for(x=1;x<=10;x++)

  166. {

  167. gotoxy(bkp+1,hkp+x);

  168. delay(dly);cprintf("**");

  169. }

  170. for(x=3;x<=7;x++)

  171. {

  172. gotoxy(bkp+x,hkp+1);

  173. delay(dly);cprintf("*");

  174. gotoxy(bkp+x,hkp+2);

  175. delay(dly);cprintf("*");

  176. gotoxy(bkp+x,hkp+5);

  177. delay(dly);cprintf("*");

  178. gotoxy(bkp+x,hkp+6);

  179. delay(dly);cprintf("*");


  180. }

  181. bkp+=8;

  182. break;




  183. case 'g':



  184. for(x=1;x<=5;x++)

  185. {

  186. y=3*sqrt((100)-(x*x));

  187. gotoxy(bkp+(30-y),hkp+(4+x));

  188. delay(dly);cprintf("***");

  189. gotoxy(bkp+(30-y),hkp+(6-x));

  190. delay(dly);cprintf("***");

  191. gotoxy(bkp+(y-19),hkp+(4+x));

  192. delay(dly);cprintf("***");

  193. }

  194. gotoxy(bkp+7,hkp+5);

  195. for(x=1;x<=7;x++)

  196. {

  197. delay(dly);cprintf("*");

  198. }

  199. bkp+=13;

  200. break;



  201. case 'h':


  202. for(x=1;x<=10;x++)

  203. {

  204. gotoxy(bkp+1,hkp+x);

  205. delay(dly);cprintf("**");

  206. gotoxy(bkp+7,hkp+x);

  207. delay(dly);cprintf("**");

  208. }

  209. for(x=3;x<=7;x++)

  210. {

  211. gotoxy(bkp+x,hkp+5);

  212. delay(dly);cprintf("*");

  213. gotoxy(bkp+x,hkp+6);

  214. delay(dly);cprintf("*");

  215. }

  216. bkp+=9;

  217. break;



  218. case 'i':


  219. for(x=1;x<=10;x++)

  220. {

  221. gotoxy(bkp+4,hkp+x);

  222. delay(dly);cprintf("**");

  223. }

  224. for(x=1;x<=8;x++)

  225. {

  226. gotoxy(bkp+x,hkp+1);

  227. delay(dly);cprintf("*");

  228. gotoxy(bkp+x,hkp+2);

  229. delay(dly);cprintf("*");

  230. gotoxy(bkp+x,hkp+9);

  231. delay(dly);cprintf("*");

  232. gotoxy(bkp+x,hkp+10);

  233. delay(dly);cprintf("*");

  234. }

  235. bkp+=9;

  236. break;




  237. case 'j':



  238. for(x=1;x<=5;x++)

  239. {

  240. y=3*sqrt((100)-(x*x));

  241. gotoxy(bkp+(30-y),hkp+(6+x));

  242. delay(dly);cprintf("**");

  243. //gotoxy(bkp+(30-y),hkp+(6-x));

  244. //delay(dly);cprintf("***");

  245. gotoxy(bkp+(y-21),hkp+(6+x));

  246. delay(dly);cprintf("**");

  247. }

  248. for(x=1;x<=7;x++)

  249. {

  250. gotoxy(bkp+8,hkp+x);

  251. delay(dly);cprintf("**");

  252. }

  253. for(x=3;x<=13;x++)

  254. {

  255. gotoxy(bkp+x,hkp+1);

  256. delay(dly);cprintf("*");

  257. gotoxy(bkp+x,hkp+2);

  258. delay(dly);cprintf("*");

  259. }

  260. bkp+=14;

  261. break;




  262. case 'k':



  263. for(x=1;x<=10;x++)

  264. {

  265. gotoxy(bkp+1,hkp+x);

  266. delay(dly);cprintf("**");

  267. }

  268. for(x=1;x<=6;x++)

  269. {

  270. y=x;

  271. gotoxy(bkp+(y),hkp+(x+4));

  272. delay(dly);cprintf("**");

  273. gotoxy(bkp+(8-x),hkp+(y));

  274. delay(dly);cprintf("**");

  275. }


  276. bkp+=9;

  277. break;



  278. case 'l':



  279. for(x=1;x<=10;x++)

  280. {

  281. gotoxy(bkp+1,hkp+x);

  282. delay(dly);cprintf("**");

  283. }

  284. for(x=3;x<=7;x++)

  285. {

  286. gotoxy(bkp+x,hkp+9);

  287. delay(dly);cprintf("*");

  288. gotoxy(bkp+x,hkp+10);

  289. delay(dly);cprintf("*");

  290. }


  291. bkp+=8;

  292. break;




  293. case 'm':



  294. for(x=1;x<=10;x++)

  295. {

  296. gotoxy(bkp+1,hkp+x);

  297. delay(dly);cprintf("**");

  298. gotoxy(bkp+11,hkp+x);

  299. delay(dly);cprintf("**");

  300. }

  301. for(x=1;x<=6;x++)

  302. {

  303. y=x;

  304. gotoxy(bkp+(y),hkp+(x));

  305. delay(dly);cprintf("**");

  306. gotoxy(bkp+(12-x),hkp+(y));

  307. delay(dly);cprintf("**");

  308. }



  309. bkp+=13;

  310. break;



  311. case 'n':



  312. for(x=1;x<=10;x++)

  313. {

  314. gotoxy(bkp+1,hkp+x);

  315. delay(dly);cprintf("**");

  316. gotoxy(bkp+10,hkp+x);

  317. delay(dly);cprintf("**");

  318. }

  319. for(x=1;x<=10;x++)

  320. {

  321. y=x;

  322. gotoxy(bkp+(y),hkp+(x));

  323. delay(dly);cprintf("**");

  324. }


  325. bkp+=13;

  326. break;




  327. case 'o':




  328. for(x=1;x<=5;x++)

  329. {

  330. y=2*sqrt((100)-(x*x));

  331. gotoxy(bkp+(20-y),hkp+(4+x));

  332. delay(dly);cprintf("***");

  333. gotoxy(bkp+(20-y),hkp+(6-x));

  334. delay(dly);cprintf("***");

  335. gotoxy(bkp+(y-11),hkp+(4+x));

  336. delay(dly);cprintf("***");

  337. gotoxy(bkp+(y-11),hkp+(6-x));

  338. delay(dly);cprintf("***");

  339. }


  340. bkp+=10;

  341. break;



  342. case 'p':



  343. for(x=1;x<=4;x++)

  344. {

  345. y=2*sqrt((r*r)-(x*x));

  346. gotoxy(bkp+(y-3),hkp+(3+x));

  347. delay(dly);cprintf("***");

  348. gotoxy(bkp+(y-3),hkp+(5-x));

  349. delay(dly);cprintf("***");

  350. }

  351. for(x=1;x<=11;x++)

  352. {

  353. gotoxy(bkp+(1),hkp+(x));

  354. delay(dly);cprintf("**");

  355. }

  356. bkp+=8;

  357. break;




  358. case 'q':



  359. for(x=1;x<=5;x++)

  360. {

  361. y=2*sqrt((100)-(x*x));

  362. gotoxy(bkp+(20-y),hkp+(4+x));

  363. delay(dly);cprintf("***");

  364. gotoxy(bkp+(20-y),hkp+(6-x));

  365. delay(dly);cprintf("***");

  366. gotoxy(bkp+(y-11),hkp+(4+x));

  367. delay(dly);cprintf("***");

  368. gotoxy(bkp+(y-11),hkp+(6-x));

  369. delay(dly);cprintf("***");

  370. }

  371. for(x=1;x<=5;x++)

  372. {

  373. y=x;

  374. gotoxy(bkp+(y+4),hkp+(x+5));

  375. delay(dly);cprintf("**");

  376. }

  377. bkp+=11;

  378. break;




  379. case 'r':



  380. for(x=1;x<=4;x++)

  381. {

  382. y=2*sqrt((r*r)-(x*x));

  383. gotoxy(bkp+(y-3),hkp+(3+x));

  384. delay(dly);cprintf("***");

  385. gotoxy(bkp+(y-3),hkp+(5-x));

  386. delay(dly);cprintf("***");

  387. }

  388. for(x=1;x<=11;x++)

  389. {

  390. gotoxy(bkp+(1),hkp+(x));

  391. delay(dly);cprintf("**");

  392. }

  393. for(x=1;x<=5;x++)

  394. {

  395. y=x;

  396. gotoxy(bkp+(y+3),hkp+(x+6));

  397. delay(dly);cprintf("**");

  398. }

  399. bkp+=9;

  400. break;





  401. case 's':



  402. for(x=1;x<=4;x++)

  403. {

  404. y=3*sqrt((r*r)-(x*x));

  405. gotoxy(bkp+(y-7),hkp+(x+9));

  406. delay(dly);cprintf("**");

  407. gotoxy(bkp+(y-7),hkp+(10-x));

  408. delay(dly);cprintf("**");

  409. gotoxy(bkp+(15-y),hkp+(x+4));

  410. delay(dly);cprintf("**");

  411. gotoxy(bkp+(15-y),hkp+(5-x));

  412. delay(dly);cprintf("**");

  413. }

  414. bkp+=9;

  415. break;



  416. case 't':



  417. for(x=1;x<=10;x++)

  418. {

  419. gotoxy(bkp+4,hkp+x);

  420. delay(dly);cprintf("**");

  421. }

  422. for(x=1;x<=8;x++)

  423. {

  424. gotoxy(bkp+x,hkp+1);

  425. delay(dly);cprintf("*");

  426. gotoxy(bkp+x,hkp+2);

  427. delay(dly);cprintf("*");

  428. }

  429. bkp+=9;

  430. break;



  431. case 'u':


  432. for(x=1;x<=5;x++)

  433. {

  434. y=3*sqrt((100)-(x*x));

  435. gotoxy(bkp+(30-y),hkp+(5+x));

  436. delay(dly);cprintf("**");

  437. //gotoxy(bkp+(30-y),hkp+(6-x));

  438. //delay(dly);cprintf("***");

  439. gotoxy(bkp+(y-20),hkp+(5+x));

  440. delay(dly);cprintf("**");

  441. }

  442. for(x=1;x<=5;x++)

  443. {

  444. gotoxy(bkp+1,hkp+x);

  445. delay(dly);cprintf("**");

  446. gotoxy(bkp+9,hkp+x);

  447. delay(dly);cprintf("**");

  448. }

  449. bkp+=11;

  450. break;



  451. case 'v':



  452. for(x=1;x<=3;x++)

  453. {

  454. gotoxy(bkp+1,hkp+x);

  455. delay(dly);cprintf("**");

  456. gotoxy(bkp+10,hkp+x);

  457. delay(dly);cprintf("**");

  458. }

  459. for(x=1;x<=4;x++)

  460. {

  461. y=x;

  462. gotoxy(bkp+(y+1),hkp+(x+3));

  463. delay(dly);cprintf("**");

  464. gotoxy(bkp+(10-x),hkp+(y+3));

  465. delay(dly);cprintf("**");

  466. }

  467. bkp+=12;

  468. break;




  469. case 'w':




  470. for(x=1;x<=3;x++)

  471. {

  472. gotoxy(bkp+1,hkp+x);

  473. delay(dly);cprintf("**");

  474. gotoxy(bkp+15,hkp+x);

  475. delay(dly);cprintf("**");

  476. }

  477. for(x=1;x<=4;x++)

  478. {

  479. y=x;

  480. gotoxy(bkp+(y),hkp+(x+2));

  481. delay(dly);cprintf("**");

  482. gotoxy(bkp+(9-x),hkp+(y+2));

  483. delay(dly);cprintf("**");

  484. }

  485. for(x=1;x<=4;x++)

  486. {

  487. y=x;

  488. gotoxy(bkp+(y+6),hkp+(x+2));

  489. delay(dly);cprintf("**");

  490. gotoxy(bkp+(16-x),hkp+(y+2));

  491. delay(dly);cprintf("**");

  492. }

  493. bkp+=17;

  494. break;



  495. case 'x':



  496. for(x=1;x<=8;x++)

  497. {

  498. y=x;

  499. gotoxy(bkp+(y),hkp+(x));

  500. delay(dly);cprintf("**");

  501. gotoxy(bkp+(9-x),hkp+(y));

  502. delay(dly);cprintf("**");

  503. }

  504. bkp+=10;

  505. break;



  506. case 'y':



  507. for(x=1;x<=4;x++)

  508. {

  509. y=x;

  510. gotoxy(bkp+(y),hkp+(x));

  511. delay(dly);cprintf("**");

  512. gotoxy(bkp+(8-x),hkp+(y));

  513. delay(dly);cprintf("**");

  514. }

  515. for(x=3;x<=6;x++)

  516. {

  517. gotoxy(bkp+4,hkp+x);

  518. delay(dly);cprintf("**");

  519. }

  520. bkp+=8;

  521. break;



  522. case 'z':


  523. for(x=1;x<=8;x++)

  524. {

  525. y=x;

  526. gotoxy(bkp+(9-x),hkp+(y));

  527. delay(dly);cprintf("**");

  528. }

  529. for(x=1;x<=8;x++)

  530. {

  531. gotoxy(bkp+x,hkp+1);

  532. delay(dly);cprintf("*");

  533. gotoxy(bkp+x,hkp+2);

  534. delay(dly);cprintf("*");

  535. gotoxy(bkp+(x),hkp+8);

  536. delay(dly);cprintf("*");

  537. gotoxy(bkp+(x),hkp+9);

  538. delay(dly);cprintf("*");

  539. }

  540. bkp+=10;

  541. break;




  542. default:

  543. delay(dly);cprintf("Error in Input Or String is large to fit in Screen. Try Again");

  544. break;

  545. }

  546. bkp++;


  547. if(bkp>=70)

  548. {

  549. bkp=0;

  550. hkp+=11;

  551. }


  552. }

  553. k++;

  554. delay(1500);

  555. goto bkp;

  556. }



Share this article :