Commits

bdemovic  committed b0e82f9

Moved selector from gm_battle to unit.

  • Participants
  • Parent commits 773ab97

Comments (0)

Files changed (4)

File gm_battle.cpp

 	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
 	this->gameTime = 0;
-	this->selector = new Texture("selector.png");
-
+	
     this->map = new Map("skirmish1.thecombatmap");
 
     this->mousePositionX = 0;
 	{
 		delete *it;
 	}
-	delete this->selector;
 }
 
 void GM_Battle::paintSelf()
 	for(std::vector<Unit*>::iterator it = units.begin(); it != units.end(); it++)
 	{
 		Unit *unit = *it;
-		if(unit->isSelected())
-		{
-			this->_paintSelector(unit->getX(), unit->getY() + 16, unit->getWidth(), unit->getHeight());
-		}
+		
 		test->drawCenteredLine("Zombie", unit->getX(), unit->getY()+unit->getHeight());
 		unit->paintSelf();
 	}
 	}
 }
 
-
-void GM_Battle::_paintSelector(float _x, float _y, float w, float h)
-{
-	glPushMatrix();
-	glTranslatef(_x, _y, 0);
-	glScalef(w/2, h/2, 0);
-	glRotatef(0, 0, 0, 1);
-
-	int frame = int(this->gameTime * 20) % 16;
-	int x = (frame % 4) * 32;
-	int y = (frame / 4) * 32;
-
-	this->selector->paintSubImageWithPixels(x,y,32,32);
-
-	glPopMatrix();
-}
 	void handleEvent(SDL_Event &event);
 
 	private:
-	void _paintSelector(float _x, float _y, float w, float h);
-
+		
+		
 	std::vector<Unit*> units;
-	Texture *selector;
 	Map *map;
 	float gameTime;
 	float mousePositionX, mousePositionY;
 Unit::Unit()
 {
 	this->tex = new Texture("zombie.png");
-
+	this->selector =new Texture("selector.png");
 	this->aniProgress = 0;
 	this->dir = 6;
 
 
 void Unit::paintSelf()
 {
+
 	if(!currentlySelected)
 	{
 		//glColor4f(0.7,0.7,0.7,1.0);
 		glColor4f(1.0,1.0,1.0,1.0);
+		
 	}
 	else
 	{
+		
 		glColor4f(1.0,1.0,1.0,1.0);
+			this->_paintSelector(getX(), getY() + 16, getWidth(), getHeight());
+	
+		
 	}
 	glPushMatrix();
 	glTranslatef(this->x, this->y + 16, 0);
 
 void Unit::updateSelf(float k)
 {
+	selectTime+=k;
+
 	switch(activeOrder)
 	{
 		case ORDER_NONE:
 	this->orderDetails.move.dsty = mapY;
 
 }
+
+
+
+
+void Unit::_paintSelector(float _x, float _y, float w, float h)
+{
+	glPushMatrix();
+	glTranslatef(_x, _y, 0);
+	glScalef(w/2, h/2, 0);
+	glRotatef(0, 0, 0, 1);
+
+	int frame = int(this->selectTime * 20) % 16;
+	int x = (frame % 4) * 32;
+	int y = (frame / 4) * 32;
+
+	this->selector->paintSubImageWithPixels(x,y,32,32);
+
+	glPopMatrix();
+}
 	void _setSelected(bool selection) { currentlySelected = selection; }
 
 	private:
+	void _paintSelector(float _x, float _y, float w, float h);
 	static int dirToCircle(int);
 	static int circleToDir(int);
 	Texture *tex;
-
+	Texture *selector;
+	
 	float aniProgress;
 	int dir;
 	float x, y;
 	
+	float selectTime;
+	
 	Unit::State activeState;
 	Unit::Order activeOrder;
 	Unit::OrderDetails orderDetails;