int main(){
	initCanvas("ARCHERY",1300,700);
	
	Polygon rect(650,350,{{50,50},{50,-50},{-50,50},{-50,-50}},4);
	rect.imprint();
	getClick();
}
Esempio n. 2
0
void KeyboardConfig::save()
{
  KConfig config("kcminputrc");

  XKeyboardControl kbd;

  clickVolume = getClick();
  keyboardRepeat = ui->repeatBox->isChecked() ? AutoRepeatModeOn : AutoRepeatModeOff;
  numlockState = getNumLockState();

  kbd.key_click_percent = clickVolume;
  kbd.auto_repeat_mode = keyboardRepeat;
  XChangeKeyboardControl(kapp->getDisplay(),
                           KBKeyClickPercent | KBAutoRepeatMode,
                           &kbd);
  if( keyboardRepeat ) {
    set_repeatrate(ui->delay->value(), ui->rate->value());
  }

  config.setGroup("Keyboard");
  config.writeEntry("ClickVolume",clickVolume);
  config.writeEntry("KeyboardRepeating", (keyboardRepeat == AutoRepeatModeOn));
  config.writeEntry("RepeatRate", ui->rate->value() );
  config.writeEntry("RepeatDelay", ui->delay->value() );
  config.writeEntry("NumLock", numlockState );
  config.sync();
}
int DestClick(points places[20])
{
	
	
	while(true)
	{
		Text td(250,400,"Please click on the destination position (click on the green nodes only.)");
		
		int pos = getClick();//position of the first click is recorded
		td.hide();
		int X = pos/65536;
		int Y = pos%65536;int t=100;
		
		for(int i=0; i<20; i++)
		{
			if((X<=places[i].x+4&&X>=places[i].x-4)&&(Y<=places[i].y+4&&Y>=places[i].y-4))
			t =i;
			
		}
		if(t!=100)
		{
			return t;
			break;
		}
		else
		{
			Text td1(300,400,"Invalid Position. Reloading ...");
			td1.show();
			wait(2);
			td1.hide();
		}
	}
	
	
}
Esempio n. 4
0
void CloudsIntroSequence::selfSetDefaults(){

	selectedQuestion = NULL;
	showingQuestions = false;
	paused = false;
	currentFontSize = -1;
	currentFontExtrusion = -1;
	startedOnclick = false;
	caughtQuestion = NULL;
	titleNoisePosition = 0;
	titleNoiseSpeed = 0;
	hoveringTitle = false;
	currentTitleOpacity = 0;
	bQuestionDebug = false;
	firstQuestionStopped = false;
    
    introNodeChangeTime = 0;
    introNodesShown = true;
	kinectHelperAlpha = 0.0;
	nodeAlphaAttenuate = 1.0;
	
	introNodeOne.introNode = introNodeTwo.introNode = introNodeThree.introNode = true;
	introNodeOne.clickSound = introNodeTwo.clickSound = introNodeThree.clickSound = getClick();
	introNodeOne.selectSound = introNodeTwo.selectSound = getSelectHigh();
	introNodeThree.selectSound = getSelectMid();
	
	introNodeOne.multiplier   =  1;
	introNodeTwo.multiplier   = -1;
	introNodeThree.multiplier =  0;
	
	hintCursorEndPoint = ofVec2f(320,240);

	promptTime = 0.0;
	promptShown = false;
	
	// Set question defaults.
	questionScale = 0.1f;
	helperFontSize = 14;
	questionZStopRange.min = 50;
	questionZStopRange.max = 300;
	perlinOffset = 0;
	
    warpCamera.setNearClip(.01);
	
	timeSinceLastPrompt = 0;
	
	questionChannels.resize(4);
	channelPauseTime.resize(4);
	
#ifdef OCULUS_RIFT
    bCursorInCenter = false;
    startTimeCursorInCenter = 0;
#endif

}
Esempio n. 5
0
int main()
{

  initCanvas("Tiling",W*N,W*N);

  int clickPos = getClick();  // to fix square to leave untiled.

  int holeX = clickPos/65536/W, holeY =(clickPos % 65536)/W;

  Circle c(holeX*W + W/2, holeY*W + W/2, W/2);
  c.setFill();
  c.setColor(COLOR("red"));
  c.imprint();

  tile(0,0,N,holeX,holeY);
  Circle c1(holeX*W + W/2, holeY*W + W/2, W/2);
  c1.setFill();
  c1.setColor(COLOR("red"));
  c1.imprint();

  getClick();

}
Esempio n. 6
0
int main(){
  initCanvas("Car",800,800);

  Car c(200,300,COLOR("blue")), d(200,600,COLOR("red"));
  d.scale(0.5);

  getClick();

  for(int i=0; i<400; i++){
    beginFrame();
    c.forward(1); d.forward(1);
    endFrame();
  }
  getClick();

  for(int i=0; i<90; i++){
    beginFrame();
    d.forward(-1);
    endFrame();
    beginFrame();
    d.forward(-1);
    endFrame();
    beginFrame();
    d.forward(-1);
    endFrame();
    beginFrame();
    d.forward(-1);
    endFrame();
    beginFrame();
    d.forward(-1);
    d.right(1);
    endFrame();
  }
  getClick();

}
int main(){
  initCanvas("Pentagon and Star");
  double pentaV[5][2], starV[5][2];

  for(int i=0; i<5; i++){
    pentaV[i][0] = 100 * cos(2*PI/5*i);
    pentaV[i][1] = 100 * sin(2*PI/5*i);
    starV[i][0] = 100 * cos(4*PI/5*i);
    starV[i][1] = 100 * sin(4*PI/5*i);
  }

  Polygon penta(200,200,pentaV,5);
  Polygon star(200,400,starV,5);

  for(int i=0; i<100; i++){
    penta.left(5);
    star.right(5);
    wait(0.1);
  }

  getClick();
}
Esempio n. 8
0
void CloudsIntroSequence::updateQuestions(){

	for(int i = 0; i < startQuestions.size(); i++){
		CloudsPortal& curQuestion = startQuestions[i];
		curQuestion.scale = questionScale;
		curQuestion.update();
		
		if(curQuestion.hoverPosition.z < warpCamera.getPosition().z){
			curQuestion.hoverPosition.z += questionWrapDistance;
		}
		
		float slowDownFactor = 0.0;
		//hold the questions
		if(questionChannels[ curQuestion.tunnelQuadrantIndex ]){
			//let it go with time
			slowDownFactor = powf(ofMap(ofGetElapsedTimef(),
											  channelPauseTime[curQuestion.tunnelQuadrantIndex] + questionPauseDuration,
											  channelPauseTime[curQuestion.tunnelQuadrantIndex] + questionPauseDuration+2, 1.0, 0.0, true), 2.0);
			if(slowDownFactor == 0.0){
				questionChannels[ curQuestion.tunnelQuadrantIndex ] = false;
			}
			
		}
		else{
			float distanceFromCamera = (curQuestion.hoverPosition.z - warpCamera.getPosition().z);
			//if it's in front of the stop range
			if(distanceFromCamera > questionZStopRange.min){
				slowDownFactor = powf(ofMap(distanceFromCamera, questionZStopRange.min, questionZStopRange.max, 1.0, 0.0, true), 2.0);
//				curQuestion.hoverPosition.z += slowDownFactor * cameraForwardSpeed;
				if(slowDownFactor > .9){
					//pause this node and all the ones behind it
                    if(!firstQuestionStopped){
                        firstQuestionStoppedTime = ofGetElapsedTimef();
                        firstQuestionStopped = true;
                    }
					questionChannels[curQuestion.tunnelQuadrantIndex] = true;
					channelPauseTime[curQuestion.tunnelQuadrantIndex] = ofGetElapsedTimef();
				}
			}
		}
		
		if(&curQuestion == caughtQuestion){
			slowDownFactor = 1.0;
		}
		
		curQuestion.hoverPosition.z += cameraForwardSpeed * slowDownFactor;

		if(curQuestion.hoverPosition.z - warpCamera.getPosition().z < questionZStopRange.max || &curQuestion == caughtQuestion){
#ifdef OCULUS_RIFT
            ofVec3f screenPos = getOculusRift().worldToScreen(curQuestion.hoverPosition, true);
			ofRectangle viewport = getOculusRift().getOculusViewport();
            float distanceToQuestion = ofDist(screenPos.x, screenPos.y,viewport.getCenter().x, viewport.getCenter().y);
#else
            ofVec2f mouseNode = cursor;
			float distanceToQuestion = startQuestions[i].screenPosition.distance(mouseNode);
#endif
			if(selectedQuestion == NULL && caughtQuestion == NULL){
				if( distanceToQuestion < questionTugDistance.max ){
					if(distanceToQuestion < questionTugDistance.min){
						caughtQuestion = &curQuestion;
						if (caughtQuestion->startHovering()) {
							getClick()->setPosition(0);
							getClick()->play();
                        }
					}
				}
			}
			
			//we have a caught question make sure it's still close
			else if(caughtQuestion == &curQuestion){

				if( caughtQuestion->isSelected() && !bQuestionDebug && selectedQuestion == NULL){
					getSelectLow()->setPosition(0);
					getSelectLow()->play();

					selectedQuestion = caughtQuestion;
					selectedQuestionTime = ofGetElapsedTimef();
					selectQuestionStartPos = warpCamera.getPosition();
					selectQuestionStartRot = warpCamera.getOrientationQuat();

					CloudsPortalEventArgs args( GetTranslationForString( ofToUpper(selectedQuestion->question) ) );
					ofNotifyEvent(events.portalHoverBegan, args);
					
				}
				else if(distanceToQuestion > questionTugDistance.max && selectedQuestion == NULL){
					caughtQuestion->stopHovering();
					caughtQuestion = NULL;
                    if(firstQuestionStopped){
                        firstQuestionStoppedTime = ofGetElapsedTimef();
                    }
				}
			}
		}
	}
    
    if (caughtQuestion != NULL) {
        // move the sticky cursor towards the caught question
        stickyCursor.interpolate(caughtQuestion->screenPosition - ofVec2f(bleed,bleed)*.5, 0.2f);
    }
    else {
        stickyCursor.interpolate(cursor, 0.5f);
    }
}
Esempio n. 9
0
CloudsIntroSequence::CloudsIntroSequence(){
	getSelectLow();
	getSelectMid();
	getSelectHigh();
	getClick();
}
void playgame(int p)
{
    int playerState[8][6];     //represents cell belonging to player
    int orbCount[8][6];    //represents no of rbs inthe cell

    for(int nrow=0;nrow<8;nrow++)
    {
        for(int ncol=0;ncol<6;ncol++)
        {
            playerState[nrow][ncol]=0;  //initilizing the cell state to be zero which means that cell donot belong any of the player
            orbCount[nrow][ncol]=0;     //initilizing no of orbs in th cell to be zero
        }
    }

    int player=1;

    while(true)
    {
    wrongCell:

        draw_grid(player%2,(player/2)%2,((player/2)/2)%2);
        int iclick=getClick();                                  // iclick will take the position of the mouse click
        int xpos=iclick/65536;                                  // xpos and the y pos will give the x and y position respectively of the mouse click
        int ypos=iclick%65536;
        int r_click=ypos/100;                                    // r_click and c_click will take value of row and the column in which it was clicked
        int c_click=xpos/100;

        if(playerState[r_click][c_click]==0)
        {                                                       // if the cell is empty it places an orb
            playerState[r_click][c_click]=player;
            orbCount[r_click][c_click]++;
            Circle c(c_click*100+50,r_click*100+50,15);
            c.setColor(COLOR(255*(player%2),255*((player/2)%2),255*(((player/2)/2)%2)));
            c.setFill();
            c.imprint();

        }

        else if(playerState[r_click][c_click]==player)
        {                                                   // if cell is not empty and if the player clicks in the cell corresponding cell and it is not reached the
        orbCount[r_click][c_click]++;                       //    critical mass then it will take to expnasion function
        expand(playerState,orbCount,r_click,c_click,player);
        }

        else if(playerState[r_click][c_click]!=player)          //  if the player clicks on the cell corresponding other player then it goes to the label : wrongCell
            goto wrongCell;

    int count=0;int playerCount[4]={0,0,0,0};

    for(int i=0;i<8;i++)
    {
        for(int j=0;j<6;j++)
        {
            count=count+orbCount[i][j];
        }
    }

    if(p==2)
    {
        for(int k=1;k<=2;k++)
        {
            for(int i=0;i<8;i++)
            {
                for(int j=0;j<6;j++)
                {                                                                       // every time it counts the no. of orbs corresponding players
                    if(orbCount[i][j]!=0&&playerState[i][j]==k)
                        playerCount[k-1]=playerCount[k-1]+orbCount[i][j];
                }
            }
        }
        if(count<=2)
        {
            if(player==1)
                player=2;
            else if(player==2)
                player=1;
        }
        else if(count>2)
        {
            if(player==1&&playerCount[1]!=0)
                player=2;                           //if the orbs corresponding to the player is 0 the that player will be eliminated otherwise player will swap to next player
            else if(player==1&&playerCount[1]==0)
            {
                wait(0.5);
                Rectangle r1(300,400,600,800); r1.setFill(1); r1.setColor(COLOR("white")); r1.imprint();
                Text t1(350,50,"WINS"); t1.imprint();
                Text t2(250,50,"PLAYER"); t2.imprint();
                Text t3(300,50,player); t3.imprint();

                cout<<"PLAYER "<<player<<" WINS"<<endl;
                cout<<"GAME OVER"<<endl;
                break;
            }
            else if(player==2&&playerCount[0]!=0)
                player=1;
            else if(player==2&&playerCount[0]==0)
            {
                wait(0.5);
                Rectangle r1(300,400,600,800); r1.setFill(1); r1.setColor(COLOR("white")); r1.imprint();
                Text t1(350,50,"WINS"); t1.imprint();
                Text t2(250,50,"PLAYER"); t2.imprint();
                Text t3(300,50,player); t3.imprint();
                cout<<endl<<"PLAYER "<<player<<" WINS"<<endl;
                cout<<"GAME OVER"<<endl;
                break;
            }

        }
    }
                                                        // if the the no.of players are 3 then this will excuete
    else if(p==3)
    {
        for(int k=1;k<=3;k++)
        {
            for(int i=0;i<8;i++)
            {
                for(int j=0;j<6;j++)
                {
                    if(orbCount[i][j]!=0&&playerState[i][j]==k)
                    playerCount[k-1]=playerCount[k-1]+orbCount[i][j];
                }
            }
        }
        if(count<=3)
        {
            if(player==1)
                player=2;
            else if(player==2)
                player=3;
            else if(player==3)
                player=1;
        }
        else if(count>=3)
        {
            if(player==1&&playerCount[1]!=0)
                player=2;
            else if(player==1&&playerCount[1]==0&&playerCount[2]!=0)
            {
                player=3;
            }
            else if(player==1&&playerCount[1]==0&&playerCount[2]==0)
            {
                wait(0.5);
                Rectangle r1(300,400,600,800); r1.setFill(1); r1.setColor(COLOR("white")); r1.imprint();
                Text t1(350,50,"WINS"); t1.imprint();
                Text t2(250,50,"PLAYER"); t2.imprint();
                Text t3(300,50,player); t3.imprint();
                cout<<"PLAYER "<<player<<" WINS"<<endl;
                cout<<"GAME OVER"<<endl;
                break;
            }
            else if(player==2&&playerCount[2]!=0)
            {
                player=3;
            }
            else if(player==2&&playerCount[2]==0&&playerCount[0]!=0)
            {
                player=1;
            }
            else if(player==2&&playerCount[2]==0&&playerCount[0]==0)
            {
                wait(0.5);
                Rectangle r1(300,400,600,800); r1.setFill(1); r1.setColor(COLOR("white")); r1.imprint();
                Text t1(350,50,"WINS"); t1.imprint();
                Text t2(250,50,"PLAYER"); t2.imprint();
                Text t3(300,50,player); t3.imprint();
                cout<<"PLAYER "<<player<<" WINS"<<endl;
                cout<<"GAME OVER"<<endl;
                break;
            }
            else if(player==3&&playerCount[0]!=0)
                player=1;
            else if(player==3&&playerCount[0]==0&&playerCount[1]!=0)
            {
                player=2;
            }
            else if(player==3&&playerCount[0]==0&&playerCount[1]==0)
            {
                wait(0.5);
                Rectangle r1(300,400,600,800); r1.setFill(1); r1.setColor(COLOR("white")); r1.imprint();
                Text t1(350,50,"WINS"); t1.imprint();
                Text t2(250,50,"PLAYER"); t2.imprint();
                Text t3(300,50,player); t3.imprint();
                cout<<"PLAYER "<<player<<" WINS";
                cout<<"GAME OVER"<<endl;
                break;
            }
        }
    }
    else if(p==4)
    {                                               // if the no.of players are 4  then this will excute.
        for(int k=1;k<=4;k++)
        {
            for(int i=0;i<8;i++)
            {
                for(int j=0;j<6;j++)
                {
                    if(orbCount[i][j]!=0&&playerState[i][j]==k)
                        playerCount[k-1]=playerCount[k-1]+orbCount[i][j];
                }
            }
        }
        if(count<=4)
        {
            if(player==1)
                player=2;
            else if(player==2)
                player=3;
            else if(player==3)
                player=4;
            else if(player==4)
                player=1;
        }
        else if(count>4)
        {
            if(player==1&&playerCount[1]!=0)
                player=2;
            else if(player==1&&playerCount[1]==0&&playerCount[2]!=0)
                player=3;
            else if(player==1&&playerCount[1]==0&&playerCount[2]==0&&playerCount[3]!=0)
                player=4;
            else if(player==1&&playerCount[1]==0&&playerCount[2]==0&&playerCount[3]==0)
            {
                wait(0.5);
                Rectangle r1(300,400,600,800); r1.setFill(1); r1.setColor(COLOR("white")); r1.imprint();
                Text t1(350,50,"WINS"); t1.imprint();
                Text t2(250,50,"PLAYER"); t2.imprint();
                Text t3(300,50,player); t3.imprint();
                cout<<"PLAYER "<<player<<" WINS"<<endl;
                cout<<"GAME OVER"<<endl;
                break;
            }
            else if(player==2&&playerCount[2]!=0)
                player=3;
            else if(player==2&&playerCount[2]==0&&playerCount[3]!=0)
                player=4;
            else if(player==2&&playerCount[2]==0&&playerCount[3]==0&&playerCount[0]!=0)
                player=1;
            else if(player==2&&playerCount[2]==0&&playerCount[3]==0&&playerCount[0]==0)
            {
                wait(0.5);
                Rectangle r1(300,400,600,800); r1.setFill(1); r1.setColor(COLOR("white")); r1.imprint();
                Text t1(350,50,"WINS"); t1.imprint();
                Text t2(250,50,"PLAYER"); t2.imprint();
                Text t3(300,50,player); t3.imprint();
                cout<<"PLAYER "<<player<<" WINS"<<endl;
                cout<<"GAME OVER"<<endl;
                break;
            }
            else if(player==3&&playerCount[3]!=0)
                player=4;
            else if(player==3&&playerCount[3]==0&&playerCount[0]!=0)
                player=1;
            else if(player==3&&playerCount[3]==0&&playerCount[0]==0&&playerCount[1]!=0)
                player=2;
            else if(player==3&&playerCount[3]==0&&playerCount[0]==0&&playerCount[1]==0)
            {
                wait(0.5);
                Rectangle r1(300,400,600,800); r1.setFill(1); r1.setColor(COLOR("white")); r1.imprint();
                Text t1(350,50,"WINS"); t1.imprint();
                Text t2(250,50,"PLAYER"); t2.imprint();
                Text t3(300,50,player); t3.imprint();
                cout<<endl<<"PLAYER "<<player<<" WINS"<<endl;
                cout<<"GAME OVER"<<endl;
                break;
            }
            else if(player==4&&playerCount[0]!=0)
                player=1;
            else if(player==4&&playerCount[0]==0&&playerCount[1]!=0)
                player=2;
            else if(player==4&&playerCount[0]==0&&playerCount[1]==0&&playerCount[2]!=0)
                player=3;
            else if(player==4&&playerCount[0]==0&&playerCount[1]==0&&playerCount[2]==0)
            {
                wait(0.5);
                Rectangle r1(300,400,600,800); r1.setFill(1); r1.setColor(COLOR("white")); r1.imprint();
                Text t1(350,50,"WINS"); t1.imprint();
                Text t2(250,50,"PLAYER"); t2.imprint();
                Text t3(300,50,player); t3.imprint();
                cout<<"PLAYER "<<player<<" WINS"<<endl;
                cout<<"GAME OVER"<<endl;
                break;
            }
        }
    }

    }
}
Esempio n. 11
0
int main(){
	initCanvas("tic-tac-toe",150,150);
	int checkout;
	for (int i=0; i<2; i++) {
		Line l1(50+i*50,0,50+i*50,150);
		l1.imprint();
		Line l2(0,50+i*50,150,50+i*50);
		l2.imprint();
	}; // just prints a 3X3 cube
	
	int square[3][3],a,b;
	for(a=0;a<3;a++){
		for( b=0;b<3;b++){
			square[a][b]=0;
		}
	} // assigns a definite variable to each square, eg., a[i][j] to square (i,j)
	int n,pos;
	for(n=1;n<10;n++){
		pos=getClick();			//getClick...click the required slot
		int i=(pos/65536)/50;			
		int j=(pos%65536)/50;
		
		double g=(pos/65536)/50;
		double h=(pos%65536)/50;
		if(n%2==1){
			Text t(25+50*g,25+50*h,"x"); 
			t.imprint();
		}
		if(n%2==0){
			Text t(25+50*g,25+50*h,"0");
			t.imprint();
		}												//print X or O accordingly
		
		if(n%2==1) square[i][j]=1;			// first player virtually denoted by 1,thus assign all its square 1
		if(n%2==0) square[i][j]=2;		//2nd player by 2,thus assign all its square 2
		
		if(n>4){									//before n=5, its impossible to complete the game
			int q;								
			if((square[0][0]*square[1][1]*square[2][2]==1)||(square[0][2]*square[1][1]*square[2][0]==1)){
				checkout=1;
				cout<<"player 1 wins"<<endl;
				break;
				}										//check diagonal for p1
			if((square[0][0]*square[1][1]*square[2][2]==8)||(square[0][2]*square[1][1]*square[2][0]==8)){
				checkout=1;
				cout<<"player 2 wins"<<endl;
				break;
			}											//check diagonal for p1
			for(q=0;q<3;q++){
				int b=square[q][0]*square[q][1]*square[q][2], c=square[0][q]*square[1][q]*square[2][q]; 
				if(b==1||c==1){
					checkout=1;
					cout<<"player 1 wins"<<endl;
					break;							//check horizontal and vertical for p1
				}
				if(b==8||c==8){
					checkout=1;
					cout<<"player 2 wins";
					break;							//check horizontal and vertical for p1
				}
			}
		}
		if(checkout==1) break;				//breaks the main for loop if someone wins
	}
	if(n==10)
	cout<<"invalid";								//in case no one wins...its a LOL.
}