Presentation is loading. Please wait.

Presentation is loading. Please wait.

GAME 1024: Advanced Game Programming Lesson 1: The Beginning By Kain Shin.

Similar presentations


Presentation on theme: "GAME 1024: Advanced Game Programming Lesson 1: The Beginning By Kain Shin."— Presentation transcript:

1 GAME 1024: Advanced Game Programming Lesson 1: The Beginning By Kain Shin

2 Quiz 1. What’s your full name, and why are you here? 2. Write down your email address that I can add to a mailing list for this class 3. Write a class declaration that has one member variable and one member function. Name it anything you want. 4. Write a function that takes an int and returns the factorial of that int. Hint: Factorial(n) = (n)*(n-1)*(n-2)*(n-3)…(1)

3 Class Format, Syllabus, and Expectations  If the class is too hard, I’ll make it easier, but you still have to know C++ by this point  The Class Project is on your syllabus  “Be a Good Programmer First, the Game Part Will Follow”  Take good notes – I’m saving you money by not making you buy a book  I’m always flexible and open to your input  I’ll answer questions via email if I don’t know the answer in class

4 Be Mindful of What Code Looks Like In Assembly o Copy vs. Reference o Branches (virtual functions, too) o Loop Unrolling o Minimize the use of strcmp, stricmp, etc. o Big O notation

5 Writing team-friendly code  Comments/pragma message  Asserts/Debug Messages  Style Conventions  Kain likes “m_” as a prefix for class variables  Kain likes “c” as a prefix for class names  Kain likes “v” as a prefix for virtual function names  Kain really hates K&R Bracing; Kain likes braces that live on their own lines  Kain likes a prefix that indicates pointer(p) or reference® on variables.

6 Watch out for common gotchas  Can’t trust floats and doubles to be exact, so don’t do things like test for exactly 0.0 or test for exactly -1.0  Initialize your variables  Protect against human nature  Put constants to the left of == tests  const correctness is your friend  K.I.S.S. (Avoid Unnecessary Complexity)

7 Minimize the use of globals  No way to control the order of global static variable initialization (they only promise to initialize before entering ‘main’)  Kain likes one global or static singleton of the cGame class that owns a bunch of public member variables for each game system (graphics, sound, input, etc.)

8 Avoiding Anti-patterns o The Blob Class o Gold Plating Your Code, which leads to the lava flow pattern o Consider Composition (HasA) relationship instead of Inheritance (IsA) when applicable

9 Prefer a hashed ID instead of enumerations o What is a hashed ID? o How do you use it? o Use it in conjunction with a map o Great for finite state machines o When does it make sense? o When you have a variable list of defined things that have a one-to-one correlation to a class object o When you want a strong separation between engine code and gameside code that uses engine classes. o RTTI

10 Hacking Can Only Take You So Far… o Prefer a finite state machine over switch statements where it makes sense, like for an animation controller o Use an Event system instead of calling on classes that have no business being #included in that cpp file o Plan your code to be maintainable and readable by other people o Don’t re-invent the wheel, become a researcher of algorithms

11 Last but not least… o Form your own opinions about coding philosophy, but always keep an open mind (STL, smart pointers, PC versus Mac versus Linux, DirectX versus OpenGL, etc.) Don’t just blindly follow without doing your own research and being aware of your own special needs.


Download ppt "GAME 1024: Advanced Game Programming Lesson 1: The Beginning By Kain Shin."

Similar presentations


Ads by Google