From 8c7f343ac7a123fb921affd9a8b2bb8d57ee1bce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Nut=CC=A6iu?= Date: Thu, 21 Apr 2016 17:12:39 +0300 Subject: [PATCH] Adding comments to problem 1 --- lab9/1.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lab9/1.c b/lab9/1.c index 0329b96..1baf9bd 100644 --- a/lab9/1.c +++ b/lab9/1.c @@ -7,6 +7,11 @@ // // +/* This function draws the disks. It stops when it has drawn all the disks + * or before getting to a minimum y, which represents the height of the băț + * after that it picks a random color from an array of predefined colors and + * draws the disks before calling itself recusively. + */ void draw_disks(FILE * file, int disks, int peg, int width, int y) { if ( !disks ) { return; } // no more disks to draw if ( y < 120) { return; } // keeps the peg from overflowing; @@ -20,13 +25,21 @@ void draw_disks(FILE * file, int disks, int peg, int width, int y) { draw_disks(file, disks - 1, peg, width - width / 4, y - 21); } +/* + * This functions draws the bețe by using recursion, it stops when pegs is 0 + * and it places them at 100px distance between them. (i think) + */ void draw_pegs(FILE * file, int pegs, int width) { if ( !pegs ) { return; } // exit function fprintf(file, "\r\n", width); draw_pegs(file, pegs - 1, width + 100); } - +/* + * This function draws the whole thing. + * First it sets up the secene, it calls the function that draws "bețe", + * and after it calls the function that draws the disks. + */ void draw_peg_scene(FILE * file, int pegs, int disks) { int scene_width = pegs * 100; fprintf(file, "\r\n"); // start