#include "main.h"

screen::screen() {
	this->left = 0;
	this->right = SCREENWIDTH;
	this->top = 0;
	this->bottom = SCREENHEIGHT;
}

int screen::setleft(float left) {	
	if ((this->right - left) < MAXWIDTH) {
		this->left = left;
		float width = this->right - this->left;
		float height = (SCREENRATIO) * width;
		this->top = this->bottom - height;
		return 1;
	}
	return 0;
}

int screen::setright(float right) {
	if ((right - this->left) < MAXWIDTH) {
		this->right = right;
		float width = this->right - this->left;
		float height = (SCREENRATIO) * width;
		this->bottom = this->top + height;
		return 1;
	}
	return 0;
}

int screen::settop(float top) {
	if ((this->bottom - top) < MAXHEIGHT) {
		this->top = top;
		float height = this->bottom - this->top;
		float width = height/(SCREENRATIO);
		this->left = this->right - width;
		return 1;
	}
	return 0;
}
		
int screen::setbottom(float bottom) {
	if ((bottom - this->top) < MAXHEIGHT) {
		this->bottom = bottom;
		float height = this->bottom - this->top;
		float width = height/(SCREENRATIO);
		this->left = this->right - width;
		return 1;
	}
	return 0;
}

