C. Program Description for Developers

Hangman

This particular rendition of hangman involved a handful of MATLAB functions and variables.

Variables

  • “wordList_hard” and “wordList_easy” are used to store words.
  • Variable “start” is used to determine if the user what to play the game or not.
  • “level” is used to let the user choose how difficult he/she wants the game to be.
  • “targetWord” is the word player needs to guess.
  • “guessWord” is the modified word that shows the word player has guessed so far.
  • “guessTime” is used to store how many times the player has entered a wrong guess.
  • “guess” is the letter player guesses, and used to be determined whether it is in the “targetWord” or not.
  • “logic” is used to determine whether the player enters a valid input.
  • “logic2” is an int variable that is used to determine whether the character player guessed is included in “targetWord” or not.
  • “guessLeft” shows how many times left can play guess wrong.

MATLAB commands:

  • “clc”: clears the command window.
  •  “clear”: clears all the variables.
  • “fprintf”: prints statements and interact with users.
  • “input”: gets inputs from users.
  • “numel()”: gets the number of elements in an array.
  • “randi()”: generates a random number from 1-number of elements in the array.
  • “length()”: shows how many letters in one word.
  • “strcmp”: compares two strings, if the first one is included in the second then return 1. Otherwise, return 0.
  • “sum”: gets the sum.
  • “break”: breaks out of a loop.
  • “imshow”: shows some png pictures that tell the stage the player at in the game.
  • In addition, loop commands, such as “while”, “for” and conditional statements like “if”, “elseif” are used to make computer determine which line of code to run next.

The only outside source used in the making of this game is the png pictures.

Connect Four

Variables

  • my_scene: initializes the scene or the sprites.
  • empty_sprite: holds the empty sprite.
  • black_sprite: holds the black disc sprite.
  • red_Sprite: hold the red  disc sprite.
  • y: a vector that holds the values of coordinates
  • row: x value of the coordinate
  • row: y value of the coordinate
  • vertCount: holds the vertically like colored discs
  • horizCount: holds the horizontally like colored discs
  • diagRightCount: holds the right diagonally like colored discs
  • diagLeftCount: holds the left diagonally like colored discs