Am I allowed to ask the professor questions after failing multiple times on my own?

I am currently reading this post. Already I feel my understanding of the language round out a bit. I will respond. Enjoy the time off from me haha! (And thank you, again for all the time you spent into this)

1 Like

Let me know if you have an questions or want any other examples, and/or when you want to look at the security code feature in your game together.

Hmm, okay, so…

Ignoring lines 1-3 for now, I’m to understand it is directly connected to the program Unity. If I was using VisualBasic or I guess even Console, they’d be titled differently. (I think)

Line 5 is a class (you call it cookie cutter, MSDN calls it struct?, I think I understand it as the object that needs describing, my blank canvas so to speak)

My object in this case is what we made in Unity called the TextController. When I hit play in Unity it will ask “Where is TextController?” and then the C# script will be loaded, which is the code all in the curly braces of TextController.MB {*}

Because I only have experience with text based(and your car example) it still feels a little abstract, but its okay, lets just keep going with this for now.

Lines 7 is a field, that is publicly available (meaning its accessible all the time to the program/user?), and is of the variable type Text(green) henceforth known as text(white), whenever (later in my code) use the word text.text it will be calling upon this part of the code?

Lines 10 and 11, while I have not even begun to research how to add images every screen, I imagine it to be in the same vein of text.text “*”, where at each state i can call upon a certain image or sprite (that I will have to upload to my assets folder in Unity?)

public Sprite sprites;

The in Sprites is throwing me off. Does a list go inside in a similar fashion as the private enum classes? (An explanation of this i don’t think is necessary, I don’t want to get more confused at this point, I would like to tackle this after, unless its unwise, which is why i mention it at all) (maybe unrelated- I keep reading Strings and Arguments are in , perhaps this is something, but I am doing what i can to stay focused on baby steps)

Line 13 is a list. The list is of the type States(green), and they are like the library of the various states the user can enter depending on state function and user input. (I feel this is the most easily understood part of the programming in C# for me.)
(enum just short hand for enumerated, or listed)

private enum States {Insert list here, items separated with commas};

Line 21 is also listing a class (which will be held private… you say “which means nothing outside of this class will be able to access/see them.”… the Class States(green) which is labeled/described as myState(white) cannot be accessed by anything outside of the class myState.

on Line 24

void Start(){
text.text = “A game about getting out.\n\n\n” +
“Press X to begin.”;

if 	(Input.GetKeyDown (KeyCode.X))		{myState = States.cell_0;}

}

I have void Start (){}, which denotes that when my program starts (when I hit play in Unity)

void is a keyword that means the program returns nothing. I understand the concept of giving the user nothing, but then later on the states and various text will say void myState(){}(whichever state is currently on screen) and so my confusion starts, if the program is to return to the user with no information(void), how is it that we are describing these states in the void with information that will be shown on screen? Currently I am just accepting it as law, something I may not understand but that I must follow.

The start, as I understand, is where the code begins to start the game. It will take all the information we listed and wrote in and compile it in the proper order and spit out the correct info based on user input. When the Game starts it calls for input at the start and then runs the update function.

On Line 25 I use text.text to call upon the previously described class of Text in the TextController (I really hope I’m close to understanding this correctly) and then it will print on the screen the string of words I put in the parenthesis “A game about getting out.\n\n\n + Press X to begin”. HERE is where logically my brain tells me "Well, its the beginning of the game, if the user wants to start they have to press X. And what better way to show this than with an if function. So I put the function (like I did when detailing the states below), my code builds successfully and i try in Unity. I don’t need to tell you it didn’t work, because I realize that the Start() function is only ran once, at the very beginning. And for some reason** it won’t accept any input, so I attempted to put it in the very beginning of the Update() function, and voila!, X starts you off in cell_0!- mini victory! except not at all, because I realize that EVERY frame the game will see what the user inputs, so if X is pressed, regardless of what frame(state), it will always put the user back to the beginning. This is an excellent way for my to drive my player insane, never being able to reach the end without pressing x, even if accidental.

The update(), every frame will print (myState)(white), so it will show me, on screen in print/text, whatever text is associated with the States(green) corresponding to the private enum States(green) and the functions I attach to them (such an an if, else if, else, or I suppose even switch? (which is another function, I think, that allows multiple outcomes based on user input?) (again, this point is probably too complicated for me to grasp just yet, So far I feel like I have learned a great deal, but am still jumbling terms. I will continue reading and rereading your post until it makes more sense.

I will continue from here after I understand this much of it. lol.

http://pastebin.com/tkub28JR (the current paste if you want/need to see the rest of it thus far.)

Hey @mnemonicon,

If you are looking to get help or advice from a fellow student - then give me a yell. Like if you have some code that you want someone to look over then I am more than willing to try and help. And I’m very good at finding bugs :grinning:. Unlike @Rob though I am not a code jockey. But two heads are better than one. Like, for instance, in the last game Number Wizard UI - I managed to put in a Input field where the user could type in a number. It took some reading on Forums and re-reading the Unity docs a number of times to get it functioning but it did work in the end - you type the right number in a certain number of guesses, hit the submit button it goes to the “Win” Screen.

I’m always adding things to the stock project and feel like I can’t submit something if I don’t think have a feature that I think is necessary. For instance, in the Block Breaker game I added a powerup which gives you the ability to shoot blocks. But I can’t submit it because I think it’s absolutely necessary for me to have the ability to spawn enemies like the original did and I want to have the multiple balls thing like the original until then I won’t consider it finished. And so moved on to Laser Defender.

So, feel free to hit me up.

Regards,
Vaughan.

1 Like

Hey @Vaughan_MacEgan Thank you for checking in on me. Please, be my guest, feel free to read the history of my learning process. My latest post is I am up to.

Thank you!
mne

Also: I just stumbled upon this. http://scottlilly.com/learn-c-by-building-a-simple-rpg-index/lesson-01-1-defining-classes-and-objects-for-the-game/ and so far it isn’t super confusing. I am now using this in conjunction with what Rob explained to me. Lego bricks in my brain are starting to click together a little.

2 Likes

One thing that would help the community greatly to help you @mnemonicon is if you could review this lecture: https://www.udemy.com/unitycourse/learn/v4/t/lecture/3463876 and share your projects on GitHub.

That allows us to download your entire code and see the errors for ourselves, which makes assisting you much easier than doing forensics on snippets that are posted on the forum.

Controlling your projects with Git is a fundamental of software development, and it’s well worth learning. My 11 year old is in the habit now of using Git for every line of code he writes, and it’s a very useful habit.

2 Likes

I made an account, I started a new repository and at that point it became so much new information that I’m starting to feel overwhelmed. I do need the help, learning a new system and program to share in this some what complex way… I thought pastes from pastebin were good to use? If I need to use github to be able to get help then I prob have a whiles to go. (also I have not reached that lecture in the class yet. I have not started block breaker. I really want to get this text adventure down, before I start anything new.) I wish I had the same smarts as your 11 year old then, lol. Anyway, no more BSing, I have to get back to understanding all this explanations and examples.

Thank you for the suggestion, I am sure I’ll be able to make use of it in the future.

1 Like

Fair enough, I know the learning curve is very steep.

There is a good step by step guide here https://unity3d.com/learn/tutorials/topics/cloud-build/creating-your-first-source-control-repository which uses BitBucket rather than GitHub, but it’s effectively the same.

2 Likes

Just downloaded github for mac, rather than read up on classes and functions, I can fully say I have confused myself stupid lol. I can always retry tomorrow.

Always trying,
mne

1 Like

Keep at it mate, one day it will just click.

1 Like

Just downloaded github for mac,[…] I can fully say I have confused myself stupid lol.

The way you phrased that made me chuckle, but I remember using Git for the first time and that soon wiped the smile from my face :slight_smile: I came from a background with a different source control system. What I did find useful however was this course on Udemy;

…it’s free, and the instructor was quick to answer my questions which was really appreciated. He does a range of different Git courses but this was enough to get me started with the basics and be up and running in a day. It focuses mainly on using the command line for typing in everything, I took one look at that and figured someone would have made a client! :slight_smile: I currently use GitKraken, which is incredibly aesthetically pleasing and also offers a free version for non-commercial users. It is available on multiple platforms including Mac;

rather than read up on classes and functions

tut tut! :wink:

I can always retry tomorrow. Always trying,

That’s the spirit… plenty of time and loads of help available.

Out of curiosity, where are you with wanting to have a go at that security code input at the moment? I’ve not lost sight of your request for some help with it but was pretty much waiting for you to come back to me after me Tolkien-esq post on classes/methods :slight_smile:

1 Like

Hey Rob,
Without getting into a very long personal story, my work schedule is literally insanity. I could have no work for weeks, then have weeks of work in two-three days, which would wipe me out for the remainder of the week. When I say I’m reading, i mean like when i have some moments of being awake, I come to GameDev.tv and read your post (over and over) as well as google/search terms and examples. I literally cannot wait to get started on the security code- But if I still haven’t figured out how to get X to start my program (and not just reset the game every time X is pressed) then I think I am still missing enough of the core concept of coding that I couldn’t possibly understand the security code part. I will check into these free tutrotials for Git at some point this weekend.

By what I can see, it appears Git sites are like a team-based Acrobat Reader for code? Where you can post your file, and there is always a master, but can be edited (if allowed) and then commented on. Still very hazy, but that’ll clear up with, I’m sure, with these online classes.

1 Like

Hi,

Absolutely no problem at all, I’m here as and when, I just didn’t want you to think I had forgotten about it, that was all. So there’s no pressure, just give me a shout when you’re ready.

Git is a source control system, Github is a service which provides online repositories, e.g. the place where you store you source code. Each time you make changes to your code locally you can commit those changes and Git keeps a record, so, if you try some new functionality out but it goes horribly wrong (we’ve all done it!), you can get back to a previous revision, in fact, any revision which you have previously committed.

Additionally, you can enable these services to be either private or public, GitHub offers a free service for public repositories, so when it comes to something that is challenging and you want to get some help, you can point people to your repository where they can then download a copy of what you have, this is invariably a lot easier if the problem is a complex one than having little fragments of code provided on the forum, or screenshots etc (although that typically works fine for more straight forward issues).

Hope this is of use and I will look forward to hearing from you in due course. Hope the work situation settles a bit and provides a bit more balance for you :slight_smile:

1 Like

Hey, i know This may be confusing because im pulling from a different thread, but it IS related to my long list of "wha?"
So on:

When you say

Parameters: from I think MSDN

In C#, arguments can be passed to parameters either by value or by reference. Passing by reference enables function members, methods, properties, indexers, operators, and constructors to change the value of the parameters and have that change persist in the calling environment.Jul 20, 2015

Does this mean that anything in the () when added/adjusted/used is a variable, something that can alter the DoSomething method?

Such as DoSomething(TypeThisMessage){}?


But originally my question was with void, You say,

So the only string I understand is the text.text string, and only because I know that strings go inside quotes. I can imagine the multitude of other strings to be used, but that isn’t in my knowledge base for now.

If I am to use a string, the program would return the string to the user? (whatever i put in the quotes?)
But if I had used void then nothing would be returned to the user?

What is IT, and where is IT returning WHAT to?

Feel free to make some jokes, even I can see how comical this is becoming haha. (Abbot and Costello anyone?)

Parameters can be used for passing information in / out of a method, I would suggest in most cases where I have used them it’s normally inbound.

Here’s a little example you can pop into a scene really easily…

void Start()
{
    string message = "Hello from the console!";

    DisplayMessageToConsole(message);
}

private void DisplayMessageToConsole(string message) 
{
    Debug.Log(message);
}

So, nice and simple this one. In your Start() method you have created a variable to hold a value, in this case its a string and it will hold a message that we want to display to the console.

We have a method DisplayMessageToConsole() which we can use for just this purpose. As you can see it has a parameter of Type string, I have named this parameter message but it could be called anything (keep them relevant to what they are though is a good idea).

This method just makes a call to Debug.Log() to display the text, in fact, Debug.Log() is doing exactly what our DisplayMessageToConsole() method is doing, it too is just taking in a parameter.

So, when you have this working, change some bits. Change the value of the variable in the Start() method to say something else. You will see that you don’t need to change your DisplayMessageToConsole() method at all and you can have different text appearing.

You could do the same for other data types also, int, float etc…

Regarding void, void is a type as well, but when used with a method it states that nothing will be returned. Again, an example;

private void HelloWorld() 
{
    Debug.Log("Hello World!");
}

The above method is referred to as a void because it doesn’t return anything to the statement that may have called it, you may have used this in the Start() method for example like this;

void Start() 
{
    HelloWorld();
}

Another example of a method that does return something could be this;

private int Add(int firstNumber, int secondNumber)
{
    int total = firstNumber + secondNumber;

    return total;
}

This time instead of void we have stated the method will return an int, the method in this case takes two numbers and adds them together, returning the total. We can use this from our Start() method like this;

void Start()
{
    int total = 0;

    total = Add(2,2);

    Debug.Log(total);
}

So in this case, we define a variable total and set it to equal zero. Then, we say that it equals the result of the Add() method. I passed in two numbers (2 and 2), the method adds them together and returns the result. I then output this using Debug.Log() - equally, if you still have the DisplayMessageToConsole() you could pass this is by saying;

void Start()
{
    string message = "My total is : ";

    message += Add(2,2).ToString();

    DisplayMessageToConsole(message);
}

The only thing I’ve added is a ToString() to the end of our Add() method, so that it converts the result, which was an int to a string before concatenating it to our message variable.

Hope this helps and the best way to really see what this is doing is to paste the above in step by step into a script in a basic scene and give it a go :slight_smile:

1 Like

Hey @ninjachimp
So I finally had some time to play with GitHub… still very confusing but I think I managed to get a bit of the basics down… maybe.

So, I made a Repository folder on my computer, then created a Repository in GitHub.com(+ 1 Readme file), I added TextController.cs file and the Game.Unity file(in case it was needed). Then cloned/copied the repo, and after youtubing a few videos, learned to use the terminal to add my repo clone to my computer (the video explained how using the GUI apps is frowned upon at companies- and not that I think I’ll be able to get a job coding anytime soon- I figure to try it this way (It was fun, reminded me of the Commodore 64 and DOS days) and get practice in the field in case an opportunity should arise.

I opened the GitHub Desktop app (since now I was sort of lost at what to do next) then opened the repo on GH.com

I wanted to practice with the program, so I tried making very slight changes to test out if what I did worked, and I found it to be half and half:

I edited the ReadMe file on the website- then did a pull request (unsure why, but after hitting many brick walls, this seemed to be the only loose brick lol) I finally saw a change on the github app and then decided to merge on the website. (unsure if what I’m doing is good or not, it was better than just staring at a screen that would not change- so I feel progress Was made.)

I saw these changes being listed on the GH app- but I feel I am still fuzzy on GH’s purpose. Is it JUST for updating and sharing files/projects? Im not meant to do any editing at all with the GH app - just to view branches (when I fully understand that concept)?

So anyway, after merging the branch into the master, I was confused as to why my files on my computer havent changed, then I realized that the initial cloning was prior to the editing readme file. I would have to download the zip file (or re-clone?) the way I did with terminal- but I feel that would give me overwrite errors (so I assume that is a no-no).

So now that I have my first repository, does this mean, now, that if i have any issues- I just upload/update the file associated with the repo in github and sync it with the desktop app?

This is the area that I have lost complete control of whats going on.

(I wish i had other quiestions, but this was all I could accomplish in the meantime.)

Thanks again, in advance, still working out the switches and the sort but I figured I can’t get help easier until I figure out github.

-mne

The basic flow with git is:

  • Before you start work, PULL the latest code from the remote down to your local repo
  • do your work locally
  • COMMIT your changes to your local repo
  • PUSH the changes from your local repo to the remote

It gets complicated with branches, pull requests, merging etc but for a one-man team, the above is all you need initially. You shouldn’t need to open the GitHub website once you’re set up - it is possible to edit files directly there, but the idea is that you can work locally, pushing your work to the remote at GitHub when you’re ready.

I would definitely use the GUI clients at first to help you get a grasp on the concepts. There is some elitism about command line, and in many cases it is more efficient than GUIs, but there’s absolutely nothing wrong with using the clients to simplify things for yourself and visualise how everything is set up.

For a single developer, Git is useful for:

  • backing up (source code is hard to replace if lost)
  • tracking old versions of code, so that you can revisit previous versions or wind back something
  • easily sharing your project with others
  • trying out new things in a branch, without affecting your master code stream
  • tying commits to specific bugs or features, for forensic debugging

It’s hard to codify all of the benefits that Git brings, but take it from someone with 18+ years of software development, it will save you someday.

Cool, so from here, if I am working with the most up to date version of the code, I do my work- save my work- then through the desktop app I would commit the changes (I guess in this case the new .cs file?)- then use the push option in the menu and it will sort of give me check points in my work process. Did I understand that correctly?

Correct. Here’s an example, the repository for my game Freezo Run. You can see all of the files that were added (the + symbol) or changed (the … symbol) in the latest commit, and how the commits have stacked on top of each other.

You can also see that when I was trying out integrating stomt with my project, I did that in a branch. Without Git I would have had to back out all those changes, and my code would have been broken until I did. With Git, I simply left the bad code on the 004_Stomt branch and continued on with my working code in the master - and the Stomt branch is there if I need it later.

1 Like

Privacy & Terms