Share your annotations here!

Include your annotated slides here as an attachment. Let’s celebrate the progress we are making to understand programming.

Please watch this thread and help check other people’s annotations and give feedback.

1 Like

Here are my annotations, please let me know if I am missing some. Thanks! :slight_smile:

Great stuff. Can you identify any expressions too?

Hi @sampattuzzi, thank you. I missed the expressions and I am reattaching the file with them labeled. Please let me know if this is correct.

Question: Is numberOfSteps++; also an expression?

Feedback: @ 7’50" in the video, in the challenge slide, you should mention that we need to identify the expressions. Just in case forgetful students like myself neglect to do so :grin:

Thank you!

1 Like

Yes it is. Infact many statements are also expressions as long as they return a value. Input.GetKeyDown(KeyCode.DownArrow) is as well. But I would expect you to label them all as there is far too many.

Hi @sampattuzzi, thank you for confirming and clarifying!

Here is my hack job of annotating and Flow Arrows

1 Like

Hi here is my attempt at the annotations, Thank.

Great work. I would try and be a little more clear on the execution flow because it doesn’t always flow exactly as the arrow does.

Thanks Samuel, I will look at the other posts to see how they tackled the execution flow.

Kind regards


1 Like

Here are my annotations. Please let me know if I’m on the right track

Nice, very pretty :slight_smile:

I found this concept harder to grasp until I realised that the variable you need to create depends on the data you need to work with and I was hung up trying to use a float command instead of the Keycode command.

I think I have it now and with practice I should get it locked in.

This is my attempt at Annoting the program.

I have not used the arrows as I understand the flow ok, but I can add them.

Great annotations!

Sorry I did it on my iPad

I put most of my stuff in comments and just numbered the flow. The 4-7 is kind of tricky because I think all 4 statements that call the method happen at every frame, and the decision to act is actually in the if statement in the CheckForMovement method.

Yes, that’s a hard one to draw but well done.

I tried, It is very ugly, blue is the flow and red is are the names.

Update get called every frame that why the arrow go back yo Update at the end of it.

Sorry. I did not draw arrows. I just added a lot of helpful comments.

// These two line import libraries that we will be 
// using in this class.  A library is a collection
// of methods, classes, enums, and variables.
// That have been pre-written for you, but THIS
// class in not aware of them until you import then
// with the "using" keyword.
using UnityEngine;
using System.Collections;

// This line declares our class.
// and tells us that it "decends" from MonoBehaviour. 
// The means the it can objects declared as this
// class type, will be able to do anything that
// a MonoBehaviour can do. PLUS, the extra
// method that we add with our new code.
public class SpeakInConsole : MonoBehaviour {

// global variables are declared here.
// Since the are outside of any other methods,
// The are availble to read or change in ANY
// method inside of this class.
public Vector2 location;
public Vector2 homeLocation;

// Use this for initialization
void Start() 
	print("Welcome to Go Home!");
	print("A game were you need to find you way back.");

	// the variables location and homeLocation are
	// given their initial values here.
	// I added this myself since I think it is more fun
	// for the game to start when you are NOT already
	// at home.  In a future version I(we) will probably 
	// be picking random numbers and thus setting a
	// "location" to a different place each time the 
	//  game is started.

	location = new Vector2 (0f,12f);
	homeLocation = new Vector2 (0f, 0f);

}  // end of the Start() method.  This is run only onece
   // before Update is run for the first time.

// Update is called once per frame
void Update () 
	// jump to CheckForMovement with first inputs.
	CheckForMovement(KeyCode.LeftArrow, new Vector2(-1, 0));
	// return from CheckForMovement first run.  No data is returned
	// since the return type is void.

	// jump to CheckForMovement with second inputs.
	CheckForMovement(KeyCode.RightArrow, new Vector2(1, 0));
	// return from CheckForMovement second run.  No data is returned
	// since the return type is void.

	// jump to CheckForMovement with third inputs.
	CheckForMovement(KeyCode.UpArrow, new Vector2(0, 1));
	// return from CheckForMovement thrid run.  No data is returned
	// since the return type is void.

	// jump to CheckForMovement with fourth inputs.
	CheckForMovement(KeyCode.DownArrow, new Vector2(0, -1));
	// return from CheckForMovement fourth run.  No data is returned
	// since the return type is void.

}  // end of the update method.  This method runs over and over,
   // for as long as the program is running.  Therefore,
   // the program is always listening for key presses from the user.

void CheckForMovement(KeyCode kc, Vector2 movementVector)
	if (Input.GetKeyDown(kc))
		location = location + movementVector;
		Vector2 pathToHome = homeLocation - location;
		print("Distance to home: " + pathToHome.magnitude);
		if (location == homeLocation)
			print("I am at home!");
		}  // end of nested if, which prints that you are howe.
		   // as soo as the test (location == homeLoaction
		   // becomse true.
	} // end of if statement which checks the Input Unity object for a 
	  // key press and its code.
}  // and of the  ChechForMovement method
   // which gets called and run 4 times currently, with different inputs.
   // but the same empty output.
   // important to note though.  I does have an effect on our global variable
   // location if someone is pressing an arrow key. So this is an output of
   // the function, is a sense. but no information is passed back to the
   // called function directly.
} // end of class SpeakInConsole.  The whole thing,
  // which includes all of our methods and only excludes the top
  // two import lines gets wrapped up in curly braces.
  // We often lose count of closing braces.  That's why I like 
  // to put a comment like "//end if" on all of my closing curlies.
  // The makes it as clear as HTML code, and it works in a similar
  // way.  Every opening curly brace must have a corrisponding.
  // closing curly brase, just like each HTML tag should have
  // a closing tag.

Here’s my annotation

Privacy & Terms