We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › need help wiyh my assignment I WANT TO LEARN!!!
Page Index Toggle Pages: 1
need help wiyh my assignment I WANT TO LEARN!!! (Read 867 times)
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;
}





Re: need help wiyh my assignment I WANT TO LEARN!!!
Reply #1 - May 9th, 2010, 10:12pm
 
Your request is as precise as your subject line...
General advice in Processing: do your loadImage in setup() once and for all.
And you should indicate where you are stuck. Error message? Logic error? No error but some other task to accomplish?
Describing the issue is half of the way of understanding it, so half of the way of solving it...
Page Index Toggle Pages: 1