Women in Game Programming Professor Ira Fay Class 3
Overview Mining Part 2 Programming Concepts Rachelle Davis Unity Demo
Learn a Name Stand up Learn the name of someone you don’t know Sit down
Mining – Part 2 How did it go? Walkthroughs? GitHub?
Mining – Part 2 Creating a GameObject and attaching a script Time.time Update() loop
Growth Mindset Reminder With a growth mindset, we can improve our skills through practicing. Learning happens over time, not instantly. The process of learning is uncomfortable when we’re not competent yet.
Math vs. Programming Math and programming look similar, but aren’t the same
Programming Lines of code are executed in order = is an assignment operator Programming is typo-intolerant You have to say the magic words exactly right for the spell to work!
Variables Variables hold information Variables can change value while the program is executing Example int myRoll;
Methods Methods are like a factory: Example They take input, and spit out results Example Random.Range(1,7);
Three Useful commands += // if ()
Useful commands: += totalScore = 0; myRoll = Random.Range(1, 7); totalScore = totalScore + myRoll;
Useful commands: += totalScore = 0; myRoll = Random.Range(1, 7); totalScore += myRoll;
Useful commands: // // Player starts with a score of 0 totalScore = 0; // Roll 1d6 myRoll = Random.Range(1, 7); // Add the roll to the score totalScore += myRoll; That’s what comments look like. Not executed by the computer. Mostly a note to your future self, and other programmers.
Useful commands: // totalScore = 0; // Random.Range excludes the max number when // given ints, so this returns a number 1-6 myRoll = Random.Range(1, 7); totalScore += myRoll; Ideally, your code should be self-documenting. Pick variable names and method names that are clear, so you don’t need comments. totalScore = 0 is obvious. Add comments where there’s a tricky bit of code that’s not as obvious.
Useful commands: if() totalScore = 0; // Random.Range excludes the max # for ints myRoll = Random.Range(1, 7); if (myRoll > 4) { totalScore += myRoll; } Indent anything within the if() statement. Don’t forget the starting and ending {}. When typing it, put the { } in the code, then fill in the middle.
Useful commands: if() > means greater than < means less than >= means greater than or equal to <= means less than or equal to == means equal != means not equal && means AND || means OR Remember that = is an assignment operator!
Variables Variables hold information Variables can change value while the program is executing
Unity Demo Create an empty game object, rename it Add a script to it Print Time.time Do something at 3 seconds. Change 3 seconds to a variable name. ActionTimer Do something every 3 seconds. How? Create a second variable. TimeToAct Create a BronzeCube prefab. Organize my files.
Rachelle Davis 1:45pm Now! Come prepared with 1 question Skype rachelle.m.davis
Josie Nutter Wednesday! Come prepared with 1 question Google Hangout: josienutter@gmail.com
Game Jam! Who went? How was it?
Useful commands: for() How could I display the numbers 1 to 9?
Useful commands: for() How could I display the numbers 1 to 9? print (“1”); print (“2”); print (“3”); print (“4”); print (“5”); print (“6”); print (“7”); print (“8”); print (“9”);
Useful commands: for() How could I display the numbers 1 to 99? 1 to 999?
Useful commands: for() // Count from 1 to 9 for (int i = 1; i < 10; i += 1) { print (i); } // We could also use a while() loop int i = 1; while (i < 10) { i += 1;
Useful commands: for() // Count from 1 to 99 for (int i = 1; i < 100; i += 1) { print (i); } // We could also use a while() loop int i = 1; while (i < 100) { i += 1;
Useful commands: for() // Count from 1 to 999 for (int i = 1; i < 1000; i += 1) { print (i); } // We could also use a while() loop int i = 1; while (i < 1000) { i += 1;
Crafting Life Isaiah + team made a game over the summer! http://stout.hampshire.edu/~ibm13/CraftingLife