Пример #1
0
bool Slider::setPosition(float val) {
	float oldposition = position;

	position = min(val,getMaxValue());
	position = max(position,getMinValue());

	if (getShowValueHint()) {
		std::wstringstream s;
		s << L" " << position << L" ";
		button->setHintText(s.str().c_str());
		button->instantHintUpdate();
	}

		if (horizontal) {
				button->setPosX(getPosX()+
					getWidth()/(getMaxValue()-getMinValue())*(getPosition()-getMinValue())
					-button->getWidth()/2);
		       button->setPosY(getPosY()+getHeight()/2-button->getHeight()/2);
		} else {

			button->setPosY(getPosY()+getHeight()-
					getHeight()/(getMaxValue()-getMinValue())*(getPosition()-getMinValue())
					-button->getHeight()/2);

		       button->setPosX(getPosX()+getWidth()/2-button->getWidth()/2);

		}

		if (position != oldposition) return true;
		else return false;	
}
Пример #2
0
void Text::update(){
	if(ContainsFlags(m_TextAtt,FADING) &&
	   getAlpha() != 0){
		setColor(getColor(),getAlpha()-2);
	}
	if(ContainsFlags(m_TextAtt,RISING)){
		setPosition(getPosX(),getPosY()-0.5);
	}
	if(ContainsFlags(m_TextAtt,FALLING)){
		setPosition(getPosX(),getPosY()+0.5);
	}
	if(ContainsFlags(m_TextAtt,SHRINKING) &&
		getSize() > 0){
		setSize(getSize()-1);
	}
	if(ContainsFlags(m_TextAtt,GROWING)){
		setSize(getSize()+1);
	}
	if(ContainsFlags(m_TextAtt,TO_THE_LEFT)){
		setPosition(getPosX()-0.5,getPosY());
	}
	if(ContainsFlags(m_TextAtt,TO_THE_RIGHT)){
		setPosition(getPosX()+0.5,getPosY());
	}
}
Пример #3
0
bool Button::isMouseOver(float mouseData[]) {

	if (mouseOverIsTrue) return true;

	if (elliptical == true) {
		
		float center_x = getPosX()+getWidth()/2;
		float center_y = getPosY()+getHeight()/2;

		float pos_x = mouseData[0];
		float pos_y = mouseData[1];

		float d = pow(((pos_x-center_x)*2/getWidth()),2.0f)+ pow((pos_y-center_y)*2/getHeight(),2.0f);

		if (d > 1.0f) return false;
		else return true;


	} else {

	if ((mouseData[0] >= getPosX()) && (mouseData[0] <= getPosX()+getWidth()) && 
		(mouseData[1] >= getPosY()) && (mouseData[1] <= getPosY()+getHeight()) )
		return true;
	else
		return false;
	}
}
Пример #4
0
int CrawlerUnit::selectWeapon(int index) {
	debugC(DEBUG_MOONBASE_AI, "Crawler weapon select");
	int myUnit = _ai->getClosestUnit(getPosX(), getPosY(), _ai->getMaxX(), _ai->getCurrentPlayer(), 1, 0, 0, 0);
	int dist = _ai->getDistance(_ai->getHubX(myUnit), _ai->getHubY(myUnit), getPosX(), getPosY());

	int x = getPosX();
	int y = getPosY();
	int energy = _ai->getPlayerEnergy();
	int terrain = _ai->getTerrain(x, y);

	if (terrain != TERRAIN_TYPE_WATER) {
		if ((energy > 2) && (dist < 220)) {
			return ITEM_RECLAIMER;
		} else {
			return ITEM_BOMB;
		}
	} else {
		if (energy > 6) {
			return ITEM_CRAWLER;
		}

		if (energy > 2) {
			if (_ai->_vm->_rnd.getRandomNumber(1)) {
				return ITEM_MINE;
			} else {
				return ITEM_TIME_EXPIRED;
			}
		}
	}

	return SKIP_TURN;
}
Пример #5
0
Common::Point *MineUnit::createTargetPos(int index, int distance, int weaponType, int sourceX, int sourceY) {
	float ratio;
	Common::Point *targetPos = new Common::Point;

	switch (weaponType) {
	case ITEM_BOMB:
		targetPos->x = getPosX();
		targetPos->y = getPosY();
		break;

	case ITEM_CLUSTER:
		targetPos->x = getPosX();
		targetPos->y = getPosY();
		break;

	case ITEM_EMP:
		ratio = 1 - (getRadius() / static_cast<float>(distance - 20));
		targetPos->x = (int16)(sourceX + ratio * (getPosX() - sourceX));
		targetPos->y = (int16)(sourceY + ratio * (getPosY() - sourceY));
		break;

	default:
		targetPos->x = getPosX();
		targetPos->y = getPosY();
		break;
	}

	return targetPos;
}
Пример #6
0
//adds a character to the text array
void textIn::addChar(int _c){

    //creates a text graphic assigns a font and colour and size and pushes it to back of text vector
    sf::Text temp;
    temp.setFont(font);
    temp.setString( static_cast<char>(_c));
    temp.setColor(sf::Color::White);
    temp.setCharacterSize(getHeight());
    text.push_back(temp);

    if(_c == 32){

        text.back().setString("_");
    }

    //if it is the first in the array set the position of the first character to be within the start of the text box
    if(text.size() == 1){

        text.at(0).setPosition(getPosX(), getPosY() - (getHeight()/5));
    }else{

        //this puts the char in args after the previous char in the array
        text.back().setPosition(text.end()[-2].getPosition().x + text.end()[-2].getLocalBounds().width , getPosY() - (getHeight()/5));
    }

    //moves the caret along one since a caret has been added
    setCaret( text.back().getPosition().x + text.back().getLocalBounds().width, getPosY(), getHeight());

    //stores the position of the caret on an array and iterates an iterator for it by one
    caretPosition.push_back(caret.getPosition().x);
    caretIndex++;
}
Пример #7
0
void Button::render(bool resetPos)
{
  //std::cout << "INFO: Button::render: Rendering the Button" << std::endl;
  float posx = getPosX();
  float posy = getPosY();
  float height = getHeight();
  float width = getWidth();
  if ( resetPos )
    setPositions();
  posx = getPosX();
  posy = getPosY();
  height = getHeight();
  width = getWidth();
  renderTexture( mTexture, mRenderer, posx, posy, width, height );
  //render the title message
  if (mTitle != nullptr)
    {
      float title_scale = 0.7;
      mTitle->setActive(true);
      mTitle->setHeight(height * title_scale);
      mTitle->setWidth(width * title_scale);
      float tborder = (1.-0.8)/2.;
      mTitle->setPosX( posx + tborder * width);
      mTitle->setPosY( posy + tborder * height);
      mTitle->render();
    }
}
Пример #8
0
void SelectionBox::draw( int mouseX, int mouseY )
{
	if ( selected >= 0 ) {
		assert( selected < entries.size() );
		bool mouseInsideBox = ( mouseX >= getPosX() && mouseX < getPosX() + getWidth() && mouseY >= getPosY() && mouseY < getPosY() + getHeight() );
		if ( mouseInsideBox ) {
			glColor4f( selectColorRed, selectColorGreen, selectColorBlue, selectColorAlpha );
		} else {
			glColor4f( baseColorRed, baseColorGreen, baseColorBlue, baseColorAlpha );
		}
		font->drawText( getPosX(), getPosY(), entries[selected] );
	}

	glColor4f( baseColorRed, baseColorGreen, baseColorBlue, baseColorAlpha );

	// TODO: Draw background and open/closed-Symbol depending on state

	if ( state == OPEN ) {
		DrawingHelpers::mapTextureToRect(Frames::frameTextures->getTexture(4), getPosX() + 15, std::max( maxSelectedWidth+10, getWidth()-15), getPosY()-selectFont->getHeight()*1.2*(entries.size()-1)-5, selectFont->getHeight()*1.2*(entries.size()-1)+5 );
		// draw the entries and highlight the one the mouse is over (if any)
		int curX=getPosX()+20;
		int curY=getPosY()-selectFont->getHeight()*1.2;
		for ( size_t curEntryNr=0; curEntryNr<entries.size(); ++curEntryNr ) {
			bool mouseOverEntry = ( mouseX > curX && mouseX <= curX+maxSelectedWidth && mouseY > curY && mouseY < curY+(selectFont->getHeight()*1.2) );
			if ( mouseOverEntry ) {
				glColor4f( selectColorRed, selectColorGreen, selectColorBlue, selectColorAlpha );
			}
			selectFont->drawText( curX, curY, entries[ curEntryNr ] );
			if ( mouseOverEntry ) {
				glColor4f( baseColorRed, baseColorGreen, baseColorBlue, baseColorAlpha );
			}
			curY -= (selectFont->getHeight()*1.2);
		}
	}
}
Пример #9
0
Common::Point *CrawlerUnit::createTargetPos(int index, int distance, int weaponType, int sourceX, int sourceY) {
	Common::Point *targetPos = new Common::Point;

	if (!distance)
		distance = 1;

	switch (weaponType) {
	case ITEM_BOMB:
		targetPos->x = getPosX();
		targetPos->y = getPosY();
		break;

	case ITEM_CLUSTER:
		targetPos->x = getPosX();
		targetPos->y = getPosY();
		break;

	case ITEM_CRAWLER:
		targetPos->x = getPosX();
		targetPos->y = getPosY();
		break;

	default:
		targetPos->x = getPosX();
		targetPos->y = getPosY();
		break;
	}

	return targetPos;
}
Пример #10
0
 bool BattleWalkFighter::PreGetObject()
 { 
     if(!_target || !_target->getHP())
     {
         if(!_count)
             _target = GetField()->GetTargetForRide(!GetSideInBS(), getPosX(),getPosY(), 2);
         else
         {
             if(_target)
             {
                 //COUT << "战将编号"  << static_cast<UInt32>(_target->GetBSNumber()) << "死亡。 ";
             _target = GetField()->GetTarget(!GetSideInBS(),getPosX(),getPosY());
             }
             if(_target)
             {
                 //COUT << "战将编号"  << static_cast<UInt32>(GetBSNumber()) << "锁定目标" << static_cast<UInt32>(_target->GetBSNumber()) << std::endl;
             }
         }
         SetMove(true);
         ++_count;
         BuildLocalStream(e_run);
     }
     if(_target)
         SetBattleTargetPos(_target->getPosX(),_target->getPosY());
     return true;
 } 
Пример #11
0
void Label::clicked( int mouseX, int mouseY, uint8_t mouseState )
{
    if ( mouseX > getPosX() && mouseX < getPosX() + font->calcStringWidth( text )
            && mouseY > getPosY() && mouseY < getPosY() + font->getHeight() )
    {
        execute();
        return; // true;
    }
	//return false;
}
Пример #12
0
bool Slider::isMouseOver(float mouseData[2]) {

	if ((mouseData[0] >= getPosX()) && (mouseData[0] <= getPosX()+getWidth()) && 
		(mouseData[1] >= getPosY()) && (mouseData[1] <= getPosY()+getHeight()) ) {
		return true;
	}
	else{
		return false;
	}
}
Пример #13
0
bool Pathfinder::areConnected(int node1, rt_dir dir){
	switch(dir){
		case RT_WEST:	return getPosX(node1)>0 && getNet(node1-1)==getNet(node1) && getNet(node1) && getNet(node1)!=blockageNet;
		case RT_SOUTH:	return getPosY(node1)>0 && getNet(node1-sizeX)==getNet(node1) && getNet(node1) && getNet(node1)!=blockageNet;
		case RT_DOWN:	return getPosZ(node1)>0 && getNet(node1-sizeXY)==getNet(node1) && getNet(node1) && getNet(node1)!=blockageNet;
		case RT_EAST:	return getPosX(node1)+1<sizeX && getNet(node1+1)==getNet(node1) && getNet(node1) && getNet(node1)!=blockageNet;
		case RT_NORTH:	return getPosY(node1)+1<sizeY && getNet(node1+sizeX)==getNet(node1) && getNet(node1) && getNet(node1)!=blockageNet;
		case RT_UP:		return getPosZ(node1)+1<sizeZ && getNet(node1+sizeXY)==getNet(node1) && getNet(node1) && getNet(node1)!=blockageNet;
	}
	return false;
}
Пример #14
0
int MineUnit::selectWeapon(int index) {
	int myUnit = _ai->getClosestUnit(getPosX(), getPosY(), _ai->getMaxX(), _ai->getCurrentPlayer(), 1, 0, 0, 0);
	int x = getPosX();
	int y = getPosY();

	int dist = _ai->getDistance(x, y, _ai->getHubX(myUnit), _ai->getHubY(myUnit));

	if ((getState() == DUS_ON) && (dist < 110)) {
		return ITEM_EMP;
	} else {
		return ITEM_BOMB;
	}
}
Пример #15
0
//Write to a designated file the routing result
void Pathfinder::pathTree(int net, ofstream& froute){	
	int antPos,pos,desloc;
	rt_dir dir;
	int r=0;
	
	if(netlist[net].routeResult.size()>0){
		froute << "Net " << net << "\t";
		froute << "( " << getPosX(netlist[net].routeResult[(r)]) << " "	<< getPosY(netlist[net].routeResult[(r)]) << " " << getPosZ(netlist[net].routeResult[(r)]) << " ) ";
		desloc=1;
		r=1;
		while(r<(netlist[net].routeResult.size()-1)){
			if(netlist[net].routeResult[r]==-1){
				froute << " ( " << getPosX(netlist[net].routeResult[(r+1)]) << " "	<< getPosY(netlist[net].routeResult[(r+1)]) << " " << getPosZ(netlist[net].routeResult[(r+1)]) << " ) ";
				r+=2;
				desloc=1;
			}
			else {
				antPos=netlist[net].routeResult[r-1];
				pos=netlist[net].routeResult[r];
				dir=dirFromPos(antPos,pos);
				if(netlist[net].routeResult[r+1]==-1 || !(getDir(pos,dir)==netlist[net].routeResult[r+1])){
					switch (dir){
						case RT_WEST:
							froute << "[ " << desloc <<  " WEST ] ";
							break; 
						case RT_EAST:
							froute << "[ " << desloc <<  " EAST ] ";
							break;
						case RT_SOUTH:	
							froute << "[ " << desloc <<  " SOUTH ] ";
							break;
						case RT_NORTH:
							froute << "[ " << desloc <<  " NORTH ] ";
							break;
						case RT_DOWN:
							froute << "[ " << desloc <<  " DOWN ] ";
							break;
						case RT_UP:
							froute << "[ " << desloc <<  " UP ] ";
							break;						
					}
					desloc=1;	
				}
				else desloc++;
				r++;
			}	
		}
		froute << endl;
	}
}
Пример #16
0
void MapGenerator::writeNoteline(int type, int length)
{
	int time = beatTick;
	int difficulty = CCRANDOM_0_1() * 2;
	int posY = getPosY(time);
	int posX = getPosX(posY, length);
	int desY = getPosY(time + length);
	int desX = getPosX(desY, length);
	fprintf(fout, "%.5d,", time);
	fprintf(fout, "%.1d,", difficulty);
	fprintf(fout, "%.1d,", type);
	fprintf(fout, "%.3d,", length);
	fprintf(fout, "%.1d%.1d,", posX, posY);
	fprintf(fout, "%.1d%.1d\n", desX, desY);
}
Пример #17
0
//removes char from position in args and changes subsequent objects to be drawn properly
void textIn::removeChar(int _i){

    try{
    //creates an iterator for text vector assigned from arg 1
    auto it = text.begin();

     if(_i != 1){

        //remove the character in the vector at index using the iterator
        text.erase(it + (_i -1));

        //iterates all text in front of inserted text to be drawn in front of the char before it (shimmies all the other letters along)
        for(int x = (_i-1); x < text.size(); x++){

            text.at(x).setPosition((text.at(x -1).getPosition().x + text.at(x -1).getLocalBounds().width) ,  getPosY() - (getHeight()/5));
        }

    }else if(_i != 0){

        //delete first element
        text.erase(it);

        //set first element to be at the front of the text box
        text.at(0).setPosition(getPosX() , getPosY() - (getHeight()/5));

         //iterates all text in front of inserted text to be drawn in front of the char before it (shimmies all the other letters along)
        for(int x = 1; x < text.size(); x++){

            text.at(x).setPosition((text.at(x -1).getPosition().x + text.at(x -1).getLocalBounds().width) , getPosY()- (getHeight()/5));
        }
    }

    if(_i != 0){
        //reorganises all positions of caret
        resetPositions();

        caretIndex--;

        setCaret(caretPosition.at(caretIndex), getPosY(), getHeight());

        //stores the new position of the character at the very front
        caretPosition.push_back(text.at(text.size() -1).getPosition().x +  text.at(text.size() -1).getLocalBounds().width);
    }
  }catch( std::out_of_range){

    std::cout<< "Range error removing char";
  }
}
Пример #18
0
void Label::draw( int mouseX, int mouseY )
{
	if ( font == NULL || text == "" )
		return;

	if (  onClickedFunc != NULL
			&& mouseX > getPosX() && mouseX < getPosX() + font->calcStringWidth( text )
			&& mouseY > getPosY() && mouseY < getPosY() + font->getHeight() )
		glColor4f( selectColorRed, selectColorGreen, selectColorBlue, selectColorAlpha );
	else
		glColor4f( baseColorRed, baseColorGreen, baseColorBlue, baseColorAlpha );
	font->drawText( getPosX(), getPosY(), text );

	// draw child controls if any
	FramesBase::draw( mouseX, mouseY );
}
Пример #19
0
void swarm::update(boundingBox bBox)
{
	//chaseBuggy(bBox);
	b->initBox(getPosX(), getPosY(), b->getWidth(), b->getHeight());
	//moveConstAcc(0.2);
	swarmAway();
}
Пример #20
0
void particle3D::draw()
{
	int vecSize;
	double x, y, z;
	glColor3f(1.0,1.0, 1.0);

	//궤적 배열에 현재 공 위치 추가
	x = getPosX(); y = getPosY(); z = getPosZ();
	trace.push_back(Vec3(x, y, z));

	int traceNum = 30;

	vecSize = trace.size();

	//궤적
	for (int i = vecSize- traceNum > 0 ? vecSize - traceNum : 0 ; i < vecSize-1; i++)
	{
		glLineWidth(2.0);
		glBegin(GL_LINES);
		glVertex3f(trace[i].x,trace[i].y,trace[i].z);
		glVertex3f(trace[i+1].x, trace[i+1].y, trace[i+1].z);
		glEnd();
	}

	//x,y,z에 골프공 렌더링
	glPushMatrix();
		glTranslatef(x,y,z);
		glutSolidSphere(radius,100,100);
	glPopMatrix();
}
Пример #21
0
bool Button::collide(float x_screen, float y_screen)
{
  //need to figure out the screen pos of the button corner and its width and heigh in pixels
  /*  float posx = parent->getPosX();
  float posy = parent->getPosY(); 
  float width = parent->getWidth() * this->getRelWidth();
  float height = parent->getHeight() * this->getRelHeight();
  float rposx = posx + getRelX();
  float rposy = posy + getRelY();*/
  setPositions();
  float rposx = getPosX();
  float rposy = getPosY();
  float width = getWidth();
  float height = getHeight();
  if ( 
      (x_screen < rposx + width) && (rposx <= x_screen ) && 
      (y_screen < rposy + height) && (rposy <= y_screen )
       )
    {
      setPressed(true);
      return true;
    }
  else
    {
      setPressed(false);
      return false;
    }
}
Пример #22
0
int detectCollision(Bomb B, Enemy E) {
	int a,b,c,d;
	a = getEnemyPosX(E);
	b = getEnemyPosY(E);
	c = getPosX(B);
	d = getPosY(B);
	return (((a-15 <= c) && (a+60 >= c)) && ((b-15 <= d) && (b+30 >= d)) && isActive(B));
}
Пример #23
0
    bool BattleRideFighter::PreGetObject()
    { 
        //获取战斗对象
        PreGetObject1() ;
        if(!_target)
            return false;
        if(count > 3)
            return false;
        if(!count || (getPosX() == _battleTargetX && getPosY() == _battleTargetY ))// || getPosX() >= (FIELD_WIDTH - 100) )
        {
            switch(count)
            {
                case 0:  //第一次出发
                    {
                        _battleTargetX = (getPosX() > (FIELD_WIDTH)/2) ? 100:(FIELD_WIDTH-100);
                        break;
                    }
                case 1:  //回头
                    {
                        _battleTargetX = GetMinX();
                        _battleTargetY = GetMinY();
                        break;
                    }
                case 2:  //停
                    {
                        SetBattleTargetPos(getPosX(),getPosY());
                        break;
                    }
                default:
                    return false ;
            }
            count++;
            //COUT << "战将编号:" << static_cast<UInt32>(GetBSNumber()) << "目的地:" << static_cast<UInt32>(_battleTargetX) << " , " << static_cast<UInt32>(_battleTargetY) << std::endl;
        }


        if(!_battleTargetY)
        {
            _battleTargetY = _target->getPosY();
        }
        BuildLocalStream(e_run);
        return true;
    } 
Пример #24
0
//removes last character
void textIn::removeChar(){

    if(text.size() > 0){

        //removes last char and chars position on an array as well as an iterator for iterating over it
        text.pop_back();
        caretPosition.pop_back();

        //moves caret back
        setCaret( text.back().getPosition().x + text.back().getLocalBounds().width, getPosY(), getHeight());

        caretIndex--;

    }else{

        //if the text array is empty then return the caret to start
        setCaret( getPosX() + 1, getPosY(), getHeight());
        caretIndex = 0;
    }
}
Пример #25
0
void UI_Box::render(IDirect3DDevice9* pd3dDevice)
{
    D3DVIEWPORT9 vp;
    vp.MinZ = 0.f;
    vp.MaxZ = 1.f;

    vp.X = (DWORD)max(0, getPosX())+4;
    vp.Y = (DWORD)max(0, getPosY());
    vp.Width = DWORD(getPosX() + (float)m_Width - (float)vp.X);
    vp.Height = DWORD(getPosY() + (float)m_Height - (float)vp.Y);
    pd3dDevice->SetViewport(&vp);

    for (int i = 0; i < m_listControls.size(); ++i)
        m_listControls[i]->render( pd3dDevice);

    vp.X = 0;
    vp.Y = 0;
    vp.Width = _SCREEN_WIDTH;
    vp.Height = _SCREEN_HEIGHT;
    pd3dDevice->SetViewport(&vp);
}
Пример #26
0
void Sprite::render(int cameraoffset_x, int cameraoffset_y, float zoom, int height)
{
  float pixel_x = 0;
  float pixel_y = 0;
  pixel_y = getPixelY(getPosX(), getPosY(), cameraoffset_x, cameraoffset_y, zoom, mScale) - height;
  pixel_x = getPixelX(getPosX(), getPosY(), cameraoffset_x, cameraoffset_y, zoom, mScale);
  
  //Render only whats visible:
  const int offscreen_tolerance = 3*TILE_SIZE*zoom;
  int screen_width;
  int screen_height;
  SDL_GetWindowSize(mWindow, &screen_width, &screen_height);

  if ((pixel_x >= 0-offscreen_tolerance) or
      (pixel_x+TILE_SIZE*zoom <= screen_width+offscreen_tolerance) or
      (pixel_y >= 0-offscreen_tolerance) or
      (pixel_y+TILE_SIZE*zoom <= screen_height+offscreen_tolerance))
    {
      renderTexture(mTexture, mRenderer, pixel_x, pixel_y, mScale*zoom, mScale*zoom);
    }
}
Пример #27
0
bool tiger :: move ( int dy , int dx )
{
       if( getBoard() == NULL )
         cout << "BOARD NULL ERROR !" <<endl ; 
     else
     {
          int x = getPosX() ; 
          int y = getPosY() ; 
     
          if( y + dy < 0 || y + dy > 8 || x + dx < 0 || x + dx > 8   )
              return false ; 
         
          
            if( getBoard() -> getItem( getPosY() + dy , getPosX() + dx ) -> getItemNo() == 1 )
             {
                 if( dy != 0 && dx == 0)
                 {
                 setX ( this->getPosX() + dx * 4 ) ; 
                 setY ( this->getPosY() + dy * 4 ) ;
                 }
                 else if ( dy == 0 && dx != 0 )
                 {
                 setX ( this->getPosX() + dx * 3  ) ; 
                 setY ( this->getPosY() + dy * 3  ) ;
                 }
                 
             }               
             else if( getBoard() -> getItem( getPosY() + dy , getPosX() + dx ) -> getItemNo() != 1)
             {
                 setX ( this->getPosX() + dx ) ; 
                 setY ( this->getPosY() + dy ) ;
                  
             }
             
     }
     
     
     
} 
Пример #28
0
void OurHero::fireProjectile(Projectiles projectile[], int size, int mPosX, int mPosY) {    
    for (int i = 0; i < size; i++) {
        if (!projectile[i].isLive()) {
            projectileHeadingX = mPosX;
            projectileHeadingY = mPosY;
            projectile[i].setX(getPosX());
            projectile[i].setY(getPosY());
            projectile[i].setLive(true);
            break;
        }
    }

}
Пример #29
0
//prepares rectangle to be drawn to create a text field
void textIn::setRects(){

    //set up colours of text input box
    rectangle.setFillColor(sf::Color::Black);
    rectangle.setOutlineColor(sf::Color::White);
    rectangle.setOutlineThickness(1);

    //position set to draw
    rectangle.setPosition(sf::Vector2f(getPosX(), getPosY()));

    //size is set to a standard, may add a scrolling
    //text field if text is too big later
    rectangle.setSize(sf::Vector2f(getWidth(), getHeight()));
}
Пример #30
0
//-------------------------------
void ofxLabGui::mousePressed(float x, float y, int button){
    if( hidden ) return;

    bool tabButtonPressed = false;

	if( bCollapsible && isInsideRect(x, y, minimizeButton)){
		if( bCollapsible ) minimize = !minimize;
	}else if( isInsideRect(x, y, topBar) && bDraggable){
        dragging = true;
        mouseDownPoint.set(x - boundingBox.x, y-boundingBox.y, 0);
    }else if(!minimize){
		bool bPanelClicked = false;
		bool bTextEnterSet = false;
		//check panel tabs
        for(int i = 0; i < panels.size(); i++){
            if ( !panels[i]->enabled ) continue;
			ofRectangle scaledTabRect = panels[i]->getTabRect();
			scaledTabRect.x += panels[i]->getPosX();
			scaledTabRect.y += getPosY();

            if( isInsideRect(x, y, scaledTabRect) && !bPanelClicked){
                selectedPanel = i;
				panels[i]->bSelected = true;
                tabButtonPressed = true;
				bPanelClicked = true;
                //break;
            } else {
				panels[i]->bSelected = false;
			}
        }
		if (!bPanelClicked)	panels[selectedPanel]->bSelected = true;
    }

    if(minimize == false && tabButtonPressed == false && isInsideRect(x, y, boundingBox) ){
        for(int i = 0; i < panels.size(); i++){
             if( i == selectedPanel )panels[i]->checkHit( x - hitArea.x, y - hitArea.y, button);
        }

		saveAsButton->checkHit(x, y, button);
		saveAsButton->updateGui(x, y, false, true);
		loadButton->checkHit(x, y, button);
		loadButton->updateGui(x, y, false, true);
		saveButton->checkHit(x, y, button);
		saveButton->updateGui(x, y, false, true);
		restoreButton->checkHit(x, y, button);
		restoreButton->updateGui(x, y, false, true);
    }

    prevMouse.set(x, y);
}