Computer)Science)–)Game)Design)UC)Santa)Cruz)CMPS 20: Game Design Experience XNA)Game)Studio)January)12,)2010)Arnav)Jhala)Adapted)from)Jim)Whitehead’s)slides)Computer)Science)–)Game)Design)UC)Santa)Cruz)Announcements)• Session)schedules)being)finalized)• Homework)#1)(Hunt)the)Wumpus))– Due)Thursday,)January)21)– Detailed)instrucOons)will)be)up)by)tomorrow)• Project)themes)and)Omeline)• Check)website)frequently)for)updates)– Come)for)help)with)Homework)#1,)C#,)XNA)Computer)Science)–)Game)Design)UC)Santa)Cruz)Imagine)Cup)• Worldwide)compeOOon)– MicrosoU)sponsored)– Many)categories,)including)game)development)– RegistraOon)Feb)1)– MulOple)rounds)–)first)round)ends)March)15)– Games)must)use)XNA)Game)Studio)3.0)– Games)must)address)contest)theme)– Would)be)possible)to)take)your)project)for)CS)20,)and)enter)it)into)the)contest)– h[p://imaginecup.com/)Computer)Science)–)Game)Design)UC)Santa)Cruz)Hunt)the)Wumpus)• A)game)where)you)move)through)a)dodecahedron)shaped)map)– Each)room)is)connected)to)three)other)rooms)– Shortest)non‐repeaOng)path)back)to)same)point)is)five)moves)A)dodecahedron)Source:)Wikipedia)A)fla[ened)dodecahedron)Source:)More)BASIC)Computer)Games)www.atariarchives.org/morebasicgames/showpage.php?page=178)Computer)Science)–)Game)Design)UC)Santa)Cruz)Hunt)the)Wumpus)(cont’d))• Turn)based)game)– Each)turn,)player)moves)or)shoots)a)crooked)arrow)(up)to)five)rooms))• Three)main)types)of)obstacles)– Wumpus)• If)awake,)kills)player)if)both)in)same)room)at))end)of)turn)• “I)smell)a)Wumpus”)– Pits)(2)instances))• Player)falls)in)and)dies)• “I)feel)a)draU”)– Superbats)• Places)player)in)a))random)new)room)• “Bats)nearby”)Source:)Best)of)CreaOve)CompuOng,)Vol.)1)www.atariarchives.org/bcc1/showpage.php?page=247)Computer)Science)–)Game)Design)UC)Santa)Cruz)Hunt)the)Wumpus)(cont’d))• Main)challenges)to)the)homework)assignment)– Reading)and)parsing)input)– How)to)represent)game)world)• How)to)represent)each)room)• How)to)represent)the)set)of)all)the)rooms)– You)have)a)fixed)number)of)them)(20))• How)to)represent)connecOons)in)the)map)– Each)room)has)a)number,)and)each)room)is)connected)to)exactly)three)other)rooms)• How)to)represent)Wumpus,)pits,)bats)– Each)is)located)in)the)game)map)– WriOng)game)logic)• Main)game)loop)• Display)of)warnings)when)player)one)room)away)from)obstacles)• Behavior)of)Wumpus,)pits,)bats)when)they)interact)with)player)• Handling)shooOng)logic)Computer)Science)–)Game)Design)UC)Santa)Cruz)Hunt)the)Wumpus)(cont’d))• As)a)rule)of)thumb,)in)object)oriented)design:)– Nouns)are)represented)as)classes)• What)are)some)of)the)nouns)in)Hunt)the)Wumpus?)– Verbs)are)methods)on)the)classes)• What)are)some)of)the)acOons)on)the)nouns?)• What)can)the)player)do?)• What)can)a)Wumpus)do?)• What)can)bats)do?)• What)can)pits)do?)– Also)need)to)consider)what)informaOon)other)classes)might)need)• These)will)be)properOes)• LocaOon)of)Wumpus,)bats,)pits))Computer)Science)–)Game)Design)UC)Santa)Cruz)Console)input)in)C#)• There)are)three)methods)for)reading)console)input)in)C#)– ReadLine)• Read)a)line)of)input)into)a)string)– ReadKey)• Read)the)next)key)pressed)into)ConsoleKeyInfo)instance)• Provides)access)to)whether)ctrl,)alt,)shiU)were)pressed)– Read)• Read)a)line)of)input,)then)gives)successive)characters)each)Ome)you)call)Read)• Any)of)these)could)be)used)for)your)assignment)– ReadLine)is)easiest)to)use)Computer)Science)–)Game)Design)UC)Santa)Cruz)Console.ReadLine)• ReadLine)– Program)execuOon)blocks)unOl)user)enters)a)line,)terminated)by)Enter)– Line)typed)by)user)is)returned)as)a)string)public class ConsoleDemo { static void Main(string[] args) { string my_input; System.Console.WriteLine(“(M)ove or (S)hoot :”); my_input = System.Console.ReadLine(); } }Computer)Science)–)Game)Design)UC)Santa)Cruz)Parsing)Input)• In)Wumpus,)need)to)check)whether)player)entered)– M)for)move,)S)for)shoot,)Q)for)quit)– That)is,)check)the)first)character)of)the)user)input)– Would)like)to)be)case)sensiOve)• No)problem)–)use)string.Compare)• string.Compare)has)10)variaOons)– An)overloaded)method)– We)want:)• public)staOc)int)Compare(string)strA,)int)indexA,)string)strB,)int)indexB,)int)length,)bool)ignoreCase);)• Compare)two)strings,)strA)and)strB&• …)starOng)at)character)number)indexA)in)strA,)and)indexB)in)strB…)• …)and)comparing)length)characters)in)each)…)• …)with)the)ability)to)ignoreCase.)– Returns)0)if)strings)are)the)same))• ‐1)if)A)lexically)smaller)than)B,)1)if)A)lexiacally)larger)than)B)Computer)Science)–)Game)Design)UC)Santa)Cruz)Parsing)Input)(cont’d))• We)want)to)compare)the)first)character)of)user)input)against)– “M”)for)move)– “S”)for)shoot)– “Q”)for)quit)public class ConsoleDemo { static void Main(string[] args) { string my_input; System.Console.WriteLine(“(M)ove or (S)hoot :”); my_input = System.Console.ReadLine(); if (string.Compare(my_input, 0, "M", 0, 1, true) = = 0) // Move if (string.Compare(my_input, 0, "S", 0, 1, true) = = 0) // Shoot if (string.Compare(my_input, 0, "Q", 0, 1, true) = = 0) // Quit } } Demonstra*on+of+Console+input+and+string+parsing+in+Visual+C#+2008+Computer)Science)–)Game)Design)UC)Santa)Cruz)Unified)Modeling)Language)(UML))• A)family)of)diagram)types)used)to)model)object‐oriented)soUware)projects)– A)standard)way)to)graphically)represent)complex)assemblages)of)objects,)components,)etc.)• Two)useful)diagram)types)– Class)diagram)• StaOc)view)of)soUware)• Object‐oriented)classes)• RelaOonships)– Inheritance)– Containment)– Sequence)diagram)• Dynamic)view)• Methods)calling)methods,))and)in)what)order)Jmgold,)Flickr)www.flickr.com/photos/jmgold/2210820262/)Computer)Science)–)Game)Design)UC)Santa)Cruz)Modeling)a)Class)in)UML)• An)object)oriented)class)contains:)– Data:)class)variables)• Type)&)visibility)of)each)variable)– Methods)•
View Full Document