2D Game Development: From Zero To Hero: A compendium of the community knowledge on game design and development

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Author(s): Daniele Penazzo
Edition: Pseudocode
Year: 2022

Language: English
Pages: 407

Foreword
Introduction
Why another game development book?
Conventions used in this book
Logic Conventions
Code Listings
Block Quotes
Boxes
Engine Used
Structure of this Book
The Maths Behind Game Development
Some useful symbols
The modulo operator
Vectors
Adding and Subtracting Vectors
Scaling Vectors
Dot Product
Vector Length and Normalization
“Clamping” a Vector
Geometry
Convex vs Concave polygons
Self-intersecting polygons
Straight Lines and their equations
Getting the equation of a straight line, given two points
Getting the equation, given the slope and a point
Projections
Projecting arbitrary lines on the axes
Matrices
What is a matrix
Matrix sum and subtraction
Multiplication by a scalar
Transposition
Multiplication between matrices
Other uses for matrices
Trigonometry
Radians vs Degrees
Sine, Cosine and Tangent
Pythagorean Trigonometric Identity
Reflections
Shifts
Trigonometric Addition and subtraction
Double-Angle Formulae
Inverse Formulas
Numerical Analysis
Newton-Raphson method
Coordinate Systems on computers
Transformation Matrices
Stretching
Rotation
Choosing the direction of the rotation
Rotating referred to an arbitrary point
Shearing
Some Computer Science Fundamentals
Recursion
Computers are (not) precise
Catastrophic cancellation
Random Numbers are not really random
De Morgan’s Laws and Conditional Expressions
Estimating the complexity of algorithms
O(1)
O(log(n))
O(n)
O(n·log(n))
O(n2)
O(2n)
A primer on calculating the order of your algorithms
Some basics
What happens when we have more than one big-O?
What do we do with recursive algorithms?
How do big-O estimates compare to each other?
Simplifying your conditionals with Karnaugh Maps
“Don’t care”s
A more complex map
Guided Exercise
Object Oriented Programming
Introduction
Objects
Abstraction and Interfaces
Inheritance and Polymorphism
Mixins
The Diamond Problem
Composition
Coupling
The DRY Principle
SOLID Principles
“Composition over Inheritance” design
Designing entities as data
Reading UML diagrams
Use Case Diagrams
Actors
Use Cases
Notes
Sub-Use Cases
Class Diagrams
Classes
Interfaces
Relationships between entities of the class diagram
Notes
Activity Diagrams
Start and End Nodes
Actions
Decisions (Conditionals) and loops
Synchronization
Swimlanes
Signals
Notes
A note on activity diagrams
Sequence Diagrams
Lifelines
Messages
Object Instantiation and Destruction
Grouping and loops
Notes
Other diagrams
Generic Programming
Advanced Containers
Dynamic Arrays
Performance Analysis
Linked Lists
Performance Analysis
Doubly-Linked Lists
Hash Tables
Binary Search Trees (BST)
Heaps
Stacks
Queues
Circular Queues
Treating multidimensional structures like one-dimensional ones
Data Redundancy
Introduction to Multi-Tasking
Coroutines
Introduction to Multi-Threading
What is Multi-Threading
Why Multi-Threading?
Thread Safety
Race conditions
Critical Regions
Ensuring determinism
Immutable Objects
Mutex
Atomic Operations
A Game Design Dictionary
Platforms
Arcade
Console
Personal Computer
Mobile
Web
Input Devices
Mouse and Keyboard
Gamepad
Touch Screen
Dedicated Hardware
Other Input Devices
Game Genres
Shooters
Strategy
Platformer
RPG
MMO
Simulation
Rhythm Games
Visual novels
Project Management Basics and tips
The figures of game design and development
Producer/Project Manager
Game Designer
Writer
Developer
Visual Artist
Sound Artist
Tester
Some generic tips
Be careful of feature creep
On project duration
Brainstorming: the good, the bad and the ugly
On Sequels
Common Errors and Pitfalls
Losing motivation
The “Side Project” pitfall
Making a game “in isolation”
Mishandling Criticism
Misusing of the Digital Millennium Copyright Act
Not letting others test your game
Being perfectionist
Using the wrong engine
Software Life Cycle Models
Iteration versus Increment
Waterfall Model
Incremental Model
Evolutionary Model
Agile Software Development
User Stories
Scrum
Kanban
ScrumBan
Lean Development
Where to go from here
Version Control
Metrics and dashboards
SLOC
Cyclomatic Complexity
Code Coverage
Code Smells
Coding Style breaches
Depth of Inheritance
Number of methods / fields / variables
Number of parameters
Other metrics
Writing a Game Design Document
What is a Game Design Document
Possible sections of a Game Design Document
Project Description
Characters
Storyline
The theme
Progression
Levels and Environments
Gameplay
Goals
Game Mechanics
Skills
Items/Powerups
Difficulty Management and Progression
Losing Conditions
Graphic Style and Art
Sound and Music
User Interface
Game Controls
Accessibility Options
Tools
Marketing
Target Audience
Available Platforms
Monetization
Internationalization and Localization
Other/Random Ideas
Where to go from here
The Game Loop
The Input-Update-Draw Abstraction
Input
Events vs Real Time Input
Timing your loop
What is a time step
Fixed Time Steps
Variable Time Steps
Semi-fixed Time Steps
Frame Limiting
Frame Skipping/Dropping
Multithreaded Loops
Issues and possible solutions
Frame/Screen Tearing
Drawing to screen
Clearing the screen
Collision Detection and Reaction
Why Collision Detection is done in multiple passes
Narrow-Phase Collision Detection: did it really collide?
Collision Between Two Points
Collision Between A Point and a Circle
Collision Between Two Circles
Collision Between Two Axis-Aligned Rectangles (AABB)
Line/Point Collision
Line/Circle Collision
Point/Rectangle Collision
Point/Triangle Collision
Circle/Rectangle Collision
Line/Line Collision
Line/Rectangle Collision
Point/Polygon Collision
Jordan Curve Theorem
Thinking outside the box: polygon triangulation
Bounding Boxes
Point/Polygon collision detection with triangles
Circle/Polygon Collision
Line/Polygon Collision
Polygon/Polygon Collision
Non-convex polygons collision
Polygon triangulation: the return
Pixel-Perfect collision
Broad-phase collision detection: is a collision even possible?
The Brute Force Method
Building Quad Trees
Building AABB-Trees
Querying
Other Collision Detection Methods
Calculating the position of tiles
Collision Reaction/Correction
HitBoxes vs HurtBoxes
Collision Reaction Methods
A naive approach
Shallow-axis based reaction method
Interleaving single-axis movement and collision detection
The “Snapshot” Method
The “Tile + Offset” Method
When two moving items collide
Common Issues with time-stepping Collision Detection
The “Bullet Through Paper” problem
Precision Issues
One-way obstacles
Separating Axis Theorem
Why only convex polygons?
How it works
Finding the axes to analyze
Projecting the shapes into the axes and exiting the algorithm
From arbitrary axes to “x and y”
Ray Casting
What is Ray Casting?
Cameras
Screen Space vs. Game Space
Most used camera types
Static Camera
Grid Camera
Position-Tracking Camera
Horizontal-Tracking Camera
Full-Tracking Camera
Camera Trap
Look-Ahead Camera
Hybrid Approaches
Clamping your camera position
Game Design Tips
Tutorials
Do not pad tutorials
Integrate tutorials in the lore
Let the player explore the controls
Consolidating and refreshing the game mechanics
Remind the player about the mechanics they learned
Introduce new ways to use old mechanics
Rewarding the player
Reward the player for their “lateral thinking”
Reward the player for their tenacity
Reward the player for exploring
Reward the player for not immediately following the given direction
Reward the player for not trusting you entirely
Reward Backtracking (but don’t make it mandatory!)
The “lives” system
1-UPs
Loading Screens
What to put in a loading screen
Letting the player “exit” the loading screen
Avoiding a loading screen altogether
Designing the story and gameplay flow
Linear Gameplay
Branching gameplay
Parallel gameplay
Threaded gameplay
Episodic gameplay
Adding parallel paths
Some game genres and their characteristics
Roguelikes and Rogue-lites
Use of pseudo-randomness and procedural generation
Permadeath
Turn-based Gameplay
Lack of mode-based gameplay
Multiple ways to accomplish (or fail!) a task
Resource Management is key
Peace was never an option
Dealing with the unknown
Tips and Tricks
General Purpose
Make that last Health Point count
Avoiding a decision can be a decision itself
Telegraphing
Minigames
When unlockables are involved, be balanced
Shooters
Make the bullets stand out
RPGs
Grinding and farming
Leveling Curves
Perceived Fairness
You don’t need precise collision detection
Immediate dangers should be well visible
Miscellaneous
You cannot use the “Red Cross” in games
Auto-saving
Feedback is important
Creating your assets
Assumptions
Graphics
Some computer graphics basics
Color Depth
Direct Color vs. Indexed Color
Lossless Formats
Lossy Formats
Transparency
Texture Filtering
Nearest Neighbor Filtering
Bilinear Filtering
Trilinear Filtering
General Tips
Practice, Practice, Practice…
References are your friends
Don’t compare your style to others’
Study other styles
Learn to deconstruct objects into shapes
Sprite sheets
Virtual Resolution
Using limited color palettes
Dithering
Layering and graphics
Detail attracts attention
Use saturation to separate layers further
Movement is yet another distraction
Use contrast to your advantage
Find exceptions
Palette Swapping
Pixel Art
What pixel art is and what it is not
Tools
Layers
Sub-pixel animation
Normal Mapping
A simple example
Tips and Tricks
Tiles
Sprites and icons
Sounds And Music
Some audio basics
Sample Rate
Bit Depth
Lossless Formats
Lossy Formats
Clipping
Sound Synthesis
AM Synthesis
FM Synthesis
Basic Wave Forms
Sine Wave
Square Wave
Triangle Wave
Sawtooth Wave
Noise
ADSR Envelope
Attack
Decay
Sustain
Release
Digital Sound Processing (DSP)
Reverb
Pitch Shift
Filtering
Doppler Effect
FM Synthesis vs Sample-based music
Simulating older consoles’ audio
Commodore Vic20
Commodore 64
Commodore Amiga
Sega Master System / GameGear
Sega Genesis/MegaDrive
NES
SNES
AdLib / SoundBlaster
“Swappable” sound effects
Some audio processing tips
Prefer cutting over boosting
DAW Basics
What is a DAW Software?
The Piano Roll
Music Tracker Basics
What is a Music Tracker Software?
Samples
Instruments
Channels
Patterns
Basic Rhythms
Four on the floor
Four on the floor with off-beat hi-hats
Adaptive Music
Fonts
Font Categories
Serif and Sans-Serif fonts
Proportional and Monospaced fonts
Using textures to make text
Using Fonts to make text
Shaders
What are shaders
Shader Programming Languages
The GLSL Programming Language
The data types
Some GLSL Shaders examples
Design Patterns
Singleton Pattern
Command Pattern
Flyweight
Observer Pattern
Strategy
Chain of Responsibility
Component/Composite Pattern
Dependency Injection
Decorator
Visitor
Adapter
Object Adapter
Class Adapter
Prototype
Facade
Service Locator
Useful Containers and Classes
Resource Manager
Animator
Finite State Machine
Menu Stack
Particle Systems
Particles
Generators
Emitters
Updaters
Force Application
Timers
Accounting for “leftover time”
A naive solution
A different approach
Inbetweening
Bouncing
Chaining
Artificial Intelligence in Videogames
Path Finding
Representing our world
2D Grids
Path nodes
Navigation meshes
Heuristics
Manhattan Distance heuristic
Euclidean Distance heuristic
Algorithms
A simple “Wandering” Algorithm
A slightly better “Wandering” algorithm
The Greedy “Best First” Algorithm
The Dijkstra Algorithm
The A* Algorithm
Finite state machines
Decision Trees
Behaviour Trees
Other Useful Algorithms
World Generation
Midpoint Displacement Algorithm
Diamond-Square Algorithm
Maze Generation
Randomized Depth-First Search (Recursive Backtracker)
Randomized Kruskal’s Algorithm
Recursive Division Algorithm
Binary Tree Algorithm
Eller’s Algorithm
Dungeon Generation
Noise Generation
Randomized Noise (Static)
Perlin Noise
Procedural Content Generation
What is procedural generation (and what it isn’t)
Advantages and disadvantages
Advantages
Less disk space needed
Larger games can be created with less effort
Lower budgets needed
More variety and replayability
Disadvantages
Requires more powerful hardware
Less Quality Control
Worlds can feel repetitive or “lacking artistic direction”
You may generate something unusable
Story and set game events are harder to script
Where it can be used
Procedural Generation and Difficulty Management
Static difficulty
Adaptive Difficulty
Rubberbanding
Static vs. Adaptive Difficulty
Developing Game Mechanics
General Purpose
I-Frames
Scrolling Backgrounds and Parallax Scrolling
Infinitely Scrolling Backgrounds
Parallax Scrolling
Avoid interactions between different input systems
Sprite Stenciling/Masking
Loading screens
Simulating Inertia
2D Platformers
Simulating Gravity
Avoiding “Floaty Jumps”
Ladders
Walking on slanted ground
Stairs
Jump Buffering
Coyote Time
Timed Jumps
Screen Wrap
Top-view RPG-Like Games
Managing height
Rhythm Games
The world of lag
Input Lag
Video Lag
Audio Lag
Lag Tests
Synchronizing with the Music
Time domain vs. Frequency Domain
The Fast Fourier Transform
Beat Detection
“Bullet Hell” Style Games
Bullets
The Ship Hitbox
Screen-clearing bombs
Clearing bullets on pattern changes
Find other chances to clear some bullets
Turn enemy bullets into collectibles at the end of a boss fight
The “Chain Meter”
Managing the player’s death
The Enemy AI
Be fair to the player, but also to the computer
Inertia
Some examples
Match-x Games
Managing and drawing the grid
Finding and removing Matches
Why don’t we delete the matches immediately?
Replacing the removed tiles and applying gravity
Cutscenes
Videos
Scripted Cutscenes
Balancing Your Game
The “No BS” principle
Always favour the player
Economy
Supply and Demand
Money sources and sinks
Inflation
Deflation
A primer on Cheating
Information-based cheating
Mechanics-based cheating
Man-in-the-middle
How cheating influences gameplay and enjoyability
Single Player
Multiplayer
P2P
Dedicated Servers
Cheating protection
Accessibility in videogames
What accessibility is and what it is not
UI and HUD Scaling
Subtitles
Mappable Buttons
Button Toggling
Dyslexia
Text Spacing
Fonts
“Slow Mode”
Colorblind mode
No Flashing Lights
No motion blur
Reduced Motion
Assisted Gameplay
Controller Support
Some special cases
Testing your game
When to test
Testing “as an afterthought”
Test-Driven Development
The “Design to test” approach
You won’t be able to test EVERYTHING
Mocking
Types of testing
Automated Testing
Manual Testing
Unit Testing
Integration Testing
Regression Testing
Playtesting
In-House Testing
Closed Beta Testing
Open Beta Testing
A/B Testing
Profiling and Optimization
Profiling your game
Does your application really need profiling?
Does your FPS counter roam around a certain “special” value?
Is the animation of your game stuttering but the FPS counter is fine?
First investigations
Is your game using 100% of the CPU?
Is your game overloading your GPU?
Is your game eating up more and more RAM as it’s running?
Optimizing your game
Working with references vs. returning values
Optimizing Drawing
Reduce the calls to the Engine Routines
Entity Cleanup and Memory leaks
Using analyzers to detect Memory Leaks
Static Scanners
Dynamic testing tools
Resource Pools
Lookup Tables
Memoization
Approximations
Eager vs. Lazy Evaluation
Eager approach
Lazy approach
Tips and tricks
Be mindful of your “updates”
Dirty Bit
Far-Away entities (Dirty Rectangles)
Tweening is better than animating
Remove dead code
Non-Optimizations
“Switches are faster than IFs”
Blindly Applying Optimizations
Marketing your game
An Important Note: Keep your feet on the ground
The importance of being consumer-friendly
Pricing
Penetrating the market with a low price
Giving off a “premium” vibe with a higher price
The magic of “9”
Launch Prices
Bundling
Nothing beats the price of “Free” (Kinda)
Managing Hype
Downloadable Content
DLC: what to avoid
DLC: what to do
Digital Rights Management (DRM)
How DRM can break a game down the line
Free-to-Play Economies and LootBoxes
Microtransactions
The human and social consequences of Lootboxes
Free-to-Play gaming and Mobile Games
Assets and asset Flips
Crowdfunding
Communication Is Key
Do not betray your backers
Don’t be greedy
Stay on the “safe side” of planning
Keep your promises, or exceed them
A striking case: Mighty No. 9
Engagement vs Fun
Streamers and Content Creators
The game developers’ side
The Streamers’ side
Other entities and conclusions
Keeping your players engaged
Communities
Forums
Wikis
Update Previews
Speedrunning
Replayability
Modding
Fan games
Randomizing
New Game+
Transmogrification
Dissecting games: two study cases
A bad game: Hoshi wo miru hito
Introduction
Balance Issues
You can’t beat starter enemies
The Damage Sponge
Can’t run away from battles, but enemies can
Statistics
Bad design choices
You get dropped in the middle of nowhere
The starting town is invisible
The Jump Ability
Items are invisible
Item management
Buying Weapons makes you weaker
Enemy Abilities
You can soft lock yourself
Confusing Choices
Starting level for characters
Slow overworld movement
Exiting a dungeon or a town
The Health Points UI
Inconveniencing the player
The battle menu order
Every menu is a committal
Password saves
Each character has their own money stash
Bugs and glitches
Moonwalking and save warping
The final maze
The endings
Conclusions
A good game: Dark Souls
Project Ideas
Tic-Tac-Toe
Basic Level
Advanced Level
Master Level
Space Invaders
Basic Level
Advanced Level
Master level
Breakout
Basic Level
Advanced Level
Master Level
Shooter Arena
Basic Level
Advanced level
Master Level
Game Jams
Have Fun
Stay Healthy
Stick to what you know
Hacking is better than planning (But still plan ahead!)
Graphics? Sounds? Music? FOCUS!
Find creativity in limitations
Involve Your Friends!
Write a Post-Mortem (and read some too!)
Most common pitfalls in Game Jams
Where To Go From Here
Collections of different topics
Books
Videos
Multiple formats
Pixel Art
Multiple Formats
Sound Design
Multiple Formats
Game Design
Books
Game Development
Videos
References and Cheat Sheets
Glossary
A
C
D
E
G
H
I
K
L
M
O
P
R
S
U
W
Engines, Libraries And Frameworks
Game Maker Studio
GDevelop
GLFW
Godot
IRRlicht
Löve
MonoGame
Ogre3D
Panda3D
SDL
SFML
Unity 3D
Some other useful tools
Graphics
Aseprite
Blender
Gimp
Inkscape
Krita
Laighter
LibreSprite
NormalMap-Online
Piskel
Pixelorama
Shaders
SHADERed
Sounds and Music
Audacity
Bosca Ceoil
Chiptone
FamiStudio
Helio
LMMS
MilkyTracker
Rimshot
SFXR/BFXR/CFXR
Tenacity
Maps
Tiled
Free assets and resources
Openclipart.org
Opengameart.org
Freesound
PublicDomainFiles
CCMixter
SoundBible.com
Incompetech
Contributors