Advertisement
Guest User

Untitled

a guest
Sep 15th, 2013
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1.     int mouseX,mouseY;
  2.     void Unit::handle_input()
  3.     {
  4.         if(occur.type == SDL_MOUSEBUTTONDOWN)
  5.         {
  6.             mouseX = occur.button.x;
  7.             mouseY = occur.button.y;
  8.         }
  9.     }
  10. Pass mouseX and mouseY as reference to the handle_input function.
  11.  
  12.     void Unit::show()
  13.     {
  14.         int BoxX;
  15.         int BoxY;
  16.         Box.x = BoxX;
  17.         Box.y = BoxY;
  18.         SDL_Rect unitOffset;
  19.         unitOffset.x = BoxX;
  20.         unitOffset.y = BoxY;
  21.         SDL_BlitSurface(Unit,NULL,screen,unitOffset);
  22.     }
  23. What's happening here? You create two ints and assign them to the previous ones? You know they are zero-initialized? So basically `BoxX, BoxY, Box.x, Box.y, unitOffset.x, unitOffset.y` are all zeros.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement