Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #pragma once
  2. #include "SDL.h"
  3. #include <cstdlib>
  4.  
  5. struct Tile
  6. {
  7.     int type;
  8.     int clip;
  9.     int min;
  10.     int max;
  11.     int frame;
  12.  
  13.     Tile( int type ) : type(type)
  14.     {
  15.       //sets the starting and ending clips
  16.         switch ( type )
  17.         {
  18.         //background
  19.         case 0:
  20.             min = 0;
  21.             max = 7;
  22.             clip = (rand() % (max - min)) + min;
  23.             break;
  24.  
  25.         //ground
  26.         case 1:
  27.             min = 8;
  28.             max = 13;
  29.             clip = (rand() % (max - min)) + min;
  30.             break;
  31.  
  32.         //toxic
  33.         case 2:
  34.             min = 14;
  35.             max = 17;
  36.             clip = (rand() % (max - min)) + min;
  37.             break;
  38.  
  39.         //lift
  40.         case 3:
  41.             min = 18;
  42.             max = 25;
  43.             clip = (rand() % (max - min)) + min;
  44.         }
  45.         frame = rand() % 30;
  46.     }
  47.  
  48.     void update()
  49.     {
  50.       //update the animation
  51.         if ( frame % 30 == 0 )
  52.         {
  53.             clip++;
  54.             if ( clip > max )
  55.                 clip = min;
  56.         }
  57.         frame++;
  58.     }
  59. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement