Inheritance STL. Entity Component Systems. Scene Graphs. Event Systems

Similar documents
QUIZ. Write the following for the class Bar: Default constructor Constructor Copy-constructor Overloaded assignment oper. Is a destructor needed?

CS201 - Introduction to Programming Glossary By

Intro to OOP Visibility/protection levels and constructors Friend, convert constructor, destructor Operator overloading a<=b a.

Short Notes of CS201

SDC Design patterns GoF

Cpt S 122 Data Structures. Course Review Midterm Exam # 2

MaanavaN.Com CS1203 OBJECT ORIENTED PROGRAMMING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Object Oriented Paradigm

C++ (Non for C Programmer) (BT307) 40 Hours

And Even More and More C++ Fundamentals of Computer Science

C++ Programming Basics III

CLASSES AND OBJECTS IN JAVA

(12-1) OOP: Polymorphism in C++ D & D Chapter 12. Instructor - Andrew S. O Fallon CptS 122 (April 3, 2019) Washington State University

ECE 3574: Dynamic Polymorphism using Inheritance

Object oriented programming. Encapsulation. Polymorphism. Inheritance OOP

Data Structures (list, dictionary, tuples, sets, strings)

C++ Inheritance and Encapsulation

CS250 Intro to CS II. Spring CS250 - Intro to CS II 1

Object Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia

Inheritance. OOP components. Another Example. Is a Vs Has a. Virtual Destructor rule. Virtual Functions 4/13/2017

CS304 Object Oriented Programming Final Term

Lecture 5: Inheritance

CHAPTER 1 Introduction to Computers and Programming CHAPTER 2 Introduction to C++ ( Hexadecimal 0xF4 and Octal literals 031) cout Object

And Even More and More C++ Fundamentals of Computer Science

Software Design COSC 4353/6353 D R. R A J S I N G H

The Strategy Pattern Design Principle: Design Principle: Design Principle:

Programming, numerics and optimization

Chapter 11. Categories of languages that support OOP: 1. OOP support is added to an existing language

C++ for System Developers with Design Pattern

CPS 506 Comparative Programming Languages. Programming Language

Overview of OOP. Dr. Zhang COSC 1436 Summer, /18/2017

Written by John Bell for CS 342, Spring 2018

Subclass Gist Example: Chess Super Keyword Shadowing Overriding Why? L10 - Polymorphism and Abstract Classes The Four Principles of Object Oriented

Object-Oriented Programming

Microsoft Visual C# Step by Step. John Sharp

C++ Programming: Polymorphism

Lecture Notes on Programming Languages

Objects Managing a Resource

CMSC 132: Object-Oriented Programming II

MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #2 Examination 12:30 noon, Thursday, March 15, 2012


CS304- Object Oriented Programming LATEST SOLVED MCQS FROM FINALTERM PAPERS. MC

Chapter 3.3 Programming Fundamentals. Languages Paradigms Basic Data Types Data Structures OO in Game Design Component Systems Design Patterns

An Introduction to C++

CS24 Week 3 Lecture 1

EPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 6: Design Patterns

Software Architecture With ColdFusion: Design Patterns and Beyond Topics Outline Prepared by Simon Horwith for CFUnderground 6

SERIOUS ABOUT SOFTWARE. Qt Core features. Timo Strömmer, May 26,

Lecture 6. COMP1006/1406 (the OOP course) Summer M. Jason Hinek Carleton University

C++ Important Questions with Answers

Advanced Object Oriented PHP

C++ Object-Oriented Programming

Advanced C++ Programming Workshop (With C++11, C++14, C++17) & Design Patterns

Magento Technical Guidelines

C++ Crash Kurs. Polymorphism. Dr. Dennis Pfisterer Institut für Telematik, Universität zu Lübeck

C++ Coding Standards. 101 Rules, Guidelines, and Best Practices. Herb Sutter Andrei Alexandrescu. Boston. 'Y.'YAddison-Wesley

Paytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value

CS11 Introduction to C++ Fall Lecture 7

M.C.A DEGREE EXAMINATION,NOVEMBER/DECEMBER 2010 Second Semester MC 9222-OBJECT ORIENTED PROGRAMMING (Regulation 2009)

Inheritance. COMP Week 12

Object-Oriented Programming

EL2310 Scientific Programming

StackVsHeap SPL/2010 SPL/20

OBJECT ORIENTED DATA STRUCTURE & ALGORITHMS

Microsoft. Microsoft Visual C# Step by Step. John Sharp

CS11 Advanced C++ Fall Lecture 7

CPSC 427: Object-Oriented Programming

OOPS Viva Questions. Object is termed as an instance of a class, and it has its own state, behavior and identity.

Polymorphism. Zimmer CSCI 330

CMSC 132: Object-Oriented Programming II

CSE 12, Week Six, Lecture Two Discussion: Getting started on hw7 & hw8

Lecture 13: more class, C++ memory management

OOPs Concepts. 1. Data Hiding 2. Encapsulation 3. Abstraction 4. Is-A Relationship 5. Method Signature 6. Polymorphism 7. Constructors 8.

Association, Aggregation and Composition. Software Engineering CITS1220

CS342: Software Design. November 21, 2017

C10: Garbage Collection and Constructors

PASCAL - OBJECT ORIENTED

POLYMORPHISM 2 PART. Shared Interface. Discussions. Abstract Base Classes. Abstract Base Classes and Pure Virtual Methods EXAMPLE

More on Inheritance. Interfaces & Abstract Classes

POLYMORPHISM 2 PART Abstract Classes Static and Dynamic Casting Common Programming Errors

CMSC202 Computer Science II for Majors

Project. C++: Smart Pointers. The Plan. Announcement. Memory Leak. Pointer Ownership. Today: STL 1 Wednesday: STL 2 Thursday: Smart Pointers

EL2310 Scientific Programming

Lecture 14: more class, C++ streams

Inheritance, Polymorphism and the Object Memory Model

CPSC 427: Object-Oriented Programming

Produced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar

Midterm 2. 7] Explain in your own words the concept of a handle class and how it s implemented in C++: What s wrong with this answer?

JAYARAM COLLEGE OF ENGINEERING AND TECHNOLOGY Pagalavadi, Tiruchirappalli (An approved by AICTE and Affiliated to Anna University)

Data Structure. Recitation III

Part VIII. More classes. Philip Blakely (LSC) C++ Introduction 226 / 370

Casting -Allows a narrowing assignment by asking the Java compiler to "trust us"

CSE 12 Abstract Syntax Trees

Socket attaches to a Ratchet. 2) Bridge Decouple an abstraction from its implementation so that the two can vary independently.

Programmazione. Prof. Marco Bertini

Why use inheritance? The most important slide of the lecture. Programming in C++ Reasons for Inheritance (revision) Inheritance in C++

CMSC 202 Section 010x Spring Justin Martineau, Tuesday 11:30am

An Introduction to Patterns

10. Abstract Data Types

Object Oriented Paradigm

Transcription:

Inheritance STL Entity Component Systems Scene Graphs Event Systems

Event Systems Motivation: Decoupling events from where they are sent and where they are processed. It facilitates communication between game systems. Observer or Command which do not decouple senders and receivers in time. Event or Message: Something that has happened or something needs to be done. ex) Keypress, Entity Death, etc... Event Queue You game will receive events from external code sporadically. You ll want to process input events at your own pace so each new event will be put into a FIFO queue. Game systems can subscribe to and receive events from the queue. But can also be done using an event channel object. Synchronous vs Asynchronous Event Handling Synchronous: Events are processed immediately. This is sometimes good for user input which controls the character. Because slight delays in input are very noticeable and detract from the game play experience. Behavior can get out of step with the reset of the game. Leading to the game waiting while processing the events and causing stuttering. Asynchronous: Important Problem your event handling must not assume the game is in the same state as when the event was posted as the FIFO nature of the queue means that many things can happen before the event is actually processed. Your events will probably include a lot more data than events in synchronous systems as they need to track this extra state information. Be careful about cycles in event handling. As a rule: avoid sending events from code that is handling events. Singlecast vs Broadcast

Inheritance C++ What is a derived class? Use class derivation list to specify the base class Derived classes can have different levels of Access Control. By Default it is private. Public Public members of the base class become public members of the derived class. Protected members of the base class become protected members of the derived class. Private members of the base class are not accessible Protected Public and protected members of the base class become protected members of the derived class. Private members of the base class are not accessible Private Public and protected members of the base class become private members of the derived class. Virtual Functions (Polymorphic Functions) A function that declares or inherits a virtual function Virtual keyword allows for references to a derived types base class to still use derived types method definitions. To use dynamic_cast, base and derived classes must be polymorphic. Virtual allows the function used to be determined at runtime based on the type of the object "Object Slicing" is where you assign an object of a derived class to an instance of a base class, thereby losing part of the information - some of it is "sliced" away. Pure Virtual Functions (Abstract Class) Pure Virtual Functions defer providing a definition to base classes. These cannot be instantiated. Guarantees base classes have to provide a definition.

Virtual Destructors Virtual destructors are useful when you can delete an instance of a derived class through a pointer to base class. Avoiding memory leaks! Rule of Three The rule of three is a rule of thumb in C++ that claims that if a class defines one (or more) of the following it should probably explicitly define all three: Destructor Must be called explicitly if using variables declared on the heap. Called automatically when out of scope if variable is declared on the stack. copy constructor constructor that takes a reference to another instance of it s type copy assignment operator operator= function that takes exactly one parameter of type T. Assigning your own avoid shallow copies and invalidating pointers.

Entity Component Systems What is an Entity? Something tied to a concept or noun, has related data and logic? Player, Bullet, Car Generally you should prefer composition over inheritance OOP Inheritance Simple to implement Least Flexible Becomes a Blob anti pattern: huge single class with a large amount of complex interwoven functionality. OOP Composition Entity is an aggregate of components. Components store data and have logic. Easy and Flexible Cache Unfriendly Create entities through factory methods DOD composition Entity is an aggregate of components. Components are strictly data. Cache Friendly Hard to implement Most Flexible Systems handle logic Mimics relational database

Scene Graphs It is a data structure that contains the logical and spatial aspects of your scene s graphics. It s usually a tree or graph structure composed of nodes. Effects (colour changes, etc) on a parent are applied to the children and propagate further. Commonly useful for transformations, they allow for grouping of many objects into a compound one. Each node usually represents entities or objects in the scene. In this course you can probably get away with a simple linked-list structure. Just use PhysX