game architecture
play

Game Architecture CS 4730 Computer Game Design - PowerPoint PPT Presentation

Game Architecture CS 4730 Computer Game Design Credit: Some slide material courtesy Walker White (Cornell) CS 4730 Event-Driven Programming


  1. Game ¡Architecture ¡ CS ¡4730 ¡– ¡Computer ¡Game ¡Design ¡ ¡ ¡ ¡ Credit: ¡Some ¡slide ¡material ¡courtesy ¡Walker ¡White ¡(Cornell) ¡ CS ¡4730 ¡

  2. Event-­‑Driven ¡Programming ¡ • Consider ¡all ¡the ¡programs ¡you’ve ¡wriFen ¡up ¡to ¡ this ¡point ¡ • Did ¡they ¡do ¡anything ¡when ¡the ¡user ¡didn’t ¡ask ¡ for ¡something? ¡ • Was ¡there ¡processing ¡in ¡the ¡background? ¡ • Or ¡did ¡it ¡mainly ¡respond ¡to ¡user ¡input? ¡ CS ¡4730 ¡ 2

  3. Event-­‑Driven ¡Programming ¡ • The ¡event-­‑driven ¡paradigm ¡works ¡great ¡for ¡a ¡ lot ¡of ¡systems ¡ – Web ¡(we ¡REALLY ¡want ¡this!) ¡ – Mobile ¡ – Office ¡apps ¡ • But ¡is ¡this ¡what ¡we ¡want ¡in ¡this ¡class? ¡ • Well… ¡maybe ¡if ¡we ¡were ¡only ¡programming ¡ board ¡games… ¡ CS ¡4730 ¡ 3

  4. Event-­‑Driven ¡Gaming ¡ • Consider ¡board ¡games ¡ • They ¡are, ¡in ¡fact, ¡event-­‑driven ¡in ¡many ¡cases ¡ • There ¡are ¡some ¡things ¡that ¡happen ¡“behind ¡the ¡ scenes” ¡ – Upda[ng ¡tallies ¡ – Shuffling ¡the ¡deck ¡ – Deciding ¡the ¡moves ¡of ¡the ¡“bad ¡guys” ¡ • But ¡not ¡all ¡games ¡are ¡like ¡this ¡ CS ¡4730 ¡ 4

  5. The ¡Game ¡Loop ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ Credit: ¡Walker ¡White ¡ CS ¡4730 ¡ 5

  6. Step ¡1. ¡Player ¡Input ¡ • Remember: ¡player ¡input ¡is ¡one ¡set ¡of ¡variables ¡ that ¡enter ¡our ¡equa[on ¡to ¡affect ¡game ¡state ¡ • Input ¡is ¡typically ¡polled ¡during ¡game ¡loop ¡ – What ¡is ¡the ¡state ¡of ¡the ¡controller? ¡ – If ¡no ¡change, ¡do ¡no ¡ac[ons ¡ • However, ¡we ¡can ¡only ¡read ¡input ¡once ¡per ¡ game ¡loop ¡cycle ¡ • But ¡good ¡frame ¡rate ¡is ¡short ¡and ¡most ¡events ¡ are ¡longer ¡than ¡one ¡frame ¡ CS ¡4730 ¡ 6

  7. Step ¡2. ¡Process ¡ac[ons ¡ • Alter ¡the ¡game ¡state ¡based ¡on ¡your ¡input ¡ • We’ve ¡discussed ¡this! ¡ • These ¡are ¡the ¡player ¡ac[ons ¡/ ¡verbs ¡ • However, ¡don’t ¡lock ¡the ¡controller ¡to ¡directly ¡ changing ¡the ¡state! ¡ • Place ¡a ¡buffer ¡here ¡– ¡have ¡it ¡call ¡a ¡method ¡ which ¡allows ¡some ¡flexibility ¡in ¡design ¡later ¡ CS ¡4730 ¡ 7

  8. Step ¡3. ¡Process ¡NPCs ¡ • An ¡NPC ¡(Non-­‑Player ¡Character) ¡is ¡anything ¡that ¡has ¡ voli[on ¡in ¡the ¡world ¡that ¡isn’t ¡you ¡ • NPCs ¡take ¡input ¡from ¡the ¡AI ¡engine ¡(maybe!) ¡but ¡not ¡ from ¡a ¡direct ¡controller ¡ • Work ¡on ¡the ¡idea ¡of ¡Sense-­‑Think-­‑Act: ¡ – Sense ¡the ¡state ¡of ¡the ¡world ¡around ¡it ¡(how ¡can ¡we ¡ “cheat” ¡here ¡to ¡make ¡an ¡NPC ¡“harder”?) ¡ – Think ¡about ¡what ¡ac[on ¡to ¡perform ¡(usually ¡limited ¡ choices) ¡ – Act ¡in ¡the ¡world ¡ CS ¡4730 ¡ 8

  9. Step ¡3. ¡Process ¡NPCs ¡ • Problem ¡is ¡sensing ¡is ¡hard! ¡ – What ¡does ¡the ¡NPC ¡need ¡to ¡know? ¡ – What ¡is ¡the ¡state ¡of ¡ALL ¡OTHER ¡OBJECTS? ¡ ¡UGH. ¡ • Limit ¡sensing? ¡ ¡“Cheat?” ¡ • Another ¡problem ¡– ¡thinking ¡is ¡hard! ¡ – Can ¡take ¡more ¡than ¡one ¡frame ¡to ¡decide ¡what ¡to ¡do! ¡ – Act ¡without ¡thinking? ¡ – What ¡if ¡one ¡acts, ¡then ¡the ¡next ¡acts ¡on ¡that ¡ac[on? ¡ • More ¡in ¡AI ¡and ¡Pathfinding! ¡ CS ¡4730 ¡ 9

  10. Step ¡4. ¡World ¡Processing ¡ • Physics! ¡ • Ligh[ng! ¡ • Collisions! ¡ • So ¡much ¡cool ¡stuff! ¡ • But ¡later! ¡ J ¡ CS ¡4730 ¡ 10

  11. Drawing ¡ • Well, ¡it ¡needs ¡to ¡be ¡fast! ¡ – We ¡want ¡to ¡do ¡as ¡liFle ¡computa[on ¡as ¡possible ¡ – Draw ¡ONLY ¡what’s ¡on ¡the ¡screen! ¡ • Keep ¡the ¡drawing ¡and ¡the ¡state ¡modifica[on ¡ separate! ¡ • PreFy ¡easy ¡to ¡do ¡in ¡MonoGame ¡ CS ¡4730 ¡ 11

  12. Architecture ¡Big ¡Picture ¡ ¡ ¡ Credit: ¡Walker ¡White ¡ CS ¡4730 ¡ 12

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend