Contents
1 Introduction
1.1 Notes
1.2 Computer Languages, Books and Teaching
1.3 Pedagogy
1.4 Legal-ish
2 First program and printing
2.1 Hooking up a simple program
2.2 Statements, print
2.3 Intro to computer math
2.4 More writing program details
2.5 Errors, Syntax errors
2.6 Adding more programs
2.7 more math
3 Variables, computer math
3.1 Math with types
3.2 Variables, declarations, simple assignment
3.3 Identifiers
3.4 Simple assignment, var use
3.5 More assign and variable rules and examples:
3.6 Declare/assign shortcuts
3.7 Semi-useful variable and assign examples
3.8 More error messages
3.9 Doubles vs. floats
4 Input, more output, testing
4.1 Input
4.2 Using Update to make more interesting programs
4.3 declare = shortcut and Inspector vars
4.4 Replacing constants with variables
4.5 Math shortcuts
4.6 Fun 3D stuff
4.7 more cute cube tricks
4.8 Errors, funny stuff
5 Using a 3D environment
5.1 Making a small room
5.2 Color, Textures
5.3 Adjusting the Camera
6 If statements
6.1 Comparison Operators
6.2 Some semi-useful ifs
6.3 Compare precedence
6.4 else
6.5 And, Or
6.6 Nested ifs
6.7 Common errors
7 more if tricks
7.1 falling through
7.2 Swapping
7.3 Incremental calculations
7.4 Tricks with modulo
7.5 Mixed and/or
7.6 Switch Statements
8 Unity if examples
8.1 bouncing
8.2 Counting
8.3 Delay counter
8.4 State variables
9 Scope and Namespaces
9.1 Scope
9.2 Namespaces
10 More ifs and randomness
10.1 Random rolls
10.2 Random Positions
10.3 More things to randomize
10.4 Coin flips, percents, random tables
11 Functions, part I
11.1 Intro Function examples
11.2 Function rules
11.3 More function examples
11.4 functions with more math
11.5 Common Errors
11.6 Style
11.7 Chains of functions
12 Functions, part II - parameters
12.1 Parameters
12.2 Rules
12.3 More rule-showing examples
12.4 Fun errors
12.5 Multiple Inputs
13 Casting
13.1 casting
13.2 char type
14 Functions, part III - return
14.1 Introduction
14.2 return values
14.3 Using value-returning functions
14.4 More math functions
15 Constants and enums
15.1 Constants
15.2 enumerated types
15.3 More enumerated types
16 Overloading and default parms
16.1 Introduction
16.2 Default parameters
16.3 overloading
16.4 Style
17 booleans
17.1 Bool rules
17.2 Common bool tricks
17.3 Testing tricks
18 Function examples
18.1 Introduction
18.2 Change me type functions
18.3 Dice functions
18.4 More style; types of functions
18.5 Moving curve examples
18.6 Reading keys
18.7 Making a real function library
18.8 Unity built-ins
19 Structs
19.1 Cow struct example
19.2 Common errors
19.3 rules
19.4 Builtin structs: Color, Vector3
19.5 Constructors, struct literals
19.6 Nested structs
19.7 Structs as function inputs
19.8 Structs as return values
19.9 Uninitialized structs
20 Struct examples
20.1 More Vector3, Color code
20.2 More built-in functions
20.3 Transform struct
20.4 Rigidbodies
21 Float problems
21.1 The Problem
21.2 Solutions
21.3 < vs <= in float compares
22 Loops
22.1 Special infinite loop warning
22.2 Number-sequence loops
22.3 While loop rules
22.4 Do it 10 times loops
22.5 Loops with floats
22.6 Go until done loops
22.7 More oddball loops
22.8 Infinite/broken loops
22.9 Move and count loops
22.10 Digit tricks
22.11 Fencepost errors
22.12 for loops
22.13 Count plus formula loops
22.14 do-while loop
23 Index Loops
23.1 Indexes
23.2 Variables as indexes
23.3 String Loop examples
23.4 Odd string loops
24 Pointers
24.1 First walk-through
24.2 Terms and Theory
24.3 Common pointer/class use
24.4 Functions and pointers
24.5 null
24.6 Errors
24.7 Pointer compare (==)
24.8 Garbage Collection
24.9 Struct new’s
24.10 Old-style pointers
25 Pointers in Unity
25.1 Instantiate
25.2 New’ing Inspector variables
26 Pointer examples
26.1 Text change
26.2 More time, and APIs
26.3 Three platforms
26.4 More prefab use
26.5 Multiple scripts
27 Using indexed lists
27.1 Intro
27.2 Creating Lists
27.3 More playing with indexes
27.4 List loop examples
27.5 Random item
27.6 Two list tricks
27.7 Size 0 and 1 lists
27.8 Functions with lists
27.9 errors
27.10 Assign shortcut
27.11 Lists variables as pointers
28 Nested loops
28.1 As a grid
28.2 Pattern in pattern
28.3 Wedge exercises
28.4 break, continue
28.5 List nested loops
29 Struct in struct
29.1 Lists of structs
29.2 Structs with Lists in them
29.3 Lists of strings tricks
29.4 2D lists
29.5 Larger structures
29.6 Giant game board example
29.7 List of indexes
29.8 Internal list pointers
30 Member functions
30.1 Example and motivation
30.2 More simple examples
30.3 Using your own member functions
30.4 Built-in member functions
30.5 this
30.6 Constructors
30.7 Scope
30.8 Style: member vs. non-member
30.9 Special struct in script rule
31 Access modifiers
31.1 How private variables work
31.2 Classes as new types
31.3 Interface/Implementation idea
32 Scripts as Classes
32.1 How scripts really work
32.2 Pointers to classes in Unity
33 Nested classes, static
33.1 Nested enum’s, classes and public
33.2 Static / namespaces
34 Reference parms
34.1 ref rules
34.2 Output parameters
34.3 mixing real return and ref parms
34.4 Pointers and References
34.5 Raycast example
34.6 Reference vs. reference?
35 Arrays
35.1 Array rules
35.2 shortcuts
35.3 Arrays and functions
35.4 Max size / real size tricks
35.5 List / array conversion
35.6 OverlapSphere Unity example
35.7 2D arrays
36 Efficiency
36.1 Most speed-ups don’t work
36.2 Premature Optimization
36.3 Not all code sections are equal
36.4 Is it already fast enough?
36.5 Will it cause more errors?
36.6 Things that work
37 Debugging
37.1 Test as you go
37.2 How/what to test
37.3 Tracking down bugs
[next]