2017-04-30 16:23:47 +00:00
|
|
|
//Camera class body
|
|
|
|
|
|
|
|
#include"camera.h"
|
|
|
|
|
2017-06-17 16:02:03 +00:00
|
|
|
Camera::Camera(int mapWidth, int mapHeight,int screenWidth, int screenHeight){
|
|
|
|
mW = mapWidth;
|
|
|
|
mH = mapHeight;
|
2017-04-30 19:23:48 +00:00
|
|
|
scW = screenWidth;
|
2017-06-17 16:02:03 +00:00
|
|
|
scH = screenHeight;
|
2017-04-30 19:23:48 +00:00
|
|
|
}
|
|
|
|
|
2017-04-30 16:23:47 +00:00
|
|
|
void Camera::update(int playerX, int playerY){
|
2017-06-17 16:02:03 +00:00
|
|
|
//Make the camera move when the player hits the middle of the screen
|
2017-06-17 17:12:59 +00:00
|
|
|
if(mW != scW){
|
|
|
|
if(playerX >= scW/2) posX = playerX - scW/2;
|
|
|
|
else posX = 0;
|
|
|
|
if(playerX >= mW - scW/2) posX = mW - scW;
|
|
|
|
}
|
2017-04-30 19:23:48 +00:00
|
|
|
else posX = 0;
|
2017-04-30 16:23:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int Camera::getPosX(){
|
|
|
|
return posX;
|
|
|
|
};
|
|
|
|
|
|
|
|
int Camera::getPosY(){
|
|
|
|
return posY;
|
|
|
|
};
|