RicardasSim

currentFrame

Oct 12th, 2019
780
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.40 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stdint.h>
  4.  
  5. #define MAX_FRAMES 2
  6.  
  7. uint32_t currentFrame = 0;
  8.  
  9. int main()
  10. {
  11.  
  12.     for(uint32_t i = 0; i < 10; ++i)
  13.     {
  14.         printf("%d ", currentFrame);
  15.         currentFrame = (currentFrame + 1) % MAX_FRAMES;
  16.     }
  17.  
  18.     return 0;
  19. }
  20.  
  21. /*
  22. output:
  23.  
  24. when MAX_FRAMES 2:
  25. 0 1 0 1 0 1 0 1 0 1
  26.  
  27. when MAX_FRAMES 3:
  28. 0 1 2 0 1 2 0 1 2 0
  29.  
  30. */
Advertisement
Add Comment
Please, Sign In to add comment