Wednesday, October 17, 2012

DSDN 142: We Have Bark! And Working Suns!


So, I've managed to meld the two codes, and get the suns causing the trees to grow. We have a success! However, I'm still working on the issue of the suns relying on a refreshing background while the tree does not. This is however only an aesthetic decision, so that's something I can leave till a little later.
One of the things that I want to have functioning as well as the tree growing is that when it ages, it also changes colour from green to a more bark-ish brown. This was easy enough to set up in the ageing loop, and I got a tree that went from green to brown and then went on into red and then hot pink. 
While this did make me laugh, it's not exactly what I wanted. Mistakes make learning so much better though! Without this mistake, I wouldn't have taken the initiative to adapt the code further to suit my needs!

So, to rectify that issue, I placed some lines of code that inhibited the growth as soon as it got to the colour that I wanted. This resulted in a very pleasing brown finish when the tree reached "maturity".


Another part that I discovered when implementing this is that each branch ages separately, rather than each individual segment of the tree ageing separately, as I had anticipated. This actually looks really cool, because then there are little green segments that show new growth!

And now to the major clincher. I managed to fix my suns! That's so damn exciting. After thinking about it long and hard, I figured out that if I had a growing black circle that was drawn first before each frame of the sun, it would be just like if my suns were being refreshed! 

Managing to mitigate the problem relatively simply without having to re-write masses of code is great, and I can definitely say I'm very happy about that. The suns look great, however, because they are refreshing 60 times a second, there is a slight problem when they overlap with the tree.

What happens is that the tree flashes at a much slower framerate than the suns, causing it to feel very erratic and almost as if the tree were in pain. Now that's really interesting, because one of the things that I wanted to do in the beginning (when I had no idea quite how hard this all was!) was to make the tree die when the sun was placed too close to it. Now, I still don't know how I would code that, but this might be a simpler alternative to work with.

For some reason, you feel quite bad when this little tree flashes like that. It feels really painful, so it actually fits perfectly with my theme of care and prevention of damage. The suns don't actually damage the tree at all, it just flashes in an awful sort of way! Now, to make the flower!

No comments:

Post a Comment