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

Slides:



Advertisements
Similar presentations
Objects and Classes Part II
Advertisements

Revealing the Secrets of Self-Documenting Code Svetlin Nakov Telerik Corporation For C# Developers.
C Programming lecture 2 Beautiful programs Greek algorithms
Brown Bag #3 Return of the C++. Topics  Common C++ “Gotchas”  Polymorphism  Best Practices  Useful Titbits.
C Language.
Coding Standard: General Rules 1.Always be consistent with existing code. 2.Adopt naming conventions consistent with selected framework. 3.Use the same.
Week 9: Methods 1.  We have written lots of code so far  It has all been inside of the main() method  What about a big program?  The main() method.
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 2: Your First Program.
1 Homework Turn in HW2 at start of next class. Starting Chapter 2 K&R. Read ahead. HW3 is on line. –Due: class 9, but a lot to do! –You may want to get.
Processes CSCI 444/544 Operating Systems Fall 2008.
Alice Variables Pepper. Set to Java look Edit / preferences restart.
Chapter 3.4 Programming Fundamentals. 2 Data Structures Arrays – Elements are adjacent in memory (great cache consistency) – They never grow or get reallocated.
Algorithm Programming Coding Advices Bar-Ilan University תשס " ו by Moshe Fresko.
IT PUTS THE ++ IN C++ Object Oriented Programming.
18-Aug-15 Air Force Institute of Technology Electrical and Computer Engineering Object-Oriented Programming in Java Topic : Objects and Classes (cont)
“Everything Else”. Find all substrings We’ve learned how to find the first location of a string in another string with find. What about finding all matches?
Chapter 5: Control Structures II (Repetition)
EGR 2261 Unit 5 Control Structures II: Repetition  Read Malik, Chapter 5.  Homework #5 and Lab #5 due next week.  Quiz next week.
C Programming Tutorial – Part I CS Introduction to Operating Systems.
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
CSC204 – Programming I Lecture 4 August 28, 2002.
IT253: Computer Organization Lecture 3: Memory and Bit Operations Tonga Institute of Higher Education.
Overloading Binary Operators Two ways to overload –As a member function of a class –As a friend function As member functions –General syntax Data Structures.
224 3/30/98 CSE 143 Recursion [Sections 6.1, ]
CIT 590 Intro to Programming First lecture on Java.
Advanced Computer Science Lab Coding Style & Documentation.
1 Advanced Issues on Classes Part 3 Reference variables (Tapestry pp.581, Horton 176 – 178) Const-reference variables (Horton 176 – 178) object sharing:
Chapter 11 More about classes and OOP. Relationships Between Classes Possible relationships – Access ("uses-a") – Ownership/Composition ("has-a") – Inheritance.
Chapter 4: Subprograms Functions for Problem Solving Mr. Dave Clausen La Cañada High School.
Chapters 1-5 Review C++ Class. Chapter 1 – the big picture Objects Class Inheritance Reusability Polymorphism and Overloading.
Introduction to C#. Why C#? Develop on the Following Platforms ASP.NET Native Windows Windows 8 / 8.1 Windows Phone WPF Android (Xamarin) iOS (Xamarin)
GAM 200 Club. How to Game Engine GAM 200 Club Zachary Nawar.
More C++ Features True object initialisation
CSCI-383 Object-Oriented Programming & Design Lecture 10.
Homework due Test the random number generator Create a 1D array of n ints Fill the array with random numbers between 0 and 100 Compute and report the average.
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
1 Homework Done the reading? –K&R –Glass Chapters 1 and 2 Applied for cs240? (If not, keep at it!) Gotten a UNIX account? (If not, keep at it!)
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Today: –Review declaration, implementation, simple class structure. –Add an exception class and show.
By Mr. Muhammad Pervez Akhtar
CSE 332: C++ pointers, arrays, and references Overview of Pointers and References Often need to refer to another object –Without making a copy of the object.
Singleton Pattern. Problem Want to ensure a single instance of a class, shared by all uses throughout a program Context Need to address initialization.
Chapter 7 Constructors and Other Tools Copyright © 2010 Pearson Addison-Wesley. All rights reserved.
M1G Introduction to Programming 2 2. Creating Classes: Game and Player.
CIS 338: VB Variables Dr. Ralph D. Westfall April, 2011.
Announcements Assignment 2 Out Today Quiz today - so I need to shut up at 4:25 1.
FUNCTIONS (C) KHAERONI, M.SI. OBJECTIVE After this topic, students will be able to understand basic concept of user defined function in C++ to declare.
LECTURE 22: BIG-OH COMPLEXITY CSC 212 – Data Structures.
CS 115 Lecture 5 Math library; building a project Taken from notes by Dr. Neil Moore.
CSE 332: C++ Exceptions Motivation for C++ Exceptions Void Number:: operator/= (const double denom) { if (denom == 0.0) { // what to do here? } m_value.
BIL 104E Introduction to Scientific and Engineering Computing Lecture 4.
CC410: System Programming
Copyright © Jim Fawcett Spring 2017
Code Optimization.
User-Written Functions
CS 215 Final Review Ismail abumuhfouz Fall 2014.
Motivation and Overview
Andy Wang Object Oriented Programming in C++ COP 3330
C Programming Tutorial – Part I
CSE 143 Introduction to C++ [Appendix B] 4/11/98.
Templates.
Problem Solving (design of programs) CS140: Introduction to Computing 1 8/26/13.
Static Members Sharing is caring….
We’re moving on to more recap from other programming languages
Seating “chart” Front Back 4 rows 5 rows 5 rows 4 rows 2 rows 2 rows
COP 3330 Object-oriented Programming in C++
Hans Zaunere, Managing Member
CSCE-221 C++ Coding Standard/Guidelines
Class rational part2.
Presentation transcript:

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

Quiz 1. What’s your full name, and why are you here? 2. Write down your 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)

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 if I don’t know the answer in class

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

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.

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)

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.)

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

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

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

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.