2-D Game Engine Construction (CU CPSC6160)
2D游戏引擎设计这门课程是我在CU的2018 Fall选修的一门专业核心课程,老师是Clemson CS系比较受欢迎的 Brian Malloy教授。
课程内容
Week1
Aug 28, Tue:
- Office hour: Wed 10-11:30 AM
- Quiz on Tue or Thu
- Answer Ques about Basics or Classes:
- ternery operator
- namespaces
- if (0)
- Do the Rule of 3
本周的重点内容是C++的基本语法以及Classes的使用
和 C++ Rule of 3
的规则应用。在这里分别整理了两个部分的博客文章:
Aug 30, Thu:
- refs vs ptrs
- r-value references
- Introduce SDL draw functions
- Review Rule of 3 – how to reproduce no crash?
- Illustrate the functions that are called: whatcalls
- Trace the Rule of 3 example from cppreference
- Rule of 0
- Introduce vectors:
- size vs capacity
- push_back vs emplace_back
Week2
Sep 4, Tue
- Review what get’s called:
- why prefer init vs assign
- Introduce vectors:
- size vs capacity
- value semantics
- emplace_back
- Marcus Painting
- Project #2
- Quiz #1 review
Week3
Sep 11, Tue:
- Review the quiz
- Why no vector.push_front() ???
- When to use emplace_back()?
- A temp is always an r-value reference
- review Rule of 3, Rule of 0, Rule of 5
Sep 13, Thu:
- Your game: can definitely be a “cover”
- Keep the scope manageable – one level, etc.
- Terminology:
- move assignment vs copy assignment
- copy constructor vs move constructor
- Questions about move semantics
- ranged for loops:
- ints: size vs cap
- C++ strings
- why no push_front for vector?
- Drawing a texture: GPU
- Makefile
- Drawing a Surface: CPU
Week4
Sep 18, Tue:
- static variables
- Design Patterns
- The Singleton Design Pattern
- Animations with SDL:
- cpu clock vs game clock
- Why clear the screen
- Inheritance:
Sep 20, Thu:
- Sammy’s dilemma
- Project #2 – let’s look at my solution.
- The Meyer’s Singleton
- Polymorphism:
- see poly example
- shapes example
- Use g++ not clang++ for effc++ warnings
- Project #3 and the tracker framework
- default vs delete for constructors/destructors
- ranged for vs while
- when to use auto
- function overload
- transparency vs alpha channel
- Parallax Scrolling
- Getting images vs “rolling your own”
- Making videos
- why use g++ vs clang++
- XML
理解为什么要使用 Singleton设计模式,已详细分析了为什么要使用singleton模式,以及Singleton设计模式的好处和如何来书写Singleton. 请参考博客:
- C++软件设计模式之Singleton 包含了两种Singleton的书写方式
Week 5
Sep 25, Tue:
- Last time: Many spinning stars – tweak velocity using XML velocity as base!
- Parallax Scrolling is easy – it’s already in the code
- string streams
- making a video
Sep 27, Thu:
- Quiz #2
Week 6
Oct 2, Tue:
- maps
- sorting:
- vectors
- lists
- emplace_back: how to use?
- Why Singleton:
- Gamedata?
- Clock?
- Two-way sprites?
- SpriteSheet
- Project #2 – CANDY
Oct 4, Thu:
- Jacob Wood
- IoMod: overload writeText
- put in Engine::draw, which is const!
- Engine::update is NOT const!
- draw and update called every iteration of the event list
- Why Singleton:
- Gamedata – yes
- Clock – no!
- Clock and fps
- string streams
- Two-way sprites?
- SpriteSheet
- projects from last year
- project #4
- sorting:
- vectors
- lists
Week 7
Oct 9, Thu
- Why Singleton:
- Gamedata – yes
- Clock – no!
- Clock and fps
- string streams
- Two-way sprites?
- SpriteSheet
- A Player Class
Oct 11, Thu:
Does anyone get a black screen on startup?
Good rule to follow: pre-load assets! e.g.: collision strategies.
Reminder: Exam #1 in one week!
Modifications to ImageFactory and/or SpriteSheet???
Review:
- How to make video for #3
- Adding a Player for #4
- slide or no slide?
- how to fit player into tracker framework
- to cast or not to cast, that is the question.
- Where to put stuff in Engine.cpp
Nested Classes: the Clock class
Collisions
AI:
- observer pattern
Week 8
Oct 16, Tue:
- Erasing from a list. Vector. map
- Project #4
- Exam #1
Oct 18, Thu:
- Review Observer
- Quiz #2
- Sorting vectors and lists
Week 9
Oct 25, Thu:
- github repo
- player/composition ==> it’s composition so need player.getVelocity()
- drawable.h in tracker framework didn’t have method getSurface
- input/mouse2
- to get pixel color see getPixel
Week 10
Nov 1, Thu:
- Write a fn object
- Review lamda functions
- Show lamda in sort
- Review Explosions
- Health bar (in your repo)
- A model for your HUD!
Week 11
Nov 8, Tue:
- Review fn objects and lambda functions
- Review the two classes needed for Chunk explosions
- Review Object pool
Quiz 3
- Sort
- Funciton object
- lambda Funciton
- Search in a list, vector, map
- Erasing from a list. Vector, map
- observer pattern
- static_cast Vs dynamic_cast
自己动手写游戏引擎
- 概述
- 设计使用C++画出来图形
- 做一个Object移动的模式