TapestryEngine

A 2D Platformer Game Engine
Log | Files | Refs

dbdbdd1b50590cd2bffe180a8c66317de08e476b.svn-base (1154B)


      1 #ifndef CAMERA_H
      2 #define CAMERA_H
      3 
      4 #include "Utils.h"
      5 #include "Console.h"
      6 #include "Actor.h"
      7 #include "Event.h"
      8 
      9 class Camera : public EventReceiver
     10 {
     11 public:
     12 	Camera() : mView() {}
     13 
     14 	Camera(int H, int W, int X, int Y, int lvlH, int lvlW);
     15 
     16 	bool LogBlocker(SDL_Rect* blocker);
     17 
     18 	SDL_Rect SmartAdjust(SDL_Rect* blocker);
     19 
     20 	SDL_Rect SetCameraPos(SDL_Renderer* ren, int Xpos, int Ypos);
     21 
     22 	SDL_Rect SetCameraPosUnbounded(SDL_Renderer* ren, int Xpos, int Ypos);
     23 
     24 	bool ArrowKeyMove(SDL_Renderer* ren, int xspd, int yspd, SDL_Event* eve);
     25 
     26 	bool ActorFollow(SDL_Renderer* ren, int Xbound, int Ybound);
     27 
     28 	bool EventProcess(Event eve);
     29 
     30 	int GetCamX()
     31 	{
     32 		return mView.x;
     33 	}
     34 
     35 	int GetCamY()
     36 	{
     37 		return mView.y;
     38 	}
     39 
     40 	int GetCenterX()
     41 	{
     42 		return mView.x + (mView.w / 2);
     43 	}
     44 
     45 	int GetCenterY()
     46 	{
     47 		return mView.y + (mView.h / 2);
     48 	}
     49 
     50 	SDL_Rect* GetCamView()
     51 	{
     52 		return &mView;
     53 	}
     54 
     55 	void CamResize(int H, int W)
     56 	{
     57 		mView.h = H;
     58 		mView.w = W;
     59 	}
     60 
     61 	void SetFollowTarget(Actor* tar)
     62 	{
     63 		mFollowTarget = tar;
     64 	}
     65 
     66 protected:
     67 	SDL_Rect mView;
     68 	int mLastMoveUpdate;
     69 
     70 	int mlvlH;
     71 	int mlvlW;
     72 
     73 	std::vector<SDL_Rect*> mBlockers;
     74 
     75 	Actor* mFollowTarget;
     76 };
     77 
     78 
     79 #endif