I have to make this game for my class. It's called penny pitch and it's a popular game at amusement parks.
At random, 15 prizes will be layed out on screen inside a board that has 25 spaces (5 prizes in all... each prize has to be in 3 spaces), along with 1 penny being in 10 different spaces. The prizes and pennies will be in different spaces at random. If a penny (which is represented by a "x") is next to the names of all 3 of the same prizes on the board then the player wins that prize (they can win a doll,poster, game, ball, or/and a puzzle).
Here's what I have so far
It outputs the board (randomly). I need help though. What do I need to do to make 10 pennies randomly appear on the screen along with the prizes? What do I need to do to output what the player won and how do I make it so that there is 3 spaces out of the 25 in which each single prize is in (since the way I have it now, some prizes are in more or in less then 3 spaces; each of the 5 prizes needs to be in 3 spaces out of the 25)?Code:#include<a:mylib.h> #include<lvp\matrix.h> #include<lvp\vector.h> void DisplayMat(matrix<String> &mat)//Displays integer matrix by rows and columns { int a=0; char mt; for(int x=0;x<mat.numrows();x++){ //row counter for(int y=0;y<mat.numcols();y++){ //column counter cout.setf(ios::right); cout.width(3); cout<<mat[x][y]<<" "; a++; if(a%5==0) //spacing cout<<endl; } } } //bool Pennies(){ //matrix<String>mat(5,6) // mat[a][b]=h; // cout<<"(x)"; //} void main(){ clrscr(); randomize(); cout<<"--Penny Pitch--"<<endl; int a,b,o,C,D,E,F,G; String h,c,d,e,f,g,z; matrix<String>mat(5,6); c="puzzle"; d="ball"; e="poster"; f="game"; g="doll"; z="x"; for(int x=0;x<mat.numrows();x++){ for(int y=0;y<mat.numcols();y++){ C=0; D=0; E=0; F=0; G=0; o=1+random(6); a=1+random(4); b=1+random(4); if(o==1) h=c; C++; if(o==2) h=d; D++; if(o==3) h=e; E++; if(o==4) h=f; F++; if(o==5) h=g; G++; if(C=3) cout<<"You won a puzzle!"<<endl; if(D=3) cout<<"You won a ball!"<<endl; if(E=3) cout<<"You won a poster!"<<endl; if(F=3) cout<<"you won a game!"<<endl; if(G=3) cout<<"you won a doll!"<<endl; mat[a][b]=h; } } DisplayMat(mat); // Pennies(); }
Any help will be appreciated![]()



LinkBack URL
About LinkBacks



