Game Design Pa,erns CS 4730 Computer Game Design - - PowerPoint PPT Presentation

game design pa erns
SMART_READER_LITE
LIVE PREVIEW

Game Design Pa,erns CS 4730 Computer Game Design - - PowerPoint PPT Presentation

Game Design Pa,erns CS 4730 Computer Game Design Credit: Some slide material courtesy Walker White (Cornell) CS 4730 Architecture Big Picture


slide-1
SLIDE 1

CS ¡4730 ¡

Game ¡Design ¡Pa,erns ¡

CS ¡4730 ¡– ¡Computer ¡Game ¡Design ¡ ¡ ¡ ¡

Credit: ¡Some ¡slide ¡material ¡courtesy ¡Walker ¡White ¡(Cornell) ¡

slide-2
SLIDE 2

CS ¡4730 ¡

Architecture ¡Big ¡Picture ¡

¡ ¡ Credit: ¡Walker ¡White ¡

2

slide-3
SLIDE 3

CS ¡4730 ¡

OO ¡to ¡MVC ¡

  • We’ve ¡discussed ¡how ¡OO ¡doesn’t ¡quite ¡work ¡

for ¡games ¡

– Not ¡that ¡we ¡have ¡to ¡throw ¡it ¡all ¡out ¡of ¡the ¡window, ¡ but ¡class ¡bloat ¡can ¡be ¡a ¡problem ¡

  • We ¡have ¡also ¡discussed ¡MVC ¡in ¡which ¡

– We ¡have ¡a ¡lightweight ¡model ¡represenNng ¡world ¡

  • bjects ¡

– We ¡have ¡a ¡heavyweight ¡controller ¡in ¡the ¡game ¡loop ¡ – We ¡have ¡a ¡drawing ¡method ¡

3

slide-4
SLIDE 4

CS ¡4730 ¡

The ¡Decorator ¡PaRern ¡

  • Remember ¡when ¡we ¡discussed ¡the ¡decorator ¡

paRern? ¡

  • The ¡idea ¡was ¡that ¡we ¡could ¡have ¡objects ¡that ¡

we ¡“hung” ¡various ¡funcNonality ¡bits ¡on ¡that ¡ would ¡handle ¡how ¡that ¡object ¡behaved ¡in ¡the ¡ world ¡

  • What ¡if ¡we ¡could ¡take ¡that ¡to ¡the ¡extreme? ¡

4

slide-5
SLIDE 5

CS ¡4730 ¡

EnNty-­‑Component-­‑System ¡

  • Another ¡game ¡architecture ¡paRern ¡is ¡EnNty-­‑

Component-­‑System ¡

  • First ¡really ¡described ¡by ¡ScoR ¡Bilas ¡of ¡Gas ¡

Powered ¡Games ¡and ¡then ¡by ¡Adam ¡MarNn ¡

  • ECS ¡is ¡a ¡paRern ¡in ¡which ¡each ¡object ¡in ¡the ¡

world ¡is ¡completely ¡unique ¡(as ¡in, ¡is ¡ represented ¡by ¡a ¡single ¡“primary ¡key” ¡integer) ¡

  • In ¡fact, ¡ECS ¡works ¡kinda ¡like ¡a ¡database… ¡

5

slide-6
SLIDE 6

CS ¡4730 ¡

What ¡is ¡an ¡EnNty? ¡

  • This ¡might ¡be ¡a ¡bit ¡hard ¡to ¡swallow ¡for ¡OO ¡

programmers ¡

  • What ¡is ¡an ¡EnNty? ¡

– An ¡EnNty ¡is ¡a ¡globally ¡unique ¡number ¡ – For ¡every ¡discernible ¡thing ¡in ¡your ¡game-­‑world, ¡you ¡ have ¡one ¡EnNty ¡(not ¡one ¡class, ¡one ¡actual ¡EnNty) ¡ – EnNNes ¡have ¡no ¡data ¡and ¡no ¡methods ¡

6

slide-7
SLIDE 7

CS ¡4730 ¡

What ¡is ¡a ¡Component? ¡

  • A ¡Component ¡provides ¡an ¡aspect ¡of ¡state ¡to ¡an ¡

EnNty ¡

– Want ¡an ¡EnNty ¡to ¡have ¡posiNon ¡in ¡the ¡world? ¡ ¡Give ¡ it ¡a ¡SpaNal ¡Component ¡ – Should ¡the ¡EnNty ¡have ¡health? ¡ ¡Add ¡a ¡Health ¡ Component ¡ – Does ¡it ¡have ¡velocity ¡like ¡a ¡bullet? ¡ ¡FantasNc ¡– ¡add ¡ the ¡Velocity ¡Component ¡

7

slide-8
SLIDE 8

CS ¡4730 ¡

What ¡is ¡a ¡Component? ¡

  • MarNn: ¡“ALL ¡the ¡data ¡goes ¡into ¡the ¡
  • Components. ¡ALL ¡of ¡it. ¡Think ¡you ¡can ¡take ¡

some ¡“really ¡common” ¡data, ¡e.g. ¡the ¡x/y/z ¡co-­‑

  • rds ¡of ¡the ¡in-­‑game ¡object, ¡and ¡put ¡it ¡into ¡the ¡

EnNty ¡itself? ¡Nope. ¡Don’t ¡go ¡there. ¡As ¡soon ¡as ¡ you ¡start ¡migraNng ¡data ¡into ¡the ¡EnNty, ¡you’ve ¡

  • lost. ¡BY ¡DEFINITION ¡the ¡only ¡valid ¡place ¡for ¡the ¡

data ¡is ¡inside ¡the ¡Component” ¡

  • Why ¡is ¡this? ¡

8

slide-9
SLIDE 9

CS ¡4730 ¡

AbstracNon ¡

  • Everything ¡is ¡abstracted ¡away! ¡
  • An ¡EnNty ¡is ¡just ¡a ¡“place ¡to ¡hang” ¡stuff ¡
  • It’s ¡the ¡combinaNon ¡of ¡Components ¡that ¡

creates ¡a ¡unique ¡in-­‑game ¡object! ¡

  • The ¡EnNty ¡is ¡simply ¡a ¡“primary ¡key” ¡that ¡holds ¡

all ¡the ¡Components ¡together ¡

  • Then ¡how ¡do ¡things ¡get ¡updated? ¡

9

slide-10
SLIDE 10

CS ¡4730 ¡

What ¡is ¡a ¡System? ¡

  • A ¡System ¡is ¡a ¡cohesive ¡set ¡of ¡funcNonality ¡that ¡

does ¡all ¡of ¡one ¡thing ¡in ¡the ¡game ¡(i.e. ¡it ¡holds ¡ all ¡the ¡behaviors) ¡

– Collision ¡DetecNon ¡ – Player ¡Input ¡ – Enemy ¡AI ¡and ¡Movement ¡ – Rendering ¡ – Enemy ¡Spawning ¡ – Physics ¡

10

slide-11
SLIDE 11

CS ¡4730 ¡

Systems ¡

11

slide-12
SLIDE 12

CS ¡4730 ¡

What ¡good ¡does ¡this ¡do? ¡

  • It ¡makes ¡the ¡game ¡MUCH ¡more ¡modular ¡
  • You ¡can ¡plug-­‑and-­‑play ¡preRy ¡much ¡anything ¡
  • You ¡can ¡change ¡out ¡funcNonality ¡without ¡

affecNng ¡the ¡rest ¡of ¡the ¡game ¡

  • And ¡most ¡importantly, ¡it ¡can ¡make ¡your ¡design ¡

data-­‑driven ¡

12

slide-13
SLIDE 13

CS ¡4730 ¡

Data-­‑Driven ¡Design ¡

  • Who ¡is ¡involved ¡in ¡making ¡a ¡video ¡game? ¡

13

slide-14
SLIDE 14

CS ¡4730 ¡

Data-­‑Driven ¡Design ¡

  • Who ¡is ¡involved ¡in ¡making ¡a ¡game? ¡

– Programmers ¡ – Level ¡designers ¡ – Dialogue ¡writers ¡ – Visual ¡arNsts ¡ – Musicians ¡ – Sound ¡effects ¡designers ¡ – Etc… ¡

  • Not ¡all ¡of ¡these ¡folks ¡are ¡programmers… ¡

14

slide-15
SLIDE 15

CS ¡4730 ¡

Data-­‑Driven ¡Design ¡

  • The ¡idea ¡is ¡that ¡all ¡content ¡is ¡NOT ¡hardcoded ¡

into ¡the ¡game ¡system ¡

  • This ¡includes: ¡

– Art ¡ – Music ¡ – Levels ¡ – Dialogue ¡ – AI ¡scripNng ¡ – Etc… ¡

15

slide-16
SLIDE 16

CS ¡4730 ¡

Data-­‑Driven ¡Design ¡

  • Why? ¡

– OpNmize ¡the ¡game ¡creaNon ¡pipeline; ¡mulNple ¡folks ¡ working ¡on ¡different ¡things ¡ – Makes ¡your ¡job ¡of ¡creaNng ¡content ¡MUCH ¡easier ¡in ¡ general ¡(put ¡all ¡the ¡levels ¡in ¡one ¡folder ¡– ¡when ¡the ¡ game ¡starts, ¡it ¡loads ¡all ¡the ¡levels ¡in ¡that ¡folder!) ¡ – Could ¡support ¡the ¡community ¡to ¡create ¡their ¡own ¡ content ¡ – Easier ¡to ¡reuse ¡code ¡later ¡(not ¡Ned ¡to ¡the ¡specifics ¡

  • f ¡that ¡game) ¡

16

slide-17
SLIDE 17

CS ¡4730 ¡

Formats ¡

  • How ¡should ¡you ¡create ¡your ¡data ¡files? ¡
  • Art ¡assets ¡should ¡be ¡standard ¡formats ¡
  • Scripts, ¡dialogue, ¡and ¡other ¡text ¡info? ¡

– XML ¡is ¡a ¡reasonable ¡opNon ¡and ¡C# ¡has ¡libraries ¡to ¡ parse ¡it ¡ – JSON ¡could ¡be ¡an ¡opNon ¡as ¡well, ¡but ¡might ¡require ¡ more ¡parsing ¡

17

slide-18
SLIDE 18

CS ¡4730 ¡

ECS ¡meets ¡Data-­‑Driven ¡

  • Users ¡can ¡have ¡more ¡control ¡over ¡the ¡game ¡if ¡

you ¡let ¡them ¡

  • Steam ¡Workshop, ¡for ¡example ¡
  • And ¡your ¡process ¡should ¡be ¡a ¡lot ¡easier ¡as ¡well ¡
  • Consider… ¡

18

slide-19
SLIDE 19

CS ¡4730 ¡

World ¡of ¡Warcral ¡– ¡Stock ¡UI ¡

19

slide-20
SLIDE 20

CS ¡4730 ¡

World ¡of ¡Warcral ¡– ¡Modded ¡UI ¡

20

slide-21
SLIDE 21

CS ¡4730 ¡

A ¡Game ¡Within ¡A ¡Game ¡

  • I ¡can’t ¡tell ¡you ¡how ¡much ¡Nme ¡I’ve ¡spent ¡

finding ¡WoW ¡mods… ¡

  • Example ¡lua ¡code ¡for ¡WoW: ¡

function HelloWorld() print("Hello, World!"); end

21

slide-22
SLIDE 22

CS ¡4730 ¡

A ¡Game ¡Within ¡A ¡Game ¡

  • XML ¡Document ¡that ¡goes ¡with ¡it: ¡

<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema- instance" xsi:schemaLocation="http://www.blizzard.com/wow/ ui/ ..\..\FrameXML\UI.xsd"> <Script File="HelloWorld.lua"/> <Frame name="HelloWorldFrame"> <Scripts> <OnLoad> HelloWorld(); </OnLoad> </Scripts> </Frame> </Ui>

22