Exemplo n.º 1
0
void unLOCK::moveAuto(int rY) {
	if ( rY > 0 ) {
		while (ScreenHeight-relY > min_visible()) moveRel(0, 1);
	} else if (rY < 0) {
		while (ScreenHeight-relY < max_visible()) moveRel(0, -1);
	}
}
Exemplo n.º 2
0
void INFO_PANEL::moveAuto(int rY) {
	if ( rY > 0 ) {
		while (relY < 0) moveRel(0, 1);
	} else if (rY < 0) {
		while (relY+ibg->h > min_visible()) moveRel(0, -1);
	}
}
Exemplo n.º 3
0
void TutorialUnit::moveGamepad(double x, double y, double phi)
{
    QMutexLocker lock(&mMutex);
    checkHAL();
    QMutexLocker waitLock(&mWaitMutex);

    emit moveRel(QPointF(x*20.0, y*-20.0), 20);
    mWait.wait(&mWaitMutex, 20);
    emit rotateRel(phi*20, 1);
    mWait.wait(&mWaitMutex, 20);
}
Exemplo n.º 4
0
void
Pickup::update()
{
  Object::update();

  int bobbing[] = {0, 0, 1, 0, 1, 0, 0, -1, 0, -1, MAGIC_NUMBER};

  if(--bobDelay == 0)
    {
      moveRel(0, bobbing[bob]);
      bobDelay = BOB_DELAY;

      if(bobbing[++bob] == MAGIC_NUMBER)
	bob = 0;
    }
}
Exemplo n.º 5
0
    void setOffset(double relOffset){cout<<"|"<<flush;
		moveRel(relOffset);
		markDirty();
		SDL_Event ev; ev.type = SDL_USEREVENT;  ev.user.code = 1;  ev.user.data1 = 0;  ev.user.data2 = 0;
		SDL_PushEvent(&ev);
    }
Exemplo n.º 6
0
void Quadrotor::executeTimeLineCommand()
{
   
    //*
   //return;
    if(readTimeline)
    {
        double current_time = QuadTimer::GetProcessTime();
        
 
        
        if(!isExecuting)
        {
            char command[100];
            char* commandstr;
            double peektime = -1;
            //double com_time;
            commandstr = timeline->readNextCommand(peektime);
            //read the command type
            if(sscanf(commandstr,"%lf %s",&comTime,command)==EOF)
            {readTimeline = false; return;}
            
            sprintf(delayedCommand,"%lf %s",peektime,commandstr);
            isExecuting = true;
        }
        else if(current_time>=comTime && !isMoving)
        {
            //command to set quad position

            sscanf(delayedCommand,"%lf %lf %s",&nextTime,&comTime,command);
            //printf("\n%s",command);
            //printf("\n%s",delayedCommand);
            comOrientationTime = 0;
            if(!strcmp(command,"POS"))
            {
                sscanf(delayedCommand,"%lf %lf %s %f %f %f",&nextTime,&comTime, command,&comVect.x,&comVect.y,&comVect.z);
                moveAbs(comVect)  ;
                
            }
            else if(!strcmp(command,"ROT"))
            {
                
                sscanf(delayedCommand,"%lf %lf %s %f %f %f",&nextTime,&comTime, command,&comVect.x,&comVect.y,&comVect.z); 
                
            }
            
            else if(!strcmp(command,"MOV"))
            {
                
                sscanf(delayedCommand,"%lf %lf %s %lf %f %f %f",&nextTime,&comTime, command,&comOrientationTime,&comVect.x,&comVect.y,&comVect.z); 
                isExecuting = true;
                quadTime.getTimeDiffSec();
                comOrientationTime = current_time + comOrientationTime;
                if(orientationMode == QuadOrientationMode::FREE)
                {}
                else if(orientationMode == QuadOrientationMode::ANOTHERQUAD)
                {  }
                else if(orientationMode == QuadOrientationMode::UPRIGHT)
                {}
                //Operations to align the quad with the direction of motion 
                
                comDirection = glm::vec3(comVect.x-pos_x,comVect.y-pos_y,comVect.z-pos_z);
                comDirection = glm::normalize(comDirection);
                
                
                /*glm::vec3 x_axis(1.0f,0.0f,0.0f);
                 *        glm::vec3 rotation_axis = glm::cross(comDirection,x_axis);
                 *        
                 *        
                 *        rotation_axis = glm::normalize(rotation_axis);
                 *        float angle = glm::angle(x_axis,comDirection);
                 *        Model = glm::rotate(glm::mat4(1.0f), -angle, rotation_axis);
                 */
            }    
             
            else if(!strcmp(command,"LOOKATQUAD"))
            {
                char quadname[10];
                sscanf(delayedCommand,"%lf %lf %s %s",&nextTime,&comTime,command, quadname);
                                
                otherQuad = Quadrotor::getQuadFromName(quadname);
                orientationMode = QuadOrientationMode::ANOTHERQUAD;
            }
            else if(!strcmp(command,"LOOKATPOINT"))
            {
                glm::vec3 position;
                sscanf(delayedCommand,"%lf %lf %s %f %f %f",&nextTime,&comTime,command, &position.x,&position.y,&position.z);

                lookAtPoint = position;
                orientationMode = QuadOrientationMode::POINT;
                
            } 
            else if(!strcmp(command,"FREE"))
            { 
                orientationMode = QuadOrientationMode::FREE;
            }
            else if(!strcmp(command,"FIREAT"))
            {
                float r,g,b,a;
                char ammotype[20];
                char quadname[10];
                sscanf(delayedCommand,"%lf %lf %s %s %f %f %f %f %s",&nextTime,&comTime,command, quadname,&r,&g,&b,&a,ammotype);
                AMMOTYPE::ENUM ammo_type = AMMOTYPE::getAmmotypeFromString(string(ammotype));
                Ammo::fire(getBarrelPosition(),string(quadname),glm::vec4(r,g,b,a),5,this,ammo_type);
                
            }
            else if(!strcmp(command,"FIREATPOINT"))
            {
                float r,g,b,a;
                char ammotype[20];
                glm::vec3 position;
                sscanf(delayedCommand,"%lf %lf %s %f %f %f %f %f %f %f %s",&nextTime,&comTime,command, &position.x, &position.y, &position.z,&r,&g,&b,&a,ammotype);
                AMMOTYPE::ENUM ammo_type = AMMOTYPE::getAmmotypeFromString(string(ammotype));
                Ammo::fire(getBarrelPosition(),position,glm::vec4(r,g,b,a),5,this,ammo_type);
                
            }
            
            customCommandParser(string(delayedCommand));
                //Operations to align the quad with the direction of motion
            isMoving = true;
            //   printf("\nGot command:%f %f %f %f",com_time,com_posx,com_posy,com_posz);
            
        }
         
        else if(current_time<=comOrientationTime) //dont have to worry about modes other than MOV
        {
            
            glm::vec3 current_axis, current_up;
            double delta_time = comOrientationTime-current_time;
            getOrientation(current_axis,current_up,glm::vec3(1.0,0.0,0.0));
            
            current_axis = glm::normalize(current_axis);
            comRotationAxis = glm::cross(current_axis,comDirection);
             
            double timediff =   quadTime.getTimeDiffSec();
            if(timediff>delta_time) timediff = delta_time;
            float axisAngle = glm::angle(current_axis,comDirection);
        //    printf("\nX: %f",angle_axis);
            /*if(axisAngle>Pi)
            {
                printf("\n%f",axisAngle);
                axisAngle = (2*Pi-axisAngle);
                
            }*/
            axisAngle = axisAngle*(float) (timediff/ delta_time);
            Model = glm::rotate(Model,axisAngle,comRotationAxis);
            //*
            glm::vec3 eye = glm::vec3(0,0,0), 
            center = glm::vec3( Model*glm::vec4(1.0f,0.0f,0.0f,1.0f)),
            up = glm::vec3(0,1,0); 
             
            glm::mat4 mm = getOrientationMatrix(eye,center,up);
            Model = mm;
            Model = glm::rotate(Model,-glm::half_pi<float>(),glm::vec3(0,1,0));
            //*/

        }
        else if(current_time>=nextTime)
        { isExecuting = false;isMoving=false;}
        else if(current_time>=comTime)
        {
            if(!strcmp(command,"MOV"))
            {
                glm::vec3 distance = glm::vec3(comVect.x-pos_x,comVect.y-pos_y,comVect.z-pos_z);
                /*
                if(orientationMode == QuadOrientationMode::ANOTHERQUAD)
                {  
                    glm::vec3 otherQuadPosition = otherQuad->getQuadPosition();
                    glm::vec3 otherDirectionRelative = otherQuadPosition - getQuadPosition();
                      
 
                    glm::vec3 upVector,tempVector; 
                    //getOrientation();
                    glm::vec3 eye = glm::vec3(0,0,0),center = otherDirectionRelative,up = glm::vec3(0,1,0);
                     
                    glm::mat4 mm = getOrientationMatrix(eye,center,up);
                    Model = mm;
                    Model = glm::rotate(Model,-glm::half_pi<float>(),glm::vec3(0,1,0));
                    
                        
                }*/ 
                if(orientationMode != QuadOrientationMode::ANOTHERQUAD && orientationMode != QuadOrientationMode::POINT)
                {
                 //*     
                   glm::vec3 eye = glm::vec3(0,0,0),
                    center = comDirection,
                    up = glm::vec3(0,1,0);
                     
                    glm::mat4 mm = getOrientationMatrix(eye,center,up);
                    Model = mm;
                    Model = glm::rotate(Model,-glm::half_pi<float>(),glm::vec3(0,1,0));
                  //*/  
                } 
                
                 double delta_time = nextTime-current_time;
                 double timediff = quadTime.getTimeDiffSec();
                 if(delta_time < timediff)
                     timediff=delta_time;
                glm::vec3 dist2 = distance *(float) (timediff/ delta_time);
                moveRel(dist2);
                //     printf("\ndelta pos:%f %f %f",dist2.x,dist2.y,dist2.z);
            }
        }
         
         
          
        //   printf("\ncurrent pos:%f %f %f",pos_x, pos_y,pos_z);
    }
    //*/
}
Exemplo n.º 7
0
Sint8 CGO_Player::setPlayerRelXY (Sint16 x, Sint16 y)
{
	t_field f;
/*
	if( (getArrayMiddleX() + x + BOX_W2) / BOX_W >= GA_W )
		er.report(LOG_WARNING, "%s: X+ %d,%d,%d,%d\n", AT,
				  getArrayX(),
				  getArrayMiddleX(),
				  x,
				  (getArrayMiddleX() + x + BOX_W2)/BOX_W
				  );

	if( (getArrayMiddleX() + x - BOX_W2) / BOX_W < 0 )
		er.report(LOG_WARNING, "%s: X- %d,%d,%d,%d\n", AT,
				  getArrayX(),
				  getArrayMiddleX(),
				  x,
				  (getArrayMiddleX() + x - BOX_W2)/BOX_W
				  );
*/
	if (x > 0)
	{
		//if (getArrayX(getArrayMiddleX()) != getArrayX(getArrayMiddleX() + x + BOX_W2))
		{
			f = ga->getBoardField(getArrayX(getArrayMiddleX() + x + BOX_W2), getArrayY(getArrayMiddleY()));
			if (f.occupancy != TBLANK || f.bomb == true)
			{
				setX(getArrayX(getArrayMiddleX()) * BOX_W);
				return -1;
			}
			else
			{
				//				 if ( abs( (getArrayMiddleY() % BOX_H) - BOX_H2 ) >= BOX_H2 - 1 )
				//				 {
				//					 setY( getArrayY( getArrayMiddleY() ) * BOX_H );
				//					 return -5;
				//				 }
				//				 if ( getArrayX( getArrayMiddleX() + BOX_W2 ) != getArrayX( getArrayMiddleX() + x + BOX_W2 ) )
				//				 {
				//					 if ( ga->getBoardField( getArrayX( getArrayMiddleX() + x + BOX_W2 ), getArrayY( getArrayMiddleY() ) ).powerup >= 0 )
				//					 {
				//						 setPowerup( ga->getBoardField( getArrayX( getArrayMiddleX() + x + BOX_W2 ), getArrayY( getArrayMiddleY() ) ).powerup );
				//						 ga->setFieldValPowerup( getArrayX( getArrayMiddleX() + x + BOX_W2 ), getArrayY( getArrayMiddleY() ), -1 );
				//					 }
				//				 }
			}
		}
	}

	if (x < 0)
	{
		//if (getArrayX(getArrayMiddleX()) != getArrayX(getArrayMiddleX() + x - BOX_W2))
		{
			f = ga->getBoardField(getArrayX(getArrayMiddleX() + x - BOX_W2), getArrayY(getArrayMiddleY()));
			if (f.occupancy != TBLANK || f.bomb == true)
			{
				setX(getArrayX(getArrayMiddleX()) * BOX_W);
				return -1;
			}
			else
			{
				//				 if ( abs( (getArrayMiddleY() % BOX_H) - BOX_H2 ) >= BOX_H2 - 1 )
				//				 {
				//					 setY( getArrayY( getArrayMiddleY() ) * BOX_H );
				//					 return -5;
				//				 }
				//				 if ( getArrayX( getArrayMiddleX() - BOX_W2 ) != getArrayX( getArrayMiddleX() + x - BOX_W2 ) )
				//				 {
				//					 if ( ga->getBoardField( getArrayX( getArrayMiddleX() + x - BOX_W2 ), getArrayY( getArrayMiddleY() ) ).powerup >= 0 )
				//					 {
				//						 setPowerup( ga->getBoardField( getArrayX( getArrayMiddleX() + x - BOX_W2 ), getArrayY( getArrayMiddleY() ) ).powerup );
				//						 ga->setFieldValPowerup( getArrayX( getArrayMiddleX() + x - BOX_W2 ), getArrayY( getArrayMiddleY() ), -1 );
				//					 }
				//				 }
			}
		}
	}

	if (y > 0)
	{
		//if (getArrayY(getArrayMiddleY()) != getArrayY(getArrayMiddleY() + y + BOX_H2))
		{
			f = ga->getBoardField(getArrayX(getArrayMiddleX()), getArrayY(getArrayMiddleY() + y + BOX_H2));
			if (f.occupancy != TBLANK || f.bomb == true)
			{
				setY(getArrayY(getArrayMiddleY()) * BOX_H);
				return -1;
			}
			else
			{
				//				 if ( abs( (getArrayMiddleX() % BOX_W) - BOX_W2 ) >= BOX_W2 - 1 )
				//				 {
				//					 setX( getArrayX( getArrayMiddleX() ) * BOX_W );
				//					 return -5;
				//				 }
				//				 if ( getArrayY( getArrayMiddleY() + BOX_H2 ) != getArrayY( getArrayMiddleY() + y + BOX_H2 ) )
				//				 {
				//					 if ( ga->getBoardField( getArrayX( getArrayMiddleX() ), getArrayY( getArrayMiddleY() + y + BOX_H2 ) ).powerup >= 0 )
				//					 {
				//						 setPowerup( ga->getBoardField( getArrayX( getArrayMiddleX() ), getArrayY( getArrayMiddleY() + y + BOX_H2 ) ).powerup );
				//						 ga->setFieldValPowerup( getArrayX( getArrayMiddleX() ), getArrayY( getArrayMiddleY() + y + BOX_H2 ), -1 );
				//					 }
				//				 }
			}
		}
	}

	if (y < 0)
	{
		//if (getArrayY(getArrayMiddleY()) != getArrayY(getArrayMiddleY() + y - BOX_H2))
		{
			f = ga->getBoardField(getArrayX(getArrayMiddleX()), getArrayY(getArrayMiddleY() + y - BOX_H2));
			if (f.occupancy != TBLANK || f.bomb == true)
			{
				setY(getArrayY(getArrayMiddleY()) * BOX_H);
				return -1;
			}
			else
			{
				//				 if ( abs( (getArrayMiddleX() % BOX_W) - BOX_W2 ) >= BOX_W2 - 1 )
				//				 {
				//					 setX( getArrayX( getArrayMiddleX() ) * BOX_W );
				//					 return -5;
				//				 }
				//				 if ( getArrayY( getArrayMiddleY() - BOX_H2 ) != getArrayY( getArrayMiddleY() + y - BOX_H2 ) )
				//				 {
				//					 if ( ga->getBoardField( getArrayX( getArrayMiddleX() ), getArrayY( getArrayMiddleY() + y - BOX_H2 ) ).powerup >= 0 )
				//					 {
				//						 setPowerup( ga->getBoardField( getArrayX( getArrayMiddleX() ), getArrayY( getArrayMiddleY() + y - BOX_H2 ) ).powerup );
				//						 ga->setFieldValPowerup( getArrayX( getArrayMiddleX() ), getArrayY( getArrayMiddleY() + y - BOX_H2 ), -1 );
				//					 }
				//				 }
			}
		}
	}

	if (moveRel(x, y) != 0)
		return -1;

	if (ga->getBoardField(getArrayX(getArrayMiddleX()), getArrayY(getArrayMiddleY())).powerup >= 0)
	{
		incPowerup(ga->getBoardField(getArrayX(getArrayMiddleX()), getArrayY(getArrayMiddleY())).powerup);
		ga->setFieldValPowerup(getArrayX(getArrayMiddleX()), getArrayY(getArrayMiddleY()), -1);

		/* FIX!!!!!!!!
		if (ga->getRandomPowerups() <= 0)
		{
			render.changeAnimStateRandomPowerups(false);
		}
		else
		{
			if (ga->getRandomPowerups() == 1)
			{
				render.changeAnimStateRandomPowerups(true);
			}
		}
		 */
	}

	Sint16 modX, modY;
	Sint16 rdx, rdy;

	modX = getArrayMiddleX() % BOX_W;
	modY = getArrayMiddleY() % BOX_H;

	rdx = abs((getArrayMiddleX() % BOX_W) - BOX_W2) / getSpeedX();
	rdy = abs((getArrayMiddleY() % BOX_H) - BOX_H2) / getSpeedY();

	if (x != 0)
	{
		//		 if ( abs( (getArrayMiddleY() % BOX_H) - BOX_H2 ) == BOX_H2 )
		//		 {
		//			 setX( getArrayX( getArrayMiddleX() ) * BOX_W );
		//			 return -5;
		//		 }
		//		 if ( abs( (getArrayMiddleX() % BOX_W) - BOX_W2 ) == BOX_W2 )
		//		 {
		//			 setY( getArrayY( getArrayMiddleY() ) * BOX_H );
		//			 return -5;
		//		 }

		if (modY < BOX_H2)
		{
			if (getArrayMiddleY() + rdy > BOX_H2)
			{
				setY(getArrayY(getArrayMiddleY()) * BOX_H);
				return -4;
			}
			else
			{
				if (rdy == 0 && (getArrayMiddleY() % BOX_H2) > 0)
				{
					setY(getArrayY(getArrayMiddleY()) * BOX_H);
					return -3;
				}
				else
				{
					return moveRel(0, rdy);
				}
			}
		}
		else if (modY > BOX_H2)
		{
			if (getArrayMiddleY() - rdy < BOX_H2)
			{
				setY(getArrayY(getArrayMiddleY()) * BOX_H);
				return -4;
			}
			else
			{
				if (rdy == 0 && (getArrayMiddleY() % BOX_H2) > 0)
				{
					setY(getArrayY(getArrayMiddleY()) * BOX_H);
					return -3;
				}
				else
				{
					return moveRel(0, -rdy);
				}
			}
		}
	}

	if (y != 0)
	{
		//		 if ( abs( (getArrayMiddleX() % BOX_W) - BOX_W2 ) >= BOX_W2 )
		//		 {
		//			 setY( getArrayY( getArrayMiddleY() ) * BOX_H );
		//			 return -5;
		//		 }
		//		 if ( abs( (getArrayMiddleY() % BOX_H) - BOX_H2 ) >= BOX_H2 )
		//		 {
		//			 setX( getArrayX( getArrayMiddleX() ) * BOX_W );
		//			 return -5;
		//		 }

		if (modX < BOX_W2)
		{
			if (getArrayMiddleX() + rdx > BOX_W2)
			{
				setX(getArrayX(getArrayMiddleX()) * BOX_W);
				return -4;
			}
			else
			{
				if (rdx == 0 && (getArrayMiddleX() % BOX_W2) > 0)
				{
					setX(getArrayX(getArrayMiddleX()) * BOX_W);
					return -3;
				}
				else
				{
					return moveRel(rdx, 0);
				}
			}

		}
		else if (modX > BOX_W2)
		{
			if (getArrayMiddleX() - rdx < BOX_W2)
			{
				setX(getArrayX(getArrayMiddleX()) * BOX_W);
				return -4;
			}
			else
			{
				if (rdx == 0 && (getArrayMiddleX() % BOX_W2) > 0)
				{
					setX(getArrayX(getArrayMiddleX()) * BOX_W);
					return -3;
				}
				else
				{
					return moveRel(-rdx, 0);
				}
			}
		}
	}

	return -91;

	//	 if ( y != 0 )
	//	 {
	//		 if ( getX() % 40 != 0 )
	//			 setX( getArrayX() * 40 );
	//	 }

	//				 if ( x < 0 )
	//					 setY( getArrayY() * 36 + ( modY - modX ) );
	//				 else
	//					 setY( getArrayY() * 36 + ( modY - (18+modX) ) );

}
Exemplo n.º 8
0
void GWindow::moveRel(double dx, double dy) {
    moveRel(R2Vector(dx, dy));
}
Exemplo n.º 9
0
void GWindow::moveRel(int dx, int dy) {
    moveRel(I2Vector(dx, dy));
}