I am working through the Vivace tutorial. I am at the point of animation, or moving things around the screen. At the end of the lesson it states extra points for preventing the randomly bouncing objects from drifting off screen.
I manage to get it to work but thanks to the circle and inverted (up ramped) line I ended up with code addressing things individually instead of a system group approach. Maybe this is good as it gets but I thought I'd ask if others had a better approach I didn't consider. Any input would be appreciated.
I tried to comment the sections I added or altered. Thanks.
Since you're using objects, you can try OOP.
Give Each object a GetLeft, SetLeft, GetRight, SetRight, GetTop, SetTop, GetBottom, and SetBottom function. Now you can easily constrain any object to the boundaries of the screen.
Sounds good. I was thinking there was a more systemic way than using a line by line deviation. Thanks.