Advertisement
Vchavauty

Object.cpp

Jul 26th, 2013
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.32 KB | None | 0 0
  1. #include "Object.h"
  2.  
  3. Object::Object()
  4. {
  5.     Img_Surface = NULL;
  6.     PosX = 0;
  7.     PosY = 0;
  8.     MaxJump = 10;
  9.     CurrentFrame[0] = 0;
  10.     CurrentFrame[1] = 0;
  11.     State = STATE_PASSIVE;
  12. }
  13.  
  14. bool Object::Init(char *File)
  15. {
  16.     PosX = 0;
  17.     PosY = 0;
  18.     IMGFile = File; //START COMMENT HERE
  19.     if((Img_Surface = MySurface::OnLoad(File)) == NULL)
  20.     {
  21.         return false;
  22.     }
  23.     MySurface::Transparent(Img_Surface, 255, 0, 255);
  24.     //END COMMENTER HERE
  25.  
  26.     return true;
  27. }
  28.  
  29. int Object::RetrievePosX()
  30. {
  31.     return PosX;
  32. }
  33. int Object::RetrievePosY()
  34. {
  35.     return PosY;
  36. }
  37.  
  38. int Object::RetrieveFrameByID(int ID)
  39. {
  40.     switch(ID)
  41.     {
  42.     case 0:
  43.         return CurrentFrame[0];
  44.     case 1:
  45.         return CurrentFrame[1];
  46.    }
  47.     return 0;
  48. }
  49.  
  50. void Object::SendAnimation()
  51. {
  52.     Animate.Anima();
  53. }
  54.  
  55. void Object::ReceiveEvent(int Event, int Direction)
  56. {
  57.     if(Event == EVENT_STOP)
  58.     {
  59.         Animate.Working = false;
  60.     }
  61.     else if(Event == EVENT_WALK)
  62.     {
  63.         Animate.Working = true;
  64.         Animate.Direction = Direction;
  65.     }
  66. }
  67.  
  68. void Object::GetValues()
  69. {
  70.     PosX = Animate.retrievePosX();
  71.     PosY = Animate.retrievePosY();
  72.     int CFrameID = Animate.GetCurrentFrame();
  73.     CurrentFrame[0] = (CFrameID / 3) * 64;
  74.     CurrentFrame[1] = (CFrameID % 3) * 64;
  75.  
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement