gameEngine/gameEngine/Sprite.cpp
//constructor with no scene give, sprite will not be updated or drawn until given to a scene
constructor with no scene give, sprite will not be updated or drawn until given to a scene
constructor with no scene give sprite will not be updated or drawn until given to a scene
Sprite::Sprite(std::string n, glm::vec2 pos, glm::vec2 size, GLchar * texture, glm::vec2 velocity, glm::vec3 color)
	: textureFile(texture), collideDebug(false), transparency(1)
{
	this->name = n;
	this->Center = pos;
	this->Size = size;
	this->lastSize = this->Size;
	this->Velocity = velocity;
	this->Rotation = 0;
	this->lastRotation = this->Rotation;
	this->Position.x = this->Center.x - this->Size.x / 2;
	this->Position.y = this->Center.y - this->Size.y / 2;
	this->Color = color;
	this->lastPosition = this->Position;
	BoxCollider *temp = new BoxCollider("default", *this, (int)size.x, (int)size.y);
	temp->setPosition(this->Position);
	colliders_.push_back(temp);
	if (ResourceManager::Textures[texture].Image_Format != 6407)
	{
		this->Texture = ResourceManager::GetTexture(texture);
	}
	else
	{
		ResourceManager::LoadTexture(texture, true, texture);
		this->Texture = ResourceManager::GetTexture(texture);
	}
	this->active = true;
	this->visible = true;
	initCenter = Center;
	initColor = Color;
	initPosition = Position;
	initRotation = Rotation;
	initSize = Size;
	initTexture = Texture;
	initTextureFile = textureFile;
	initVelocity = Velocity;
	resetCounter = 0;
}
Sprite :: Sprite ( std :: string n , glm :: vec2 pos , glm :: vec2 size , GLchar * texture , glm :: vec2 velocity , glm :: vec3 color ) : textureFile ( texture ) , collideDebug ( false ) , transparency ( 1 ) { this -> name = n ; this -> Center = pos ; this -> Size = size ; this -> lastSize = this -> Size ; this -> Velocity = velocity ; this -> Rotation = 0 ; this -> lastRotation = this -> Rotation ; this -> Position . x = this -> Center . x - this -> Size . x / 2 ; this -> Position . y = this -> Center . y - this -> Size . y / 2 ; this -> Color = color ; this -> lastPosition = this -> Position ; BoxCollider * temp = new BoxCollider ( " " , * this , ( int ) size . x , ( int ) size . y ) ; temp -> setPosition ( this -> Position ) ; colliders_ . push_back ( temp ) ; if ( ResourceManager :: Textures [ texture ] . Image_Format != 6407 ) { this -> Texture = ResourceManager :: GetTexture ( texture ) ; } else { ResourceManager :: LoadTexture ( texture , true , texture ) ; this -> Texture = ResourceManager :: GetTexture ( texture ) ; } this -> active = true ; this -> visible = true ; initCenter = Center ; initColor = Color ; initPosition = Position ; initRotation = Rotation ; initSize = Size ; initTexture = Texture ; initTextureFile = textureFile ; initVelocity = Velocity ; resetCounter = 0 ; }
constructor with no scene give, sprite will not be updated or drawn until given to a scene
constructor with no scene give sprite will not be updated or drawn until given to a scene
//center the postion based on the height and width of the sprite //see if texture is already loaded //std::cout << "using already loaded Texture"; //load texture //init init vars, for restarting scenes