Translate What Instructor is Saying

“The information on the fact that we chosen level 1 is now stuck in the start game menu and if we try to get out of the start game function and do something else that information will be lost. Information can’t come into the onuserinput because the terminal doesn’t know about levels”

So this entire statement makes absolutely no sense to me. What does it mean for information to get lost? What does passing around a level mean? What does it mean for the terminal to not know about levels?

Hi Kevin,

Welcome to our community! :slight_smile:

Computers do not remember anything by default. Data gets lost immediately after code has been executed. The only way for us to keep data for a longer time is to assign it, for example, to a variable.

level is a variable. When we assign 1 to level, level will always have the value 1. The name itself does not have any further meaning for a computer, there is no concept for “levels”, thus our terminal cannot know anything about levels.

We need to make the level variable accessible for the OnUserInput method so the method can read the data assigned to level. That’s what Ben does in this lecture.

Does that make sense?

I have no idea what this data even is and what lost even means (like does it go missing and I have to find it, does it disappear into a black hole and there’s no way of getting it back?). Its a silly metaphor but the concept of ‘lost’ is completely different to a person who understands the coding language and to the person who doesn’t.

Its like when he says “the terminal doesn’t know levels so its our job to keep track of levels.” What does ‘keeping track’ even mean? Am I keeping track of the term or am I defining it for the console to understand? I’m assuming the key to understanding the coding logic is by understanding the language and if that’s the case then good lord I’m in trouble.

Imagine you go to an important convention and meet lots of important people who are interested in your upcoming game. You want to stay in contact, so they tell you their name and their e-mail address. And you tell them your name and your e-mail address. A name and an e-mail address are data.

Does that make sense so far?

If so, how do you remember these data? Can you learn everything by heart within seconds or do you need something that helps you remember, e.g. a notebook? Where does the data go when you forget something?

What about the people you met? How can they remember your name, let alone your e-mail address?

When you come home, does your best friend know about all the interesting people you met? Or do you have to tell him about them first?

The computer is not that different from you. The only difference is that it is not creative, it cannot remember anything, cannot interpret anything, cannot invent anything, and it needs strict, unambiguous instructions. Coding is nothing than providing clear instructions in a programming language.

The logic behind those instructions is independent from a specific programming language. In fact, you could even program without a computer. Train a bunch of chickens to do things in a specific order, and you have a program.

Do you know these Japanese devices in their gardens that are supposed to frighten away animals? I’m sure you can express the algorithm/logic/concept behind it in a few simple sentences: If X, then Y. If Y, then X. If you can do that, you are a programmer and have all the relevant skills to write code. It might be that you don’t know any programming language yet or do not know how to express your thoughts in a sequence of simple instructions but that’s something you can learn.


Back to the initial problem. You want to remember the important people because you want to show them your upcoming game. And you want them to remember you.

Imagine you had a business card with all the relevant information about you. You give it to people, and people give you theirs. Now all you have to do is to remember that you got business cards and where you put them. If you keep all your business cards in one place, you can keep track of the data. You can count how many people you met. You have their data right there. If you are messy, cards could get lost, and it is likely that you forget the names and/or e-mail addresses on the lost cards.

When you want to write an e-mail to all important people you met, all you have to do is to grab your stack of business cards and use the relevant data on them.

Since everybody can have a business card and since you could replace data on a card, you can regard the business card itself as a variable. A variable is a container for data.

In C#, you could express this concept of business cards like this:

BusinessCard myBusinessCard = new BusinessCard(
    "Kevin",
    "Indie Game Developer",
    "email@address.com"
);

BusinessCard companyCard = new BusinessCard(
    "John Doe",
    "Important person in big company",
    "john.doe@bigcompany.com"
);

BusinessCard instructorCard = new BusinessCard(
    "Ben Tristem",
    "Instructor in the Unity 3D course",
    "some@test-test.com"
);

As long as the data is assigned to myBusinessCard, and as long as the variable myBusinessCard exists, you can pass this package of data/information on to other methods and objects within your program. The computer can the data from myBusinessCard. Or from companyCard.

Did this clear it up for you a bit?

It only makes sense in the vein of how business cards operate in real life but it doesn’t help me understand the logic of how the instructor makes the ‘level’ term be available the way that he does (as well as the majority of lessons that’s been taught up to this point but that’s an entirely different problem). I just don’t know how to translate what he’s doing in a language that makes sense to me.

If you regard the business cards as a rather abstract concept, as a container for information/data, you could apply this concept to other things, too. And you could change or extend it as you need it.

Are you in lecture “Member Variables To Hold State” (currently #21)?

If so, let’s recapitulate our game idea: The user selects a level. Then they are supposed to enter a password. Our programm shall compare the user input to the password of the current level. The player wins if the password is correct. Or they lose if it is wrong. Depending on the result (won or lost), we want to display a message.

This is our state at the beginning of the lecture #21: The user input gets fetched in the OnUserInput method. The player is supposed to press 1 for the local library, or 2 for the police stations. These two options are our “levels”.

Is this clear so far?

If so, here is the problem Ben wants to solve in this lecture: After the user pressed 1 or 2, we want something specific happen in our StartGame method. The task is supposed to depend on the user input, thus we somehow need to pass on the local data from the OnUserInput method to the StartGame method.

Local means that nothing else but the current code block, here: OnUserInput, knows about the data. When the OnUserInput method was executed, the user input is lost because we do not store it anywhere. There is no history of what the user typed. The user input is there for a brief moment only. If the computer remembered everything, it would be out of memory within a few seconds.

How can we pass on the data in this brief moment to StartGame?

Is the problem clear?

If so, on to Ben’s solution: At around the 2:20, Ben passes on an integer to the StartGame method like this: StartGame(1);. Now the StartGame method can do something with the passed on 1. And if we pass on 2, the StartGame method could do something with the passed on 2. And so on.

Is Ben’s approach clear?

If so, on to the next problem: What if the player selects level 1 first and types a password next time? Both times, the program gets a string via OnUserInput. The computer does not have any concept of “level” or “password”. A string is a sequence of characters, nothing else. How can the computer remember the current level?

Solution: We store the 1 and 2 respectively in a variable, e.g. in level.

Variables at the top of your class persist during the lifetime of the current object/instance. Here: Until you stop your game. This means that other methods within the same object/instance can access the variable at the top of your class. These variables are also called instance member. Their respective value persist during runtime until something overrides their respective value.

This way, our program can keep track of the current level.

Haven’t responded in a while because I’m still trying to make sense of what you wrote. Needless to say I’m doing pretty **** poor trying to learn abstract ideas with the lack of abstract thought.

You do have abstract thoughts, and you are able to process abstract throughts.

Proof: What is “the internet”?

We all have an abstract concept of what “the internet” is without knowing what “the internet” actually is. Or can you point a finger to “the internet”?

Yet you use the term “internet”, and people understand you because they have a similar idea of what “the internet” is for them (and for you), and they have similar expectations as you.


Programming is concrete. You do something. You provide commands: Do X, do Y. If the variable is A, do B.

An idea, a game idea, a concept are abstract.


Maybe you could “forget” Rick’s solution and what I said for a moment. Think about how you would solve the problem I mentioned in my previous answer.

Just in case: A summary of the game idea

The user selects a level. Then they are supposed to enter a password. Our programm shall compare the user input to the password of the current level. The player wins if the password is correct. Or they lose if it is wrong. Depending on the result (won or lost), we want to display a message.

Ignore Unity and C# for a moment. Just think about a logical concept. How would this work if you didn’t have a computer but people who are supposed to make this work? How would you instruct them? What are their tasks?

Once you have a concept, make a diagram of it. When you did that, try to express the diagram in pseudo-code. Then compare your pseudo-code to Rick’s code. Alternatively, if you don’t have pseudo-code, just read Rick’s code again and try to figure out if something in his script matches your concept.

How are you getting on with this, @Kevin_Cheng? Do my walls of text make a bit more sense now? Or did you find a better explanation?

I’m still deciphering what has been said in this thread.

Have you tried to phrase the problem and your ideas for a solution in your own words?

This topic was automatically closed after 43 hours. New replies are no longer allowed.

Privacy & Terms