jj35
YaBB Newbies
Offline
Posts: 1
need help wiyh my assignment I WANT TO LEARN!!!
May 9th , 2010, 5:24pm
//Here is my assignment, we are supposed to finish this for a game of rock, paper, scissors. I can do shapes and stuff but when it comes to this I am STUCK. PLEASE HELP....I want this for a career so I'm trying but I'M stuck. Thank You Very Much! // PlayRockPaperScissors Project // Instructor Example // April 2010 // May 2010 // Added keyReleased functionality to // provide keyboard control of drawing // Added code for procudure functions // promptForPlayersChoice, // getPlayersChoice, and // getComputersChoice // boolean keyStruck = true; char playersChoice; char computersChoice; PFont myFont; void setup() { size( 250, 350 ); background( 0, 0, 255 ); myFont = createFont( "Arial", 20, false ); textFont(myFont); } void draw() { if (!keyStruck) { keyStruck = true; promptForPlayersChoice(); getPlayersChoice(); getComputersChoice(); displayTheComputersAndPlayersChoices(); displayTheWinningChoice(); } } void promptForPlayersChoice() { background( 0, 0, 255 ); float w = textWidth( "Press R for Rock," ); text( "Press R for Rock, P for Paper or" + " S for Scissors", 0, 0, w, 120); } void getPlayersChoice() { if (key == 'R' || key == 'P' || key == 'S' || key == 'r' || key == 'p' || key == 's') { playersChoice = key; // when the player's choice is lowercase, // change it to the corresponding uppercase // switch (playersChoice) { case 'r': playersChoice = 'R'; break; case 'p': playersChoice = 'P'; break; case 's': playersChoice = 'S'; break; } } } void getComputersChoice() { computersChoice = char(int(random(1,4))); switch (computersChoice) { case 1: computersChoice = 'R'; break; case 2: computersChoice = 'P'; break; default: computersChoice = 'S'; } } //This is where I began..=( void displayTheComputersAndPlayersChoices() { background(255,0,0); R = loadImage("Rock.jpg"); image(R,50,50, 20, 20); //P = loadImage("Paper.jpg"); //image(P,50,50); //S = loadImage("Scissors.jpg"); //image(S,50,50); } void displayTheWinningChoice() { } // Permits draw to execute the // application steps once // void keyReleased() { keyStruck = false; }