My objective is to draw a diamond shaped object with unique border and fill characters, and a size specified by the user/data file. Also there are spaces between each character. The size that is specified is for one side of the diamond, on this example diamond the size would be 4.
1 2 3 4 5 6 7
$
$ $
$ * $
$ * * $
$ * $
$ $
$
So, I know that I have to use some combination of for loops.
Man am I lost. This is all I have.. I have thought about making some sort of bool for when it gets to the middle line to start going in reverse, or something like that but I cannot come up with how to switch from the border to fill, or fill to border, or spaces to border. Can someone point me in the right direction here?
As you go down the diamond starting from the top, the length of each slice of diamond first increases then decreases. So I think you could have two for() loops one after the other. The first counting up and the second counting down.
Then with each iteration of one of those loops you know how many characters there are in that particular 'slice' of diamond...
Note that I'm low on caffeine, so this may not be the best solution to a problem I've come up with.
Now you will want a for loop that runs immediately after the $ sign is placed that runs (size of the diamond - number of spaces before the $ in question - 1) * 2 times to fill in the... texture is all I can call it. It would add space on the even number and an asterisk on the odd (assuming the iterator starts from 0). On the last iteration, it would also add a $.
loop runs the correct amount of times. I didn't follow exactly what you were saying Albatross but it just gave me the idea to use the number of spaces before the border character in order to figure everything else out. But thanks for the help!