Published using Google Docs
2.5 - Hunger, Rock or Tic
Updated automatically every 5 minutes

2.5 Farm, Rock or Tic?  Advanced Boolean Logic Game

Structured Programming 2

This is the first assignment where you need will start to differentiate yourself based on how well you understand boolean logic.

You have 3 Options:

Least Difficult - Yes/No Game

If you do not feel you are ready for being creative with advanced boolean logic yet, you are to create a Yes/No game based on the Farm Animals example from within class.  This example code is also provided at the end of this document.

Medium difficulty - Rock, Paper, Scissors

Before beginning you must already have a strong idea of how you would use advanced boolean logic to compare the choices (where one player chooses rock and another chooses scissors,

scissors vs paper, etc).

Most difficult Logic - Tic-Tac-Toe

Logically, this is not much more difficult but you are given little help on what to do.


Basic Logic - The Yes/No Game

Structured Programming 2

Your goal of this assignment is to demonstrate:

In class, we completed an example of a 20 Questions type game based on Farm Animals. Your job is to create a similar game based on a famous movie, book or game series. For example, it could be about Marvel Characters

Text Version - 80%

  1. Using fonts of your choice, print the title and instructions. Within those instructions

2. Ask the user a series of yes/no questions.

3. Identify the user’s choice when all the questions are asked.  It should say something like: “You picked a pot belly pig.”

(60/80 for all of the above working but only for 5-10 characters.)

4. Give an error message if the computer can not identify the answer based on the user’s answers.

Final 20% - Adding Pictures

This is not exceptionally hard but is time consuming.

 

Your goal is to show a picture in step 3 when your program identifies the choice.


Advanced Logic (Medium Difficulty) - Rock, Paper, Scissors Game

Structured Programming 2

Your goal of this assignment is to demonstrate:

Create a keyPress based rock paper scissors game.  This can be 2 players or 1 player. (One player is one of the extra challenges.)

Save your file as RPS_TwoPlayer

Basic 2 Player Game (80%)

Introduce the game and give the instructions

Display pictures on the screen for each of your choices.

Ask player 1 to choose from their keys (such as a for rock, b for paper, etc.) and store that value into a variable.  You must also print the choice and/or show the choice visually.

Ask player 2 to choose from different keys (such as r for rock, p for paper, etc.) and store that value into a variable.You must also print the choice and/or show the choice visually.

After they have made their choices, use the key or mouse to trigger a ‘Check Winner’ feature

Final 20%

Choose any 2 of the following additions.  Each are worth 10%.  Read all before beginning.

Advanced Logic - Tic-Tac-Toe game

To Begin

Save a picture of an X and a picture of an O then load them into different PImage variables

Draw a board.

Part 1 - 60%

When the mouse is pressed for the first time, draw an X approximately centred on the mouse.

When the mouse is pressed for the second time, draw an O.

Continue flipping the draw.

Do not allow more than 9 clicks. (after 9 nothing happens).  You can assume the players will only click on open squares.  

Part 2 - 80%

The Xs and Os must be centered within the grid.  In other words, the user should be able to click anywhere within the box and the X/O is properly placed, not centred on where it is clicked.

Part 3 - 100%

Setup 9 variables for the 9 spots on the board.

As the two players click, set the proper variable to x or y.

Set up a series of IF statements to see who wins

Still too easy?  Add the option to make your move OR erase an opponent's move instead.

Still too easy?  When someone wins, have a small picture of Usain Bolt (or Mr. Couprie) walk across the board, leaving a line behind him (to mark the winning 3 moves).


Hunger Games Example Code

//This game will work for Katniss, Prim, Peeta, Hamich, Snow

boolean isFemale = false;

boolean fought = false;

boolean isAlcoholic = false;

int questNum = 1;

void setup() {

  size(700, 700);

  background(0);

  textSize(24);

  text("Welcome to the 2017 Hunger Games Game", 50, 50);

  textSize(16);

  text("Think of one of the following characters and I will try to guess it.", 50, 95);

  text("Katniss, Prim, Peeta, Hamich, Snow", 70, 115);

  textSize(20);

  question1();

}//end setup

void draw() {

  //background(0);

}//end draw

void keyPressed() {

  if (questNum == 1 && key == 'y' ) {

    isFemale = true;

    question2();

  } else if ( questNum == 1  && key=='n'   ) {

    question2();

  } else if (questNum ==2 && key == 'y' ) {

    fought = true;

    question3();

  } else if (questNum ==2 && key == 'n') {

    question3();

  }

 

  else if (questNum ==3 && key == 'y' ) {

    isAlcoholic = true;

    solvePuzzle();

  } else if (questNum ==3 && key == 'n') {

    solvePuzzle();

  }

 

}//end keyPressed

void question1() {

  questNum = 1;

  fill(0);

  rect(0, 180, 700, 200);

  fill(255);

  text("Is your character female? (y or n)", 50, 200);

}

void question2() {

  questNum = 2;

  fill(0);

  rect(0, 130, 700, 200);

  fill(255);

  text("Did he/she fight in the hunger games? (y or n)", 50, 200);

}

void question3() {

  questNum = 3;

  fill(0);

  rect(0, 130, 700, 200);

  fill(255);

  text("Is he/she an alcoholic? (y or n)", 50, 200);

}

void solvePuzzle(){

  fill(0);

  rect(0, 130, 700, 200);

  fill(255);

 

  if (  isFemale  &&  fought  && !isAlcoholic ) {

    text("Katniss is your character.  I win!", 50, 200);

  }

  else if (  isFemale && !fought && !isAlcoholic  ){

    text("Prim is your character.  I win!", 50, 200);

  }

  else if  (  !isFemale && fought && !isAlcoholic  ){

    text("Peeta is your character.  I win!", 50, 200);

  }

  else if  (  !isFemale && fought && isAlcoholic  ){

    text("Hamich is your character.  I win!", 50, 200);

  }

  else if  (  !isFemale && !fought && !isAlcoholic  ){

    text("President Snow is your character.  I win!", 50, 200);

  }

  else {

    text("I do not know who you are.", 50, 200);

  }

 

 

}//end solvePuzzle