当前位置: 首页>>代码示例>>C++>>正文


C++ Position::GetYDistance方法代码示例

本文整理汇总了C++中Position::GetYDistance方法的典型用法代码示例。如果您正苦于以下问题:C++ Position::GetYDistance方法的具体用法?C++ Position::GetYDistance怎么用?C++ Position::GetYDistance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Position的用法示例。


在下文中一共展示了Position::GetYDistance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: click

// Mouse clicking function to turn the snake
int click(const Position &p){
	int w=289;	

	if (images.IsInside(p) && state==2) {
        snake.StopTimer();
	state=1;
	}


	if (forward.IsInside(p) && state==1) {
	snake.StartTimer(100);
	state=2;

	}
 
	else { if( ((p.GetXDistance()>snakepos[0][0]+0.4 && p.GetXDistance()<16.0 && p.GetYDistance()<16.0) || Right.IsInside(p) ) && w==289){
			if(q=='u' || q=='d'){
				
				q='r';
				w=1;
				}
		}	   
	if( ((p.GetXDistance()<snakepos[0][0] && p.GetXDistance()<16.0 && p.GetYDistance()<16.0) || Left.IsInside(p) ) && w==289){
			if(q=='u' || q=='d'){
				
				q='l';
				w=2;
				}
		}
	if( ((p.GetYDistance()<snakepos[0][1]  && p.GetXDistance()<16.0 && p.GetYDistance()<16.0) || Up.IsInside(p) ) && w==289){
			if(q=='l' || q=='r'){
				
				q='u';
				w=3;
				}
		}			
	if( ((p.GetYDistance()>snakepos[0][1]+0.4 && p.GetXDistance()<16.0 && p.GetYDistance()<16.0) || Down.IsInside(p) ) && w==289 ){
			if(q=='l' || q=='r'){
				
				q='d';
				w=4;
				}
		}
	    
	    }
	return 3;
	}
开发者ID:umangm,项目名称:Snake,代码行数:48,代码来源:movement.cpp

示例2: user

int user(const Position &p1)
{
 
 int x1,y1;
 
  x=p1.GetXDistance();
  y=p1.GetYDistance();

int snakecheck=0;

 if(x>=6.4&&x<=8.4&&y>=8.0&&y<=10.4)
 {
 snakecheck=1;
 } 
  if(W1Bmp.IsInside(p1))
  {

  W1Bmp.Erase();
  
  writefile();
  
  
  
  }
  
 if(W4Bmp.IsInside(p1))
 {
  UserWindow.Close();
  /*open another(previous) window here*/

 }

 if( W5Bmp.IsInside(p1))
  { void playusermaze();

     playusermaze();

  }
  
 if(x<16.0&&y<16.0&&snakecheck!=1)
 {
  W1Bmp.Draw();
  x=10*x;
  y=10*y;
  
  x1=(int)x;
  y1=(int)y;
  
  x1=x1-(x1%4);
  y1=y1-(y1%4);
 

  x=x1/10.0;
  y=y1/10.0;
  
  if(maze_user[x1][y1]==0)
  { 
   maze_user[x1][y1]=1;        
   renderboundary(x,y);
   createmazeuser();
  }
   else
   {
    maze_user[x1][y1]=0;
       
             UserWindow.RenderRectangle(Position(x,y), Position(x+0.4,y+0.4),
               White, false);

     createmazeuser();       
   }
   }

   return 0;
   }
开发者ID:umangm,项目名称:Snake,代码行数:74,代码来源:usermaze.cpp

示例3: VirtualkeyboardMouseClick

int VirtualkeyboardMouseClick(const Position &p) {
	
   float x=p.GetXDistance();
   float y=p.GetYDistance();
    addX=(0.2 * count1);
   
   //P1=P1 + Position(addX*count1,0.0);
   //P2=P2 + Position(addX*count1,0.0);


   //cout<<x<<" "<<y<<endl;
   //cout<<addX<<endl;

  if (A.IsInside(p)) {
        Virtualkeyboard.RenderText(UpperLeft,LowerRight,"A", Red);
        P1=P1 + Position(0.2,0.0);
        P2=P2 + Position(0.2,0.0);
        UpperLeft = Position(6.0,10.0) +P1;
        LowerRight = Position(6.2,10.2)+P2;
        name[count1]='A';
        count1++;
                     }

   if (B.IsInside(p)) {
        Virtualkeyboard.RenderText(UpperLeft,LowerRight,"B", Red);
        P1=P1 + Position(0.2,0.0);
        P2=P2 + Position(0.2,0.0);
        UpperLeft = Position(6.0,10.0) +P1;
        LowerRight =Position(6.2,10.2)+P2;
        name[count1]='B';
        count1++;
                     }

   if (C.IsInside(p)) {
        Virtualkeyboard.RenderText(UpperLeft,LowerRight,"C", Red);
        P1=P1 + Position(0.2,0.0);
        P2=P2 + Position(0.2,0.0);
        UpperLeft = Position(6.0,10.0)+P1;
        LowerRight = Position(6.2,10.2)+P2;
        name[count1]='C';
        count1++;
                     }

   if (D.IsInside(p)) {
        Virtualkeyboard.RenderText(UpperLeft,LowerRight,"D", Red);
        P1=P1 + Position(0.2,0.0);
        P2=P2 + Position(0.2,0.0);
        UpperLeft = Position(6.0,10.0) +P1;
        LowerRight = Position(6.2,10.2)+P2;
        name[count1]='D';
        count1++;
                     }

   if (E.IsInside(p)) {
        Virtualkeyboard.RenderText(UpperLeft,LowerRight,"E", Red);
        P1=P1 + Position(0.2,0.0);
        P2=P2 + Position(0.2,0.0);
        UpperLeft = Position(6.0,10.0) +P1;
        LowerRight = Position(6.2,10.2)+P2;
        name[count1]='E';
        count1++;
                     }

   if (F.IsInside(p)) {
        Virtualkeyboard.RenderText(UpperLeft,LowerRight,"F", Red);
        P1=P1 + Position(0.2,0.0);
        P2=P2 + Position(0.2,0.0);
        UpperLeft = Position(6.0,10.0) +P1;
        LowerRight = Position(6.2,10.2)+P2;
        name[count1]='F';
        count1++;
                     }

   if (G.IsInside(p)) {
        Virtualkeyboard.RenderText(UpperLeft,LowerRight,"G", Red);
        P1=P1 + Position(0.2,0.0);
        P2=P2 + Position(0.2,0.0);
        UpperLeft = Position(6.0,10.0) +P1;
        LowerRight = Position(6.2,10.2)+P2;
        name[count1]='G';
        count1++;
                     }

   if (H.IsInside(p)) {
        Virtualkeyboard.RenderText(UpperLeft,LowerRight,"H", Red);
        P1=P1 + Position(0.2,0.0);
        P2=P2 + Position(0.2,0.0);
        UpperLeft = Position(6.0,10.0) +P1;
        LowerRight = Position(6.2,10.2)+P2;
        name[count1]='H';
        count1++;
                     }

   if (I.IsInside(p)) {
        Virtualkeyboard.RenderText(UpperLeft,LowerRight,"I", Red);
        P1=P1 + Position(0.2,0.0);
        P2=P2 + Position(0.2,0.0);
        UpperLeft = Position(6.0,10.0) +P1;
        LowerRight = Position(6.2,10.2)+P2;
        name[count1]='I';
//.........这里部分代码省略.........
开发者ID:umangm,项目名称:Snake,代码行数:101,代码来源:virtual.cpp


注:本文中的Position::GetYDistance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。