gameEngine/gameEngine/Sprite.cpp
//make given pos the center of the sprite, so calc the real pos, setup given texture, setup collider texture, add sprite to scene, set velocity, and init initvalues
make given pos the center of the sprite, so calc the real pos, setup given texture, setup collider texture, add sprite to scene, set velocity, and init initvalues
make given pos the center of the sprite so calc the real pos setup given texture setup collider texture add sprite to scene set velocity and init initvalues
Sprite::Sprite(std::string n, AbstractScene &scene, glm::vec2 pos, glm::vec2 size, GLchar* texture, glm::vec2 velocity, glm::vec3 color)
	: parentScene(&scene), 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);
	}
	scene.addSprite(this);
	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 , AbstractScene & scene , glm :: vec2 pos , glm :: vec2 size , GLchar * texture , glm :: vec2 velocity , glm :: vec3 color ) : parentScene ( & scene ) , 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 ) ; } scene . addSprite ( this ) ; this -> active = true ; this -> visible = true ; initCenter = Center ; initColor = Color ; initPosition = Position ; initRotation = Rotation ; initSize = Size ; initTexture = Texture ; initTextureFile = textureFile ; initVelocity = Velocity ; resetCounter = 0 ; }
make given pos the center of the sprite, so calc the real pos, setup given texture, setup collider texture, add sprite to scene, set velocity, and init initvalues
make given pos the center of the sprite so calc the real pos setup given texture setup collider texture add sprite to scene set velocity and init initvalues
//center the postion based on the height and width of the sprite //see if texture is already loaded //load texture //init init vars, for restarting scenes