コード例 #1
0
int MainMouseClickEvent(const Position &p)
{
	if (Play.IsInside(p))
	{	
		 system("./Playfunccall");
		 
	}
	
	if (How.IsInside(p))
	{	//Main.Close();
 		Howto.Open();
		assert(Howto.GetStatus() == WindowOpen);
		 Hplay.Load("hplay.xpm");
		assert(Hplay.GetStatus() == BitMapOkay);
		Hplay.SetPosition(Position(0.0,0.0));
		Hplay.Draw();
	}
	if (Options.IsInside(p))
	{
		system("./acceptheightwidth_new");
	

	}	
	if (Loop.IsInside(p))
	{	 		system("./loopsolverfuncall");
 			
 }
	if (Exit.IsInside(p))
	{
 		ApiEnd();
		assert(Exit1.GetStatus() == WindowOpen);
		}
		return 1;
}
コード例 #2
0
ファイル: main.cpp プロジェクト: jemaloqiu/ros-vision-qt
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    a.setApplicationVersion(QUOTE(APP_VERSION));
    SimpleWindow w;
    w.show();
    w.setGeometry(X_INIT, Y_INIT, w.width(), w.height());

    return a.exec();  
}
コード例 #3
0
ファイル: movement.cpp プロジェクト: umangm/Snake
// Function to delete the tail
void taildelete(SimpleWindow &snake,int r, float snakepos[][2])       //to delete cells between tail and cell r
		{  snake.RenderRectangle
			(Position(snakepos[n-1][0],snakepos[n-1][1]),
			 Position(snakepos[n-1][0]+0.4,snakepos[n-1][1]+0.4),White,false
			);

		 for(i=n-1; i>0;i--)
			{ snakepos[i][1]=snakepos[i-1][1];
			  snakepos[i][0]=snakepos[i-1][0];
			 }
		}
コード例 #4
0
int ApiMain()
 {
 	Main.Open();
 	assert(Main.GetStatus() == WindowOpen);
	Wall.Load("wl3.xpm");
	assert(Wall.GetStatus() == BitMapOkay);
	Wall.SetPosition(Position(0.0,0.0));
	Wall.Draw();
	assert(Main.GetStatus() == WindowOpen);
	Play.Load("play2.xpm");
	assert(Play.GetStatus() == BitMapOkay);
	Play.SetPosition(Position(4.3,4.0));
	Play.Draw();
	assert(Main.GetStatus() == WindowOpen);
	How.Load("how2.xpm");
	assert(How.GetStatus() == BitMapOkay);
	How.SetPosition(Position(4.3,5.5));
	How.Draw();
	assert(Main.GetStatus() == WindowOpen);
	Options.Load("option2.xpm");
	assert(Options.GetStatus() == BitMapOkay);
	Options.SetPosition(Position(4.3,7.0));
	Options.Draw();
	assert(Main.GetStatus() == WindowOpen);
	Loop.Load("loop2.xpm");
	assert(Loop.GetStatus() == BitMapOkay);
	Loop.SetPosition(Position(4.3,8.5));
	Loop.Draw();
	assert(Main.GetStatus() == WindowOpen);
	Exit.Load("exit2.xpm");
	assert(Exit.GetStatus() == BitMapOkay);
	Exit.SetPosition(Position(4.3,10.0));
	Exit.Draw();	
	Main.SetMouseClickCallback(MainMouseClickEvent);
	return 0;
}
コード例 #5
0
//Main Program******************************************************************************************************************
int ApiMain()
 {
	
	
	cout<<"*******************Welcome To  The Game****************************"<<endl;
	cout<<"Enter Your Name ";
	cin>>username;
	sprintf(welcome,"Welcome To The Game %s",username);	
	Game.Open();																			
	

	AlertWindow("Loading","Your Game Will Load In A While..");
	Game.RenderText(Position(14,7.5),"Loading Game Please Wait....!!!",Red,White);
	Game.RenderText(Position(14,3.5),"Star Wars",Red,Black);
	RectangleShape r(Game,Position(14,8.5),Black,28,1);
	r.Draw();
	
	//loading all images*****************************************************************************************************
	background.Load("images/background.xpm");
	assert(background.GetStatus() == BitMapOkay);
	background.SetPosition(Position(0,0));
	background.Draw();
	Game.RenderText(Position(14,3.5),"Star Wars",Red,Black);
	Game.RenderText(Position(15,7.5),"Loading Game Please Wait....!!!",Red,Black);
	r.Draw();
	RectangleShape fill(Game,Position(1,8.5),White,2,1);
	fill.Draw();
	Game.RenderText(Position(14,8.5),"Loading....",Black,White);
	
	ballimage.Load("images/ball.xpm");
	assert(ballimage.GetStatus() == BitMapOkay);
	fill.SetPosition(Position(3,8.5));
	fill.Draw();
	Game.RenderText(Position(14,8.5),"Loading....",Black,White);
	
	exit1.Load("images/exitunpressed.xpm");
	assert(exit1.GetStatus() == BitMapOkay);
	exit1.SetPosition(Position(26.3,14.5));
	inst1.Load("images/instruction1.xpm");
	assert(inst1.GetStatus() == BitMapOkay);
	inst1.SetPosition(Position(6,2));
	fill.SetPosition(Position(5,8.5));
	fill.Draw();
	Game.RenderText(Position(14,8.5),"Loading1....",Black,White);
	
	exit2.Load("images/exitpressed.xpm");
	assert(exit2.GetStatus() == BitMapOkay);
	exit2.SetPosition(Position(26.3,14.5));
	inst2.Load("images/instruction2.xpm");
	assert(inst2.GetStatus() == BitMapOkay);
	inst2.SetPosition(Position(6,2));
	fill.SetPosition(Position(7,8.5));
	fill.Draw();
	Game.RenderText(Position(14,8.5),"Loading....",Black,White);
	
	obstacleimage.Load("images/obstacle.xpm");
	assert(obstacleimage.GetStatus() == BitMapOkay);
	fill.SetPosition(Position(9,8.5));
	fill.Draw();
	Game.RenderText(Position(14,8.5),"Loading....",Black,White);
	
	starti.Load("images/start.xpm");
	assert(starti.GetStatus() == BitMapOkay);
	fill.SetPosition(Position(11,8.5));
	fill.Draw();
	Game.RenderText(Position(14,8.5),"Loading....",Black,White);
	
	highscorei.Load("images/highscores.xpm");
	assert(highscorei.GetStatus() == BitMapOkay);
	fill.SetPosition(Position(13,8.5));
	fill.Draw();
	Game.RenderText(Position(14,8.5),"Loading....",Black,White);
	
	leveli.Load("images/level.xpm");
	assert(leveli.GetStatus() == BitMapOkay);
	fill.SetPosition(Position(15,8.5));
	fill.Draw();
	Game.RenderText(Position(14,8.5),"Loading....",Black,White);
	
	instructioni.Load("images/instructions.xpm");
	assert(instructioni.GetStatus() == BitMapOkay);
	fill.SetPosition(Position(17,8.5));
	fill.Draw();
	Game.RenderText(Position(14,8.5),"Loading....",Black,White);
	
	crediti.Load("images/credit.xpm");
	assert(crediti.GetStatus() == BitMapOkay);
	fill.SetPosition(Position(19,8.5));
	fill.Draw();
	Game.RenderText(Position(14,8.5),"Loading....",Black,White);
	
	exiti.Load("images/quit.xpm");
	assert(exiti.GetStatus() == BitMapOkay);
	fill.SetPosition(Position(21,8.5));
	fill.Draw();
	Game.RenderText(Position(14,8.5),"Loading....",Black,White);
	
	starwar.Load("images/starwars.xpm");
	assert(starwar.GetStatus() == BitMapOkay);
	fill.SetPosition(Position(23,8.5));
	fill.Draw();
	Game.RenderText(Position(14,8.5),"Loading....",Black,White);
	
	explode.Load("images/explode.xpm");
	assert(explode.GetStatus() == BitMapOkay);
	explode.SetPosition(Position(-4,-4));
	fill.SetPosition(Position(25,8.5));
	fill.Draw();
	Game.RenderText(Position(14,8.5),"Loading....",Black,White);
	
	next.Load("images/next.xpm");
	assert(next.GetStatus() == BitMapOkay);
	next.SetPosition(Position(24,14.4));
	fill.SetPosition(Position(27,8.5));
	fill.Draw();
	Game.RenderText(Position(14,8.5),"Loading....",Black,White);
	AlertWindow("Welcome",welcome);


	//Reading from highscore.txt and storing them in an array.
	fp=fopen("HighScore.txt","r");
	char input[120];
	for(int i=0;i<10;i++)
	{
		fgets(input,120,fp);
		sscanf(input,"%s%d",highscoreuser[i],&highscore[i]);
	}
	fclose(fp);
	
	start();  			//Calling start function

	
	/*RectangleShape NewGame(Game,Position(14,4.5),Blue,8,2);
	NewGame.Draw();
	Game.RenderText(Position(14,4.5),"New Game",Blue,Red);
	mouse();*/
	//playgame();
	


	
	return 0;
}
コード例 #6
0
ファイル: 3.cpp プロジェクト: Tanmay-r/cs101Project
int ApiMain()
{	
	//SimpleWindow Game_Board("Game Board",19.5,19.5,Position(4.0,2.0));	
	//SimpleWindow Welcome_Screen("Welcome To Monopoly",18.0,12.0,Position(0.0,0.0));
	//SimpleWindow Roll_Dice("Roll Dice",25.0,18.0,Position(4.0,2.0));

	/*BitMap Dice_Image(Roll_Dice);
	BitMap Dice_1(Roll_Dice);
	BitMap Dice_2(Roll_Dice);
	BitMap Dice_3(Roll_Dice);
	BitMap Dice_4(Roll_Dice);
	BitMap Dice_5(Roll_Dice);
	BitMap Dice_6(Roll_Dice);
	BitMap Dice_text(Roll_Dice);
	BitMap Game_Board_Image(Game_Board);*/
	BitMap Welcome_Image(Welcome_Screen);
	

	int current_position=0;
	int flag1=0;

	class city cty[20];
	class player plyr[2];
	class company cmpny[6]; 
					
	Monopoly.Open();
	Welcome_Image.Load("Welcome.xpm");
	Position WindowCenter=Monopoly.GetCenter();
	Position Welcome_ImagePosition= WindowCenter+Position(-0.5*Welcome_Image.GetWidth(),-0.5*Welcome_Image.GetHeight());
	Welcome_Image.SetPosition(Welcome_ImagePosition);
	Welcome_Image.Draw();
	cin>>flag1;
	
	if(flag1==2)
	{
		cout<<"Thank You"<<endl;
		return 1;
	}
	if((flag1!=1)&&(flag1!=2))
	{
		cout<<"INVALID INPUT, GAME QUITS"<<endl;
		return 2;
	}
	if(flag1==1)
	{
		cout<<" Let's Start The Game: "<<endl;
	                                            
		FILE *fp1,*fp2,*fp3;
		fp1=fopen("city.txt","r");
		fp2=fopen("company.txt","r");								
	
		if(fp1==NULL)
		{
			cout<<"\nCannot open the file city.txt";
			exit(0);
		}
		if(fp2==NULL)
		{
			cout<<"\nCannot open the file company.txt";
			exit(0);
		}
		i=0; 
		char str1[20];												
		int id, c_rent , hse_rent, htl_rent, t, c_cost, hse_cost, htl_cost, hse_count, htl_count; 			int cty_owner;                 //dummy variables for city
		while(!feof(fp1))
		{
			fscanf(fp1,"%s %d %d %d %d %d %d %d %d %d %d %d",str1,&t,&id,&c_cost,&hse_cost,&htl_cost,&c_rent,&hse_rent,&htl_rent,&hse_count,&htl_count,&cty_owner);
			cty[i].set_details_of_city(str1,id, c_rent,hse_rent,htl_rent,t,c_cost,hse_cost,htl_cost,hse_count,htl_count,cty_owner);
			cty[i].display_details_of_city();
			i++;
			cout<<endl;
		}
		cout<<endl;	
		i=0;
		char str[20], str2[20];
		int p_comp_id,b_rent,p_rent,comp_cost,c_owner;
		while(!feof(fp2))
		{
			fscanf(fp2,"%s %s %d %d %d %d %d %d",str,str2,&id,&p_comp_id,&comp_cost,&b_rent,&p_rent,&c_owner);
			cmpny[i].set_details_of_company(str,str2,id,p_comp_id, b_rent, p_rent,comp_cost,c_owner);
			cmpny[i].display_details_of_company();
			i++;
			cout<<endl;
		}
		for(i=0;i<2;i++)
		{
			plyr[i].set_details_of_player(i,50000,0,0,0,0,0);     
			plyr[i].display_details_of_player();
			cout<<endl;                                        
		}
		fclose(fp1);
		fclose(fp2);	                                                                       	
		int x,y,flag=-1,type_count=0,j,temp;	
		char ch,ch2='n'; 			//flag=0 denotes city, and flag=1 denotes company
//main algorithm	
		start:                                                                //LABEL	
		while((plyr[0].return_balance()>0)&&(plyr[1].return_balance()>0)&&((ch2=='n')||(ch2=='N')))
		{
	    		i=z%2;
	    		cout<<"\nNext player's turn.";
	    		cout<<"\nYour current balance:"<<plyr[i].return_balance();
	    		flag=-1;
			z++;
			/*Roll_Dice.Open();
			
			Position WindowCenter1=Roll_Dice.GetCenter();
				
			
			Dice_text.SetPosition(Dice_textPosition);
			Dice_text.Draw();
			Dice_Image.SetPosition(Dice_ImagePosition);
			Dice_Image.Draw();*/
			Welcome_Image.Erase();
			Dice_Image.Load("dice.xpm");
			Dice_text.Load("df.xpm");
			Dice_1.Load("diceno1.xpm");
			Dice_2.Load("diceno2.xpm");
			Dice_3.Load("diceno3.xpm");
			Dice_4.Load("diceno4.xpm");
			Dice_5.Load("diceno5.xpm");
			Dice_6.Load("diceno6.xpm");
			Position Dice_textPosition=WindowCenter+Position(-0.5*Dice_text.GetWidth(),-0.5*Dice_text.GetHeight());
			Position Dice_ImagePosition= Position(12.0+Exit_Button.GetWidth(),17-Exit_Button.GetHeight());
			Position Dice_1Position= WindowCenter+Position(3.0-0.5*Welcome.GetWidth(),4.0-0.5*Welcome.GetHeight());
			Position Dice_2Position= Dice_1Position+Position(3.0,0.0);
			Dice_text.SetPosition(Dice_textPosition);
			Dice_text.Draw();
			Dice_Image.SetPosition(Dice_ImagePosition);
			Dice_Image.Draw();			
			if(plyr[i].return_turn()==0)
			{
				dice();
			}
			Monopoly.SetMouseClickCallback(MouseClickEvent1);
				
			
			
		
		main_algorithm_start:                                            //LABEL
		
		
		
		
		
		current_position=plyr[i].set_position(dice_sum);
		
		main_algorithm_start_2:
		
		
		if((current_position==9)&&(plyr[i].return_turn()==0))
		{
		    
			if(plyr[i].return_turn()==0)
			{
			cout<<"\nYou've landed in 'JAIL'.Wait for the other player to play.";
			plyr[i].modify_turn(1);
			goto start;
			}
			if(plyr[i].return_turn()>0)
			{	
				if(plyr[i].return_turn()==1)
				{
				cout<<"\nWould you like to pay a fine of Rs. 500, throw three times or miss three turns?";
				cout<<"\nEnter 1, 2 or 3 respectively.";
				cin>>jail_choice[i];
				}
				switch(jail_choice[i])
				{
					case 1:
						plyr[i].modify_balance(-500);
						cout<<"\nRs. 500 has been deducted from your bank balance.";
						cout<<"\nYour current balance : "<<plyr[i].return_balance();
						plyr[i].modify_turn((-1)*(plyr[i].return_turn()));
						dice();
                        plyr[i].set_position(dice_sum);					
						break;		
					case 2:
						int d_sum[3];
						for(j=0;j<3;j++)
						{
							dice();
							if(dice_1==dice_2)
							{
								plyr[i].modify_turn((-1)*(plyr[i].return_turn()));
								goto main_algorithm_start;
							}
							d_sum[j]=dice_sum;
						}
						if((d_sum[0]==d_sum[1])&&(d_sum[1]==d_sum[2]))
						{
							plyr[i].modify_turn((-1)*(plyr[i].return_turn()));
							goto main_algorithm_start;
						}
						cout<<"\nYou've failed to satisfy the condition to be released from 'JAIL'.Hence you've to wait for two more turns.";
					case 3:
						if(plyr[i].return_turn()<3)
						{
							plyr[i].modify_turn(1);
							goto start;
						}
						if(plyr[i].return_turn()==3)
						{
							plyr[i].modify_turn((-1)*(plyr[i].return_turn()));
							goto start;
						}
						break;
					default:
						cout<<"\nInvalid input.You've been released from jail and Rs.500 has been deducted from your bank balance.";
						plyr[i].modify_balance(-500);
						break; 
				}
			}
		}
		
		
		
		                                                                  //chance 
		
		if (current_position==7 || current_position==20)
		{
			cout<<"\nYou have landed at 'CHANCE'.";
			switch (dice_sum)
			{
				case 2:				//SYNTAX DOUBTFUL
					cout<<"\nYou have lost Rs. 2000 in the share market.";
					plyr[i].modify_balance(-2000);
					break;
				case 3:
					cout<<"\nYou have won Rs. 2500 in the lottery!";
					plyr[i].modify_balance(2500);
					break;
				case 4:
					cout<<"\nYou have been fined Rs. 1500 for driving under influence (DUI)";
					plyr[i].modify_balance(-1500);
					break;
				case 5:
					cout<<"\nYou have won Rs. 1000 in a crossword competition!";
					plyr[i].modify_balance(1000);
					break;
				case 6:
					cout<<"\nHouse repairs have cost you Rs. 1500";
					plyr[i].modify_balance(-1500);
					break;
				case 7:
					cout<<"\nYou have won a jackpot of Rs. 2000!";
					plyr[i].modify_balance(2000);
					break;
				case 8:
					cout<<"\nA fire in your godown has caused you a loss of Rs. 3000";
					plyr[i].modify_balance(-3000);
					break;
				case 9:
					if (current_position==7)
					plyr[i].modify_balance(2500);
																	                         //Changed the rules.to be filled.
					break;
				case 10:
					cout<<"\nYou have been sent to the 'JAIL'.";
					plyr[i].jump(9);
					goto main_algorithm_start_2;
					break;
				case 11:
					cout<<"\nYou have won Rs. 3000 for best performance in export!";
					plyr[i].modify_balance(3000);
					break;
				case 12:
					cout<<"\nYou have been sent to the 'REST HOUSE'.";
					plyr[i].jump(27);			                                                        //Changed the rules. Player will NOT miss a turn.
					plyr[i].modify_balance(100);
					break;
			}
		}
		
		
		if((current_position==16)||(current_position==29))                   //community chest
		{
			cout<<"\nYou have landed at 'CHANCE'.";
			switch (dice_sum)
			{
				case 2:
					cout<<"\nIt is your birthday.You have received Rs. 500 as gift.";
					plyr[i].modify_balance(500);
					break;	
				case 3:
				    cout<<"\nYou've been sent to 'JAIL'.";
					plyr[i].jump(9);
					goto main_algorithm_start_2;
					break;
				case 4:
					cout<<"\nYou've won 1st prize in beauty contest.Rs. 2500 has been awarded to you.";
					plyr[i].modify_balance(2500);
					break;
				case 5:
					cout<<"\nYou've to pay medical and school fees totaling Rs. 1000.";
					plyr[i].modify_balance(-1000);
					break;
				case 6:
					cout<<"\nIncome tax refund:You received Rs. 2000.";
					plyr[i].modify_balance(2000);
					break;
				case 7:
					cout<<"\nExpenses for marriage celebration are Rs. 2000.";
					plyr[i].modify_balance(-2000);
					break;
				case 8:
					cout<<"\nYou've been sent to 'REST HOUSE'.";
					plyr[i].jump(27);			                                                        //Changed the rules. Player will NOT miss a turn.
					plyr[i].modify_balance(100);
					break;
				case 9:
					cout<<"\nCost of carrying out general repairs on all your properties is :\n"<<"Rs.50 for each house.\n"<<"Rs.100 for each hotel.";
					plyr[i].modify_balance((-50)*(plyr[i].return_house_count())+(-100)*(plyr[i].return_hotel_count()));
					break;
				case 10:
					cout<<"\nYou've received interest on shares amounting to Rs. 1500.";
					plyr[i].modify_balance(1500);
					break;
				case 11:
					cout<<"\nYou've to pay Insurance Premium amounting to Rs. 1500.";
					plyr[i].modify_balance(-1500);
					break;
				case 12:
					cout<<"\nYou've received Rs. 3000 by selling your stocks.";
					plyr[i].modify_balance(3000);
					break;
			}
		}
		
					
		
		
		
		
		
		if(current_position==18)                                                     //CLUB
		{
			cout<<"\nYou have landed at CLUB HOUSE.";
			plyr[i].modify_balance(-100);
			cout<<"\nRs. 100 deducted from your bank account."; 
		}
		
		if(current_position==27)                                                 //REST HOUSE
		{
			cout<<"\nYou have landed at REST HOUSE.";
			plyr[i].modify_balance(100);
			cout<<"\nRs. 100 deposited in your bank account."; 
		}
		
		if(current_position-dice_sum<0)                                         //START
		{
			cout<<"\nYou have crossed START and Rs. 500 has been deposited in your bank account";
			plyr[i].modify_balance(1500);
		}
		
		
		
		
		
		
		if (current_position==5)				                                    //income tax
		{
			cout<<"\nYou have landed at 'INCOME TAX'."; 
			if (plyr[i].return_city_count()*(50) >500)
			{
				plyr[i].modify_balance(-500);
				cout<<"\nRs. 500 has been deducted fom your bank account.";
			}
			else
			{
				plyr[i].modify_balance((-50)*(plyr[i].return_city_count()));
				cout<<"\nRs. "<<(50)*(plyr[i].return_city_count())<<" has been deducted from your bank account.";
			}
		}
		
		if (current_position==31)				                                //wealth tax
		{
			cout<<"\nYou have landed at 'WEALTH TAX'.";
			if ((plyr[i].return_house_count()+(2)*(plyr[i].return_hotel_count()))*(50) > 500)
			{
				plyr[i].modify_balance(-500);
				cout<<"\nRs. 500 has been deducted from your bank account.";
			}
			else
			{
				plyr[i].modify_balance((-50)*((plyr[i].return_house_count())+(2)*(plyr[i].return_hotel_count())));
				cout<<"\nRs. "<<(-50)*((plyr[i].return_house_count())+(2)*(plyr[i].return_hotel_count()))<<" has been deducted from your bank account.";
			}
		}
		
		
		
				
		
		//city and company
		
		
		
		x=0;				                                            //flag=0 denotes city, and flag=1 denotes company
		for(x=0;x<6;x++)
		{
			if(cmpny[x].return_id()==current_position)
			{
				flag=1;
				break;
			}
		}
		if(flag==1)
		{
			cout<<"\nYou have landed on a company.";
			cmpny[x].display_details_of_company();
			if(cmpny[x].get_owner()==-1)
			{
				cout<<"\nWould you like to buy this company?(y/n)";
				cin>>ch;
				while (!(ch=='y' || ch=='n' || ch=='Y' || ch=='N'))
				{
					cout<<"\nInvalid input, please type your response again. (y/n)";
					cin>>ch;
				}
				if((ch=='y' || ch=='Y'))
				{
					plyr[i].modify_balance((-1)*cmpny[x].return_company_cost());
					cmpny[x].modify_owner(i);
					cout<<"\nCongratulations!!You are the owner of this company.";
					cout<<"\n"<<cmpny[x].return_company_cost()<<" has been deducted from your bank account.";
				}
			}