26 lines
449 B
C++
26 lines
449 B
C++
|
//Camera class body
|
||
|
|
||
|
#include"camera.h"
|
||
|
|
||
|
Camera::Camera(int mapWidth,int screenWidth){
|
||
|
mW = mapWidth;
|
||
|
scW = screenWidth;
|
||
|
}
|
||
|
|
||
|
void Camera::update(int playerX, int playerY){
|
||
|
//Make the camera when the player hits the middle of the screem
|
||
|
if(playerX >= scW/2) posX = playerX - scW/2;
|
||
|
else posX = 0;
|
||
|
if(playerX >= mW - scW/2) posX = mW - scW;
|
||
|
|
||
|
//posY = playerY;
|
||
|
};
|
||
|
|
||
|
int Camera::getPosX(){
|
||
|
return posX;
|
||
|
};
|
||
|
|
||
|
int Camera::getPosY(){
|
||
|
return posY;
|
||
|
};
|