Exemplo n.º 1
0
		int Round() {
			Die1.RollDie(); Die2.RollDie();
			Score = Score + Die1.getValue() + Die2.getValue();
			if(Score == 5 || Score == 15 || Score == 25 || Score == 35) {
				if(Money < 5000) {
					Money = 0;
				}
				else {
					Money = Money - 5000;
				}
			}
			if(Score == 10 || Score == 20 || Score == 30 || Score == 40) {
				Money += 10000;
			}
			return Score;
		}
Exemplo n.º 2
0
int main()
{
	//frame setup
	system("title Dice Game");
	system("mode con: cols=63 lines=20");
	system("color 27");
	
	
	//animation array, this was shorteded to var "a" for easy use
	int a[20][2] = {{5,9},{7,7},{9,4},{11,2},{13,2},
					{15,4},{17,6},{19,9},{21,8},{23,7},
					{25,6},{27,5},{29,4},{31,5},{33,6},
					{35,7},{37,8},{39,9},{41,9},{42,9}};
	
	
	//var setup
	Renderer renderer;
	Die die;
	int dice1;
	int dice2;
	int yourScore = 0;
	int dealerScore = 0;
	int input;
	bool even;
	srand(5);
	
	
	//Start Game Here
	cout<< "Note:\n -Number displays work best if you pick less than 10 iterations\n -For best effect dont resize window\n-------------------------------------------------------------";
	cout<< "\nHow Many times do you want to play? ";
	cin >> input;
	cout << "\nEven or odd (0 or 1)? ";
	cin >> even;
	for(int j = 0; j < input; j ++){
		for(int i = 0; i < 20; i ++){
			//clear renderer
			renderer.clear();
			//display roll number
			char rollnum[8] = {'R','o','l','l',' ',(char)(j + 49),':','\0'};
			renderer.write(5,1,rollnum,7);
			//die #1 display
			die.roll();
			switch(dice1 = die.getValue()){
				case 1:
					renderer.draw(a[i][0],a[i][1]," ----- |     ||  O  ||     | ----- ",7,7*5);
					break;
				case 2:
					renderer.draw(a[i][0],a[i][1]," ----- |O    ||     ||    O| ----- ",7,7*5);
					break;
				case 3:
					renderer.draw(a[i][0],a[i][1]," ----- |O    ||  O  ||    O| ----- ",7,7*5);
					break;
				case 4:
					renderer.draw(a[i][0],a[i][1]," ----- |O   O||     ||O   O| ----- ",7,7*5);
					break;
				case 5:
					renderer.draw(a[i][0],a[i][1]," ----- |O   O||  O  ||O   O| ----- ",7,7*5);
					break;
				case 6:
					renderer.draw(a[i][0],a[i][1]," ----- |O   O||O   O||O   O| ----- ",7,7*5);
					break;
			};
			//die #2 display
			die.roll();
			switch(dice2 = die.getValue()){
				case 1:
					renderer.draw(a[i][0]+8,a[i][1]," ----- |     ||  O  ||     | ----- ",7,7*5);
					break;
				case 2:
					renderer.draw(a[i][0]+8,a[i][1]," ----- |O    ||     ||    O| ----- ",7,7*5);
					break;
				case 3:
					renderer.draw(a[i][0]+8,a[i][1]," ----- |O    ||  O  ||    O| ----- ",7,7*5);
					break;
				case 4:
					renderer.draw(a[i][0]+8,a[i][1]," ----- |O   O||     ||O   O| ----- ",7,7*5);
					break;
				case 5:
					renderer.draw(a[i][0]+8,a[i][1]," ----- |O   O||  O  ||O   O| ----- ",7,7*5);
					break;
				case 6:
					renderer.draw(a[i][0]+8,a[i][1]," ----- |O   O||O   O||O   O| ----- ",7,7*5);
					break;
			};
			//render frame
			renderer.render();
			//sleep for a sec then move on to the next frame
			usleep(100000);
		}
		//this if desides who wins the roll
	 	if(even ? (dice1+dice2)%2 == 1 : (dice1+dice2)%2 == 0){
	 		cout<<"\nYou Win!\n";
	 		yourScore ++;
		}else{
			cout << "\nDealer Wins!\n";
			dealerScore ++;
		}
		system("pause");
	}
	//clear renderer
	renderer.clear();
	//end game cstring setup
	char you[30] = {'Y','o','u','r',' ','f','i','n','a','l',' ','s','c','o','r','e',' ','i','s',' ',(char)(yourScore + 48),' ','p','o','i','n','t','s','.','\0'};
	char deal[34] = {'D','e','a','l','e','r',(char)96,'s',' ','f','i','n','a','l',' ','s','c','o','r','e',' ','i','s',' ',(char)(dealerScore + 48),' ','p','o','i','n','t','s','.','\0'};
	char win[9] =  {'Y','o','u',' ','W','i','n','!','\0'};
	char loss[9] =  {'Y','o','u',' ','L','o','s','t','\0'}; 
	//setup and display end game message
	if(yourScore <= dealerScore)
			renderer.write(28,9,loss,8);
	else 
			renderer.write(28,9,win,8);
	renderer.write(16,4,you,29);
	renderer.write(14,6,deal,33);
	renderer.render();
return 0;
}