Advertisement
sombriks

step phase on character

Mar 9th, 2012
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. void Sprite::step(int delta, SDL_Event event) {
  2.     if (controller) {
  3.         int space = delta * speed;
  4. //      printf("Sprite[%s] will move %d on delta %d\n",name,space,delta);
  5.         controller->step(delta, event);
  6.         if (controller->canUp()) {
  7.             pos.y -= space;
  8.             direction = up;
  9.         } else if (controller->canDown()) {
  10.             pos.y += space;
  11.             direction = down;
  12.         }
  13.         if (controller->canRight()) {
  14.             pos.x += space;
  15.             direction = right;
  16.         } else if (controller->canLeft()) {
  17.             pos.x -= space;
  18.             direction = left;
  19.         }
  20.  
  21.         if (controller->moved()) {
  22.             cur += delta;
  23.             if (cur > tpf) {
  24.                 cur = 0;
  25.                 anim++;
  26.                 anim %= seq->size();
  27.             }
  28.         } else
  29.             anim = 0;
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement