Ejemplo n.º 1
0
// 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;
	}
Ejemplo n.º 2
0
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;
   }
Ejemplo n.º 3
0
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';
        count1++;
                     }

   if (J.IsInside(p)) {
        Virtualkeyboard.RenderText(UpperLeft,LowerRight,"J", 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]='J';
        count1++;
                     }

   if (K.IsInside(p)) {
        Virtualkeyboard.RenderText(UpperLeft,LowerRight,"K", 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]='K';
        count1++;
                     }

   if (L.IsInside(p)) {
        Virtualkeyboard.RenderText(UpperLeft,LowerRight,"L", 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]='L';
        count1++;
                     }


   if (M.IsInside(p)) {
        Virtualkeyboard.RenderText(UpperLeft,LowerRight,"M", 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]='M';
        count1++;
                     }

   if (N.IsInside(p)) {
        Virtualkeyboard.RenderText(UpperLeft,LowerRight,"N", 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]='N';
        count1++;
                     }

   if (O.IsInside(p)) {
        Virtualkeyboard.RenderText(UpperLeft,LowerRight,"O", 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]='O';
        count1++;
                     }

   if (P.IsInside(p)) {
        Virtualkeyboard.RenderText(UpperLeft,LowerRight,"P", 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]='P';
        count1++;
                     }

   if (Q.IsInside(p)) {
        Virtualkeyboard.RenderText(UpperLeft,LowerRight,"Q", 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]='Q';
        count1++;
                     }

   if (R.IsInside(p)) {
        Virtualkeyboard.RenderText(UpperLeft,LowerRight,"R", 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]='R';
        count1++;
                     }

   if (S.IsInside(p)) {
        Virtualkeyboard.RenderText(UpperLeft,LowerRight,"S", 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]='S';
        count1++;
                     }

   if (T.IsInside(p)) {
        Virtualkeyboard.RenderText(UpperLeft,LowerRight,"T", 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]='T';
        count1++;
                     }

   if (U.IsInside(p)) {
        Virtualkeyboard.RenderText(UpperLeft,LowerRight,"U", 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]='U';
        count1++;
                     }

   if (V.IsInside(p)) {
        Virtualkeyboard.RenderText(UpperLeft,LowerRight,"V", 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]='V';
        count1++;
                     }

   if (W.IsInside(p)) {
        Virtualkeyboard.RenderText(UpperLeft,LowerRight,"W", 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]='W';
        count1++;
                     }

   if (X.IsInside(p)) {
        Virtualkeyboard.RenderText(UpperLeft,LowerRight,"X", 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]='X';
        count1++;
                     }

   if (Y.IsInside(p)) {
        Virtualkeyboard.RenderText(UpperLeft,LowerRight,"Y", 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]='Y';
        count1++;
                     }    

if (Z.IsInside(p)) {
        Virtualkeyboard.RenderText(UpperLeft,LowerRight,"Z", 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]='Z';
        count1++;
                     }

if (SpaceBar.IsInside(p)) {
        Virtualkeyboard.RenderText(UpperLeft,LowerRight," ", White);
        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]=' ';
        count1++;
                     }

if (Backspace.IsInside(p)) {
       
       if(UpperLeft.GetXDistance()>=6.0){ 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;
        float UX=UpperLeft.GetXDistance();

        if(UX<6.0) 
                 {
                  UpperLeft= Position(6.0,10.0);
                  LowerRight=Position(6.2,10.2);
                 }
        
        Virtualkeyboard.RenderText(UpperLeft,LowerRight," ", White);

        name[count1-1]= '\0';
	count1--;
                     }


    if (ENTER.IsInside(p)) {
        Virtualkeyboard.RenderText(Position(2.5,6.5),(10.0,14.0),hello+name+Excl, Blue);
	
	Virtualkeyboard.SetTimerCallback(NameTimer);
        Virtualkeyboard.StartTimer(2000);
			   }

return 0;
}