Game Programming - Course Introduction

Game Programming

Design Patterns in Unity 🎮

CSCI 3213 - Game Programming

Welcome to the world of professional game development!

Meet Your Instructor

Professor Bobby Reed

🎮 A Lifetime of Game Development

The Journey:

  • Early Days: Started making games as a kid with Clickteam's Klik & Play
  • Evolution: Progressed through Games Factory, PowerPoint games (yes, really!)
  • High School: Dove into Flash (when it was still Macromedia Flash)
  • Professional Career: 6 years at OU as "the VR guy"
    • Released 25 VR apps for research and educational augmentation

At Oklahoma City University

I handle all web, game, and software engineering curriculum for both graduate and undergraduate students.

Philosophy: Games have been my passion since childhood. This class is about sharing that passion and helping you build the skills to create professional-quality games!

Icebreaker: What Makes a Game?

Getting to Know Each Other Through Play

🎮 Your Turn to Share

Each student will introduce themselves by sharing:

  1. Your Name
  2. Why You Love a Game - Don't say the name! Describe what makes it compelling, fun, or meaningful to you
  3. What's Different About Video Games? - How do video games differ from board games, sports, or make-believe?
đŸ¤Ģ Important: Keep your game a SECRET! We'll try to guess what everyone was talking about on the next slide.
Think critically: What makes something a "game"? What experiences work best as video games vs. other game types?

Guessing Game: What Were They Talking About?

Determining Research Era Selection Order

đŸŽ¯ The Challenge

Now that everyone has shared, let's see how well we listened!

How It Works:

  1. Each student gets one guess about which game someone else was describing
  2. Correct guesses earn you points
    1. Correct Genre
    2. Correct Series/Character/Lore/World
    3. Exactly Correct
  3. The student with the most correct guesses gets first pick
  4. Selection order continues by points (highest to lowest)

What Are We Selecting?

Your selection determines which era of video game history you'll research in our next activity!

Listening carefully and thinking about what makes games unique pays off!

Game Design Lesson: Good communication about game design requires precision. Practice describing mechanics, feelings, and experiences clearly!

Course Overview

This semester, you'll learn professional game development using Unity and C#

What We'll Build

  • Blade Racer - A futuristic arcade racing game
  • Implement professional design patterns
  • Build reusable, maintainable game systems
  • Create a portfolio-worthy project
Philosophy: We're not just making a game - we're learning to write professional, scalable game code.

🎨 Creative Freedom

Blade Racer is a reference implementation. You're welcome to create your own game theme, story, art style, and mechanics! The important part is implementing the design patterns - not following the Blade Racer narrative exactly.

Video Game History Timeline

Building Our Collective Knowledge

📚 10-Minute Research Activity

Each student: Select one era and become the class expert on that period!

1940s - 1960s
1970s - 1980s
1990s
2000s - 2010s
2020s

Starting Point

Begin here: museumofplay.org/video-game-history-timeline

Then explore! Follow links, search for key games, consoles, and innovations from your era.

After Research: We'll share what we learned! I'll start by sharing pre-1940 history, focusing on Nintendo's origins in playing cards and their focus on "play."

What You Should Already Know

C# Core Features

Access Modifiers

  • public and private keywords
  • protected and internal
  • Encapsulation principles

Data Types

  • Primitive types (int, float, bool, string)
  • Arrays and collections
  • Reference vs value types

OOP Concepts

  • Classes and objects
  • Inheritance (base/derived)
  • Polymorphism basics

C# Review: Access Modifiers

public class Player { // Public: Accessible everywhere public int score = 0; // Private: Only within this class private float health = 100f; // Protected: This class + children protected bool isAlive = true; // Internal: Same assembly only internal string playerId; }
Best Practice: Use private by default, expose only what's needed with public.

When to Use Each

public - Methods/properties other scripts need to access

Example: player.TakeDamage(10)

private - Internal implementation details

Example: Helper methods, internal state

protected - For inheritance hierarchies

Example: Base class methods children can override

internal - Within same project/assembly

Example: Shared utilities in your game

C# Review: Data Types

Value Types

Stored directly in memory, copied when assigned

int health = 100; float speed = 5.5f; bool isAlive = true; char grade = 'A'; // Structs are value types Vector3 position = new Vector3(0, 0, 0);

Reference Types

Store reference to memory location, share data

string name = "Player"; int[] scores = new int[5]; List<string> items = new List<string>(); // Classes are reference types GameObject player = new GameObject();

The Key Difference

// VALUE TYPE: Creates a copy int a = 10; int b = a; // b gets its own copy b = 20; // a is still 10, b is 20 // REFERENCE TYPE: Shares reference int[] listA = new int[] { 1, 2, 3 }; int[] listB = listA; // Same array! listB[0] = 999; // BOTH listA[0] and listB[0] are 999
Common Pitfall: Modifying reference types affects all references!

Game Example: If two scripts reference the same GameObject, changes in one script affect what the other sees!

C# Review: OOP & The 4 Pillars

Object-Oriented Programming Fundamentals

1. Encapsulation

Bundle data and methods together, hide internal details

public class HealthSystem { private float _health = 100f; // Hidden public void TakeDamage(float damage) { // Controlled access _health -= damage; if (_health < 0) _health = 0; } }
2. Inheritance

Child classes inherit properties/methods from parent classes

public class Enemy : Character { // Enemy inherits from Character public override void Attack() { base.Attack(); // Call parent's Attack // Add enemy-specific behavior } }
3. Polymorphism

Same interface, different implementations (many forms)

Character[] characters = { new Player(), new Enemy() }; foreach (Character c in characters) { c.Attack(); // Each calls their own Attack() }
4. Abstraction

Hide complexity, show only essential features

public abstract class Weapon { public abstract void Fire(); // Must implement } public class Pistol : Weapon { public override void Fire() { /* Pistol logic */ } }

What You Will Need to Pick Up Quickly (get gud)

Unity Core Features

MonoBehaviour Scripts

  • Creating and attaching scripts
  • Component-based architecture
  • GameObject references

Unity Editor

  • Creating new scenes
  • Manipulating GameObjects
  • Inspector window usage

Event Functions

  • Awake() and Start()
  • Update() and FixedUpdate()
  • Execution order understanding

Advanced C# Features

We'll be using these advanced concepts throughout the course:

// Static members - globally accessible public static class GameManager { public static GameManager Instance; } // Events - publisher/subscriber pattern public event Action OnGameStart; // Delegates - function pointers public delegate void TimerCallback(); // Generics - type-safe reusable code public class Singleton<T> : MonoBehaviour where T : Component
Don't worry! We'll cover these in depth during our next class crash course. If you need extra help, see me during office hours.

Need a Refresher?

Official Unity Learning Resources

learn.unity.com

Recommended pathways:

  • Unity Essentials - Complete Unity interface overview
  • Junior Programmer - C# fundamentals in Unity
  • Create with Code - Hands-on programming projects
Office Hours: If you need help finding the right resources for your skill level, set up an appointment with me. I'm here to help you succeed!

Course Textbook & Attribution

📚 Primary Reference

Game Development Patterns with Unity 2021
Second Edition

By David Baron

How to Access

  • 📖 Purchase: Available from major book retailers
  • đŸ›ī¸ Library: Available at Dulaney Browne Library
  • đŸ’ģ Digital: eBook versions available
Note: All course content is adapted and heavily modified from Baron's work. His book provides the foundation for our pattern implementations, customized for the Blade Racer project.

Next Class: C# & Unity Crash Course

What We'll Cover

  • Quick review of static, events, delegates, and generics
  • Unity-specific patterns and best practices
  • Prefabs, ScriptableObjects, and Coroutines
  • Setting up your first project structure

âš ī¸ Important Note

We won't spend extensive time on basic programming concepts after this. Make sure you're comfortable with fundamental C# and Unity before Week 2!

Environment Setup

Unity Version

Required Version

Unity 6.3 (LTS)

✓ Long Term Support (LTS)

✓ Open version (non-Enterprise)

✓ Available directly in Unity Hub

How to Download

  1. Download and install Unity Hub from unity.com/download
  2. Open Unity Hub
  3. Go to the "Installs" tab
  4. Click "Install Editor" and select Unity 6.3 LTS
  5. Add platform support modules (Windows, Mac, and/or Linux)

Environment Setup

Code Editor: JetBrains Rider

Why Rider?

  • ✓ Best-in-class Unity integration - Purpose-built for Unity development
  • ✓ FREE for students - Full professional license with your OCU email
  • ✓ Advanced debugging - Built-in Unity debugger and profiler
  • ✓ Intelligent code completion - Unity API autocomplete and suggestions
  • ✓ Powerful refactoring - Rename, extract, and restructure with confidence
VS Code Alternative: While I'll be demonstrating with Rider, VS Code is also acceptable. Both will work fine for this course - choose what works best for you!

Get Your Free Rider License

Student Educational Access

Step-by-Step Instructions

  1. Visit JetBrains Student Portal:
    jetbrains.com/community/education/#students
  2. Click "Apply Now" button
  3. Choose verification method: "University email address"
  4. Enter your OCU email: yourname@my.okcu.edu
  5. Fill out application form with your student information
  6. Check your email for verification link
  7. Activate your license - Valid for 1 year, renewable annually
Important: Use your @my.okcu.edu email address. Approval is usually instant, but can take up to 24 hours.

Installing Rider

1. Download Rider

jetbrains.com/rider/download

Available for Windows, macOS, and Linux

2. Install & Launch

  • Run the installer
  • Follow default settings
  • Launch Rider when complete

3. Activate License

  • Sign in with JetBrains account
  • Your educational license activates automatically

4. Unity Integration

  • Unity plugin installs automatically
  • No additional setup needed!

Connecting Unity to Rider

Setting Rider as Default Editor

  1. Open Unity Editor
  2. Go to Edit → Preferences (Windows) or Unity → Settings (Mac)
  3. Select External Tools in left sidebar
  4. Click dropdown for External Script Editor
  5. Select Rider from the list
    • If not listed: Click "Browse" and navigate to Rider installation
    • Windows: Usually C:\Program Files\JetBrains\Rider\bin\rider64.exe
    • Mac: Usually /Applications/Rider.app
  6. Check the "Regenerate project files" checkbox if available (ensures Unity keeps IDE settings updated)
  7. Click the "Regenerate project files" button to force immediate sync
Test It: Double-click any C# script in Unity - Rider should launch automatically!

Our Project: Blade Racer

Game Overview

A futuristic arcade racing game where the player controls a turbo-charged motorcycle across an obstacle course. The race track is built on a railway system where players can steer between rails to avoid obstacles and collect power-ups.

Core Gameplay Elements

  • đŸī¸ High-speed motorcycle racing on a rail system
  • đŸŽ¯ Dodge obstacles and collect power-ups
  • ⚡ Turbo boost system with risk/reward mechanics
  • 🔧 Vehicle upgrade system
  • 🎮 Third-person camera following the action

Blade Racer: The World

Year 2097

Humanity has mastered Earth and set sights beyond the solar system. With peace and technology solving all challenges, collective boredom sets in. Enter Neo Lusk, a tech entrepreneur who invents a dangerous new sport: turbo-charged motorcycle racing through deadly obstacle courses.

Only those with nerves of steel and reflexes as sharp as a blade can master this sport.

Even arcade games benefit from narrative context - it gives meaning to gameplay and triggers player imagination!
Your Story, Your Vision: This is just the default story. Feel free to create your own world, characters, and narrative! Want a medieval cart racing game? A space pod racer? A fantasy broomstick race? Go for it! Just make sure you implement the same technical patterns.

Blade Racer: Core Systems

đŸ›¤ī¸ Rail System

Four-track navigation system with dynamic obstacle spawning

🎲 Risk System

Rewards close-call dodges with bonus points

⚡ Turbo Boost

Speed system with reduced handling trade-off

🔧 Upgrade System

Weapon attachments and vehicle modifications

Each system will be implemented using professional design patterns!

Rail-Based Games: A Gaming Legacy

From Arcade Origins to Modern Classics

🏁 The Original: Pole Position (1982)

Atari's Pole Position pioneered the racing-on-rails concept in arcades. View Arcade Cabinet

đŸī¸ Combat Racing on Rails

  • Road Rash (1991-1999) - Combat motorcycle racing series
    View Game
  • Road Redemption (2017) - Modern spiritual successor
    View on Steam

🚀 On-Rails Shooters

  • Star Fox (1993) - Space combat on rails
    View Game
  • Star Fox 64 (1997) - Refined rail shooting
    View Game

đŸŽī¸ Arcade Racing Series

  • Cruis'n USA (1994) - Arcade racing classic
    View Game
  • Cruis'n World (1996) - Global racing sequel
    View Game

đŸĻŠ 3D Platformers on Rails

  • Crash Bandicoot (1996) - Forward-scrolling platformer
    View Game
  • Sonic Adventure 2 (2001) - Speed stages on rails
    View Game
Design Note: Rail systems simplify player control while maintaining the illusion of freedom. They're perfect for fast-paced games where split-second decisions matter!

What's Flexible, What's Required?

✨ Customize These (Creative Elements)

  • Theme & Setting: Sci-fi, fantasy, modern, historical - your choice!
  • Story & Characters: Write your own narrative
  • Art Style: Low-poly, realistic, stylized, pixel art
  • Audio: Music and sound effects
  • Game Feel: Speed, difficulty, controls
  • UI Design: Colors, fonts, layout

🔧 Keep These (Technical Requirements)

  • Design Patterns: Implement all assigned patterns correctly
  • Core Systems: The technical architecture must match
  • Code Quality: Clean, documented, professional code
  • Pattern Applications: Use patterns for their intended purpose
  • Unity Best Practices: Follow Unity conventions

Example: You can make a pirate ship racing game instead of motorcycles, but you still need to implement the State pattern for ship states, the Command pattern for replay, etc.

What Are Design Patterns?

Design patterns are reusable solutions to common software development problems.

Origin Story

Architect Christopher Alexander originated the concept for building architecture. In the late 1980s, software engineers adapted these concepts to programming. The classic "Gang of Four" book Design Patterns: Elements of Reusable Object-Oriented Software became the foundation of modern software patterns.

Our Focus: Practical application in Unity game development, not academic theory!

Why Design Patterns Matter

✅ With Patterns

  • Code is reusable and modular
  • Easy to maintain and debug
  • Team communication is clearer
  • Scales to larger projects
  • Professional-quality architecture

❌ Without Patterns

  • Spaghetti code everywhere
  • Bugs multiply with changes
  • Hard to explain to others
  • Breaks at large scale
  • Difficult to extend features

Bottom line: Patterns help you write code that doesn't make you cry when you revisit it 6 months later!

Design Patterns This Semester

Foundational Patterns

📋 Core Patterns (Chapters 4-8)

  • Singleton - Game Manager implementation
  • State - Character state management
  • Event Bus - Managing game-wide events
  • Command - Replay system implementation
  • Object Pool - Performance optimization

Design Patterns This Semester

Behavioral & Structural Patterns

📋 Intermediate Patterns (Chapters 9-13)

  • Observer - Decoupling components
  • Visitor - Power-up system implementation
  • Strategy - Enemy AI behaviors
  • Decorator - Weapon system upgrades
  • Spatial Partition - Level editor optimization

Design Patterns This Semester

Alternative Patterns

📋 Alternative Patterns (Chapters 14-16)

  • Adapter - System integration and compatibility
  • Facade - Simplifying complex subsystems
  • Service Locator - Managing dependencies
Real-world Application: Each pattern will be implemented as part of the Blade Racer game system!

How This Course Works

Weekly Structure

  • Lecture: Learn a design pattern and its use case
  • Implementation: Code the pattern in Unity for Blade Racer
  • Testing: Verify the pattern works correctly
  • Iteration: Refine and integrate with other systems

Theory (30%)

Understanding the pattern's purpose and structure

Practice (70%)

Hands-on implementation in Unity/C#

Example: Singleton Pattern

// Without Singleton - messy! public class Player : MonoBehaviour { GameManager manager; // Have to find this everywhere void Start() { manager = GameObject.Find("GameManager").GetComponent<GameManager>(); } } // With Singleton - clean! public class Player : MonoBehaviour { void Start() { GameManager.Instance.StartGame(); // Direct access! } }

Result: Cleaner code, easier access, guaranteed single instance

Assessment Overview

Weekly Pattern Assignments

7 assignments (Weeks 1-7)

21% (3% each)

Blade Racer Complete

All patterns integrated (Week 8)

5%

Midterm Exam

Design patterns & Unity (Week 8)

15%

Personal Project Milestones

6 check-ins (Weeks 9-15)

35%

Final Presentation & Game

Presentation + demo (Week 16)

15%

Final Exam

Cumulative exam (Finals Week)

5%

Participation & Peer Review

Workshop attendance, feedback, playtesting

4%

Two-Phase Course: Phase 1 (Weeks 1-8) focuses on design patterns with Blade Racer. Phase 2 (Weeks 9-16) is your personal project workshop with peer support and structured milestones.

📊 How You're Graded

Grading is based on technical implementation of design patterns, not on theme. A well-coded fantasy racing game will score just as well as a well-coded Blade Racer implementation!

Before Next Class

Required Setup Tasks

  1. Install Unity 6.3 LTS via Unity Hub
  2. Apply for free JetBrains educational license (use @my.okcu.edu email)
  3. Download and install Rider
  4. Configure Unity to use Rider as external script editor
  5. Create a Unity Hub account (free)
  6. Review C# basics if needed (learn.unity.com)

Optional Preparation

  • Browse the Unity Junior Programmer pathway
  • Review delegates and events in C#
  • Explore the Unity Asset Store
  • Familiarize yourself with Rider's interface
Using VS Code instead? That's fine! Just make sure you have the C# extension installed and configured for Unity.

Course Resources

Official Links

Getting Help

  • Office Hours: Tue 12-1 PM, Wed 9-11 AM, Thu 12-1 PM, Fri 9-10 AM (SSM-204A)
  • Email: bobby.reed@okcu.edu
  • Peer Programming: Encouraged!

Gaming History Moment đŸ•šī¸

Before Video Games - Nintendo's Playing Card Origins (1889-1940s)

In 1889, Fusajiro Yamauchi founded Nintendo Koppai in Kyoto, Japan - not as a video game company, but as a playing card manufacturer. The name "Nintendo" roughly translates to "leave luck to heaven," reflecting their philosophy of creating tools for play and entertainment.

For over 80 years, Nintendo focused on hanafuda (flower cards), children's toys, and later electronic toys. They survived through dedication to quality craftsmanship and bringing joy through play - the same philosophy that would guide them when they entered video games in the 1970s and eventually saved the industry with the NES in 1985.

Connection to Game Development

Just as Nintendo started with playing cards before revolutionizing video games, you're starting this course with foundational patterns before building your complete game. Great systems are built on solid foundations - whether it's hanafuda craftsmanship or design patterns!

Learn More: Nintendo History 1889-1980 (Gaming Historian) | The Story of Nintendo (OCU Library)

Questions & Discussion đŸ’Ŧ

Open Floor

Now is the time to ask questions about:

  • Course expectations and requirements
  • Technical setup and software installation
  • Design patterns and what to expect
  • The Blade Racer project scope
  • Anything else on your mind!

Welcome Aboard! 🚀

Today's Achievements Unlocked:

Next Class: C# & Unity Crash Course

Homework: Complete environment setup (Unity + Rider + Educational License)

Get ready to build something amazing! 🎮