560 likes | 690 Views
Announcements. Please register for the course on Banner if you haven’t If you need an override, email cs195uheadtas@cs.brown.edu This weekend is a long weekend You still have work due There are still hours Next week is playtesting rather than weeklies
E N D
Announcements • Please register for the course on Banner if you haven’t • If you need an override, email cs195uheadtas@cs.brown.edu • This weekend is a long weekend • You still have work due • There are still hours • Next week is playtesting rather than weeklies • Note that playtesting, not being playtested, is the requirement • If you want your game to be playtested, be sure to hand in on time!
Lecture 3 Without taxation! Gameplay Mechanics Tips for Minecraft 3 Weeklies Object Representation
Entity (game object) representation • Many possible ways to represent a game object • Frequently want several different representations of the same entity • Different information needed for rendering, collision detection, physics, animation… • Can be thought of as a single class in an inheritance hierarchy • This is probably how most of you are doing it • Can alternatively be thought of as a collection of “components” used by different engine subsystems • Component-based engines (will be covered as a special topic)
Rendering • Designed for efficient resource usage • Ordered by material • Geometry in formats meant for graphics hardware • Such as triangle strips • Many entities exist only for rendering • Blades of grass • Decals on walls
Collision • The simpler, the better • As long the visual result is not conspicuously inconsistent • Common geometry for collision detection • Sphere/ellipsoid • AABB/OBB • Cylinder • Capsule • Some geometry pieces/entities are just for collision detection • Blocking volumes on edges of cliffs or in the sky • “invisible walls”
Physics • Simple geometry with extra properties • Center of mass, mass distribution function • Linear velocity, angular velocity • Coefficients of friction, restitution • Constraints • Ball-and-socket joints, hinges, pistons
Animation • Baked animation • Interpolation between keyframes in a sequence • Full-character or per-part (different leg and torso animations) • Procedural animation • Generate pose dynamically from environment • Example: create pose from contact points • Attachment points for carrying/manipulating items
Lecture 3 Well there’s yer problem! Gameplay Mechanics Tips for Minecraft 3 Weeklies Object Representation
Gameplay mechanics • This section focuses purely on mechanics • Not covering narrative, aesthetics, etc. • Lots of advice from The Art of Game Design by Jesse Schell • Professor at Entertainment Technology Center at CMU • Lots of excellent online resources • We recommend the “Extra Credits” web series
Questions • Overarching question: • What makes games fun? • Other important questions: • What is a game? • What is a puzzle? • What does fun mean? • How do I balance my game? • Will feature X improve my game?
What is a game? • Lots of disagreement over exact definition • Some important game qualities: • Has goals • Has conflict • Has rules • Can be won and lost • Is interactive • Has challenge • Can create intrinsic value • Engages players • Is a closed, formal system • Not every game has all of these qualities
A simpler definition • "A game is a problem-solving activity, approached with a playful attitude." - Jesse Schell • Why is this important? • Consider what problems the player is solving • Think about how to add interesting new problems
What is a puzzle? • "A puzzle is a game with a dominant strategy" - Schell • Puzzles are key to many games • Goal must be easily understood • Sense of progress important • It's not fun being stuck • How to prevent the player from getting stuck • Provide hints • Dynamically adjust difficulty • e.g. add more time for a timed challenge after the player fails • Provide a way of skipping puzzles
What does fun mean? • Many categories of fun • Fun of learning • Fun of mastery • Fun of exploration • Fun of overcoming challenges (called Fiero) • Social fun • There are also different categories of players • Bartle's taxonomy has 4 categories based off surveys of MUD (multi-user dungeon) players
Bartle's taxonomy of player types • Achievers • Want to achieve goals of the game, overcome challenges • Explorers • Want to know breadth of game, pleasure of discovery • Socializers • Seek relationships with other players, pleasure of fellowship • Killers • Mainly enjoy competing and defeating others
Beyond Bartle's taxonomy • Bartle proposed expanded model in 2003 • Friend • Griefer • Hacker • Networker • Opportunist • Planner • Politician • Scientist • Others argue for a "component" model • Measure each type/component independently • http://www.nickyee.com/daedalus/motivations.pdf
Difficulty • Usually want difficulty levels and/or adaptive difficulty • Widens your audience • Adds longevity for dedicated players • What's appropriate difficulty for the creator is way too difficult for the average player • Playtest, playtest, playtest! • It will be obvious what playtesters find too difficult
Flow • "A feeling of complete and energized focus in an activity, with a high level of enjoyment and fulfillment" – Schell • Preconditions: • Goals are clear • Feedback is immediate • Balance between perceived challenge and perceived ability
Interest curves • Used in all kinds of storytelling • Starts off with a hook • Includes a climax close to the end Interest Time
Case study: Left 4 Dead • FPS based on a group of 4 survivors in a zombie apocalypse • Extremely simple goal: get from a starting position to a safe house • What makes it fun and replayable? • AI director adjusts pacing based on how you play • Procedurally populates world with enemies
Left 4 Dead: AI Director • Promote "structured unpredictability" • Uniform randomness isn't exciting • Exact positioning isn't replayable • Want to move toward a target intensity • Model "Emotional Intensity" of each player • Take max of intensity of all players • If too high, temporarily remove threats • If too low, create an interesting population
Left 4 Dead: "Emotional Intensity" • Model survivor intensity as a number • Increase intensity when player is damaged, pushed off a ledge, etc. • Decay intensity over time when player is not engaged
Left 4 Dead: Population modulation • Use emotional intensity to modulate population • Build up, sustain, fade, and relax • Sound familiar? All about Interest curves!
Case study: Batman: Arkham Asylum • Third-person adventure; player is Batman • Variety of gameplay types • Puzzles • Roaming • Combat • Gargoyle room (sneaking without being noticed) • Cinematic (no player interaction) • Boss fight • Gadget (player given new gagdet to play with) • How to combine all these elements? • Pacing through variety
Batman: Arkham Asylum • Interleaves contrasting gameplay elements • Rarely more than 5 minutes of successive combat • What does the interest curve look like? • Steady progress • New gadgets awarded roughly every 60 minutes of gameplay • Allows short bursts of exploration; an entirely open world is often too overwhelming • Anticipation of unlocking new areas • Clear objectives and clear rewards
Balance • All games, especially multiplayer ones, have some notion of balance • Unbalanced game becomes old quickly • Good balance provides longevity • What is balance? • Preventing a single dominant strategy • Strive for emergent complexity
Balance: The problems • Balancer's Paradox • Can't balance weapon's power until we know player's health • Can't balance player's health until we know weapon damage • Fairness != balance • Rock-Paper-Scissors is fair • But it's a boring game, all roles are the same! • We want balance with asymmetric gameplay
Balance: Suggestions • Balance in passes • Don't backtrack in the middle of a pass! • Starting with paper design helps • List out as many specifics as possible as a baseline • Know what cannot change • List invariants, tweak everything else • Make large changes, not small ones • e.g. Use factors of 2 to adjust scale, not "I'll add 0.5"
Case study: Halo 3 • Sniper rifle was overpowered in Halo 2 • How to fix this? • Make the balance instantly noticeable • Not total ammo • Balance what the player can see • Not damage per shot • Don't add a new weakness • Instead balance out strengths
Halo 3: What to change? • So, what should be changed? • Increase time to zoom • Doesn't fix close range use • Increase length of reload • Feels like a weakness • Reduce number of shots in clip • Pressure to constantly reload • Increase time between shots • Instantly noticeable, but doesn't weaken original role
Halo 3: Final decision • Time between shots increased from 0.5 seconds to 0.7 seconds • Lots of testing before the change was finalized
Game spaces • More than just the geometry of a world • Graph that connects different game areas • Consider different types of game spaces • Linear • Grid • Web • Hub • Divided
Game spaces: Linear • Player moves forward (and possibly backward) • Examples • Super Mario Brothers • Crash Bandicoot • Guitar Hero
Game spaces: Grid • Easy to understand • For both players and computers • Cells don't need to be square • Civilization V uses a hexagonal grid • Examples • Fire Emblem • Legend of Zelda (NES) • Civilization
Game spaces: Web • Interest points connected by paths • Common technique: several branches ending at same location • Examples • Zork • Defense of the Ancients (DotA) • Onslaught Mode in Unreal Tournament 2004
Game spaces: Hub • Central hub connects to areas of interest • Examples • Banjo Kazooie • Diddy Kong Racing • Super Mario Galaxy
Game spaces: Divided space • Irregularly divide world into sections • Most like a real map • Examples • Zelda: Ocarina of Time • Darksiders • Metroid Prime
Conclusions • No formula for a fun game • Try to maintain balance and allow players to stay in the flow channel • Make prototypes • Paper or electronic • No other way to get a sense of a mechanic's feel • Playtest • Trust people's gut feelings, not their suggestions
Lecture 3 Hssssssss . . . ! Gameplay Mechanics Tips for Minecraft 3 Weeklies Object Representation
Minecraft: Week 3 • Adding and removing blocks • Use voxel traversal rays • Enemies with simple movement and jumping • Collide as AABB, must collide with the player • Streaming chunks • But you don’t need to save modifications to the world
Adding and removing blocks • Cast a ray from the player’s eye • First collision point determines block to remove • Block adjacent to face of collision determines block to add • Make sure not to add to a block occupied by the player! • How to efficiently intersect the ray with a large number of blocks? • Voxel traversal! Eye
Fast voxel traversal algorithm • Ray equation: • Two stage algorithm • Initialization • Traversal • Intuition: break ray into components based on grid boundaries 6 3 4 5 1 2 P
Fast voxel traversal algorithm V = [2, 1] // +1 or -1 depending on direction constintstepX, stepY; // t delta to span an entire cell const floattDeltaX, tDeltaY; // integer block coordinates intX, Y; // t value to next integer boundary floattMaxX, tMaxY; loop { processVoxel(X, Y); if (tMaxX < tMaxY) { tMaxX += tDeltaX; X += stepX; } else { tMaxY += tDeltaY; Y += stepY; } } 3 tMaxY = 0.8 tMaxX = 0.95 2 tMaxX = 0.45 (X, Y) P = [1.1, 1.2] (X, Y) tMaxY = 1.8 1 1 2 3 4 (X, Y) (X, Y) tMaxX = 0.95
Fast Voxel Traversal Algorithm • Calculations on previous page didn’t have normalized V-vector • Mostly just to show an easy example of how to calculate • Be sure to normalize this vector! • Can be easily extended to 3D • Be careful of rays parallel to an axis (divide by 0) • Look at the paper for more details • http://www.cse.yorku.ca/~amana/research/grid.pdf
Enemies • Keep behavior simple • For example: go directly toward the player and jump if on ground • Reuse AABB-world collision detection from last week • Collide with player using AABB-AABB collision detection • Don’t need to move out of collision • Optional: make a rigid-body hierarchy with animation
Optional: Random sampling • You can have a vector directly pointing to the player • What if we want a random vector biased toward the player? • Method 1: Linearly combine a unit vector toward the player with a uniformly random unit vector • Method 2: Sample from a non-uniform random distribution
Aside: Random sampling • How do we get a uniformly random 3D unit vector? • Choose a uniformly random yaw and pitch? • No: there are more points near the poles! • Choose uniform (x, y, z) within unit cube, then normalize? • No: it will be denser near the 8 cube corners • What does work: • Choose a yaw from [0, 2π) and z from [-1, 1] (point on a cylinder), then map onto a sphere:[x, y, z] = [sqrt(1 – z^2)cos(yaw), sqrt(1 – z^2)sin(yaw), z]
Aside: Random sampling • C++ only provides rand()for pseudorandom ints • Convert to [0, 1] float or double by dividing by RAND_MAX • Random vector implemented in support code already: Vector3::randomDirection() • C++11 standard library has three different pseudorandom number generators • Also has non-uniform random distributions (poisson, gamma, and others)
AABB-AABB collision detection • Simple interval overlap test along each axis • Return true only if all interval tests detect an overlap • Most efficient if AABB is represented as min and max in each dimension Interval test: returnb.min <= a.max && a.min <= b.max a.max b.max a.min b.min a.min b.min b.max a.max