Source code for this project is on sourceforge, here.
The first thing about this project is that it requires several images. It is a very simple way of cycling through sprites. To work with these images, we will simply have an array containing each image's GUID.
The function that handles the image cycling is very simple. All it does is wait for a keyboard stroke. If it senses the up or down arrow, it will point to the next image in the given direction.
RotateUp() and RotateDown() are basically the same function. They take in a pointer to the current position in the array, the index of that position, and the length of the array. For this particular display, I did not want the images to loop back and start the cycle over again, and I wanted them to stop once the ends of the array were reached and not go past it. To do that, I simply returned the original GUID that was passed in rather than a new one. It would be a simple change to make the images cycle back around by using a mod operator. If it is not at the end, the function will simply point to the next element in the array in the given direction.
The main function does a basic error check, displays the directions, and calls the function that deals with image cycling.
No comments:
Post a Comment