Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.74 KB | None | 0 0
  1. #pragma once
  2. #ifndef __ACTOR_HPP__
  3. #define __ACTOR_HPP__
  4.  
  5. #include "core/Level.hpp"
  6. #include "script/Common.hpp"
  7. #include "video/Surface.hpp"
  8.  
  9. namespace Core {
  10.  
  11.     class Level;
  12.  
  13.     class ActorBase {
  14.     private:
  15.  
  16.         int mId;
  17.  
  18.         float x;
  19.         float y;
  20.         int   layer;
  21.  
  22.         Video::Surface * mSurf;
  23.         Level          * mLevel;
  24.  
  25.     public:
  26.  
  27.         ActorBase(Level * lvl, int id) { mLevel = lvl; mId = id; }
  28.         ~ActorBase()                   { delete mSurf;           }
  29.  
  30.         int GetID() { return mId; }
  31.  
  32.         virtual float GetX()          { return x;     }
  33.         virtual void  SetX(float nx)  { x = nx;       }
  34.         virtual float GetY()          { return y;     }
  35.         virtual void  SetY(float ny)  { y = ny;       }
  36.         virtual int   GetLayer()      { return layer; }
  37.         virtual void  SetLayer(int l) { layer = l;    }
  38.  
  39.         virtual Video::Surface* GetSprite()                     { return mSurf; }
  40.         virtual void            SetSprite(Video::Surface* surf) { mSurf = surf; }
  41.  
  42.         virtual void  OnInit();
  43.         virtual void  OnTick(int ticks);
  44.         virtual void  OnKeyDown(int key);
  45.         virtual void  OnKeyUp(int key);
  46.         virtual void  OnMouseButtonDown(const char* button, int mx, int my);
  47.         virtual void  OnMouseButtonUp(const char* button, int mx, int my);
  48.         virtual void  OnMouseMotion(int x, int y, int relx, int rely);
  49.         virtual void  OnTouched(ActorBase* actor);
  50.         virtual void  OnExit();
  51.  
  52.         virtual void  OnDraw() { mSurf->Blit((int)x * mLevel->GetTileWidth(), (int)y * mLevel->GetTileHeight()); }
  53.  
  54.     };
  55.  
  56.     class Actor: public ActorBase {
  57.     private:
  58.  
  59.         v8::Persistent<v8::Context>    context;
  60.         v8::Handle<v8::ObjectTemplate> global;
  61.  
  62.         v8::Handle<v8::ObjectTemplate> CreateTemplate();
  63.  
  64.     public:
  65.        
  66.         v8::Persistent<v8::Object>     self;
  67.  
  68.         Actor();
  69.         ~Actor();
  70.        
  71.         v8::Persistent<v8::Object> Wrap();
  72.  
  73.     };
  74.  
  75. } // namespace Core
  76.  
  77. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement