A Quick Prototyping Tool for Serious Games with Real Time Physics
Total Page:16
File Type:pdf, Size:1020Kb
Technische Universität München Fakultät für Informatik Master’s Thesis in Computational Science and Engineering A quick prototyping tool for serious games with real time physics Juan Haladjian Technische Universität München Fakultät für Informatik Master’s Thesis in Computational Science and Engineering A quick prototyping tool for serious games with real time physics Juan Haladjian Date: 26.09.2011 Supervisor: Prof. Bernd Brügge, Ph.D Advisor: Dipl.-Inf. Univ. Damir Ismailović Ich versichere, dass ich diese Diplomarbeit selbständig verfasst habe und nur die angegebenen Quellen und Hilfsmittel verwendet habe. München,den26.09.2011, .......................... (Juan Haladjian) v Acknowledgments I would like to express my gratitude to Prof. Bernd Brügge for making me part of his research team. Special gratitude goes to my supervisor Damir for his great ideas, constant support and ability to motivate. I am also pleased to acknowledge Barbara’s tips on usability of my application and Jelena’s corrections of this document. vii Contents 1Introduction 1 1.1 Outline .................................... 1 2TheoreticalBackground 3 2.1 Software Prototyping ............................ 3 2.1.1 Prototype Based Programming .................. 4 2.1.2 Domain Specific Language (DSL) ................. 5 2.2 Serious Games ................................ 7 2.2.1 Definition .............................. 7 2.2.2 Game Engineering ......................... 8 2.2.3 Serious Game Engineering ..................... 11 2.3 Multitouch Gestures ............................ 12 3Casestudy 15 3.1 Development ................................ 16 3.2 The Rope Game ............................... 16 3.3 Observed Problems ............................. 18 3.3.1 Complexity of Physics ....................... 19 3.3.2 Changes in the Requirements ................... 20 4RequirementsSpecification 22 4.1 Related Work ................................ 22 4.1.1 Physics Editors ........................... 22 4.1.2 Sprite Helpers ............................ 25 4.1.3 Braille Games Generator ...................... 26 4.1.4 Parallel Software Generator .................... 26 4.1.5 Software Cinema .......................... 27 4.1.6 Scratch ................................ 28 4.1.7 Lua ................................. 28 4.1.8 Summary .............................. 29 4.2 Objectives .................................. 30 4.3 Scenarios ................................... 32 4.3.1 Problem Scenarios ......................... 32 4.3.2 Visionary Scenario ......................... 33 4.4 Functional Requirements ......................... 34 4.4.1 Editing ................................ 34 ix CONTENTS 4.4.2 Simulating .............................. 36 4.4.3 Generating Code .......................... 36 4.5 Non-functional Requirements ....................... 37 4.5.1 Usability ............................... 37 4.5.2 Performance ............................. 38 4.5.3 Supportability ............................ 38 4.5.4 Robustness ............................. 39 4.5.5 Implementation Requirements ................... 39 4.6 System Models ............................... 39 4.6.1 Use Case Model ........................... 39 4.6.2 Object Model ............................ 40 4.6.2.1 Editing and Simulating ................. 40 4.6.2.2 Palette .......................... 41 4.6.2.3 Application Objects ................... 42 4.6.2.4 Code Generation ..................... 43 4.6.3 Dynamic Model .......................... 43 4.7 User Interface ................................ 44 5SystemDesign 47 5.1 Design Goals ................................ 47 5.2 Enabling Technology ............................ 48 5.2.1 Cocoa Framework .......................... 48 5.2.2 Cocos2d Framework ........................ 48 5.2.3 Box2d Physics Engine ....................... 49 5.3 Subsystem Decomposition ......................... 49 5.4 Persistent Data Management ........................ 50 6ObjectDesign 51 6.1 World Subsystem .............................. 51 6.1.1 Memento Classes .......................... 51 6.1.2 Connectable Objects ........................ 52 6.1.3 Object State Triggers ........................ 53 6.1.4 Rope as Proxy Pattern ....................... 53 6.1.5 Particle System as Strategy Pattern ................ 54 6.2 Edition Subsystem ............................. 54 6.2.1 Overview .............................. 54 6.2.2 Palette ................................ 55 6.2.2.1 AddObjectsTab ...................... 55 6.2.2.2 EditObjectsTab ...................... 56 6.2.2.3 Droppable Protocol .................... 56 6.2.2.4 Custom Palette Items .................. 57 6.2.3 Dynamic Behavior ......................... 58 6.3 Simulation Subsystem ........................... 59 6.4 Code Generation Subsystem ........................ 59 6.5 View Subsystems .............................. 60 x CONTENTS 7ParticleSimulation 63 7.1 The Linked-Cell method .......................... 65 7.2 Rendering optimizations .......................... 67 7.3 Conclusions ................................. 69 8Evaluation 71 8.1 Prototypical implementation ........................ 71 8.2 Achievement of Objectives ......................... 71 8.2.1 Realized Functionality ....................... 71 8.2.1.1 Editing .......................... 71 8.2.1.2 Simulating ........................ 74 8.2.1.3 Generating Code ..................... 74 8.2.2 Nonfunctional Requirements Accomplishment .......... 74 8.2.2.1 Usability ......................... 74 8.2.2.2 Performance ........................ 75 8.2.2.3 Supportability ...................... 76 8.2.2.4 Robustness ........................ 76 8.3 Game Creation ............................... 77 8.3.1 Case Study: Creation of the Rope Game ............. 77 8.3.2 Creation of “Cut the Rope” .................... 81 9ConclusionsandFutureWork 84 9.1 Supporting Polygons ............................ 85 9.2 Custom PaletteItems ............................ 85 9.3 Code Generation .............................. 86 9.4 Snapping to Grid .............................. 86 9.5 Removing Objects ............................. 86 9.6 Dynamically Loading Assets ........................ 87 9.7 Grouping Objects Around a Physical Object ............... 87 9.8 Labels .................................... 87 AUsedSoftware 89 A.1 Software Development ........................... 89 A.2 Software Resources ............................. 89 A.3 Authoring this Document ......................... 89 B Glossary 91 Bibliography 93 xi CONTENTS xii List of Figures 2.1 Logo graphics ................................ 6 2.2 Game design phases [45]. .......................... 8 3.1 Sketch of the Rope Game .......................... 17 3.2 Structure of the Rope Game ........................ 18 4.1 GUI of the LevelHelper physics editor. .................. 23 4.2 Editing the collision polygon of an image in Physics-Editor. ....... 26 4.3 DPnDP communication model [38]. .................... 27 4.4 Blocks in Scratch. .............................. 28 4.5 Usage of prototype and class based languages in different phases of the software engineering process. ........................ 31 4.6 Mapping between a conceptual model and a formal model. ....... 31 4.7 Use cases identified in a UML use case diagram. ............. 40 4.8 The World class and its relation to application objects, Editor and Simulator. ................................. 41 4.9 The Palette and its relation with the PaletteItem taxonomy. ..... 41 4.10 The EditableObject taxonomy. ...................... 42 4.11 The Composite PhysicalObject. ...................... 42 4.12 Relation between TriggersandotherEditableObjects. ........ 43 4.13 The CodeGenerator taxonomy and its relation to the Template class. 43 4.14 States diagram of the system. ....................... 44 4.15 Sketch of the system’s interface, together with the functional require- ments. .................................... 45 5.1 System’s design as Model View Controller. ................ 50 6.1 Structure of Memento classes. ....................... 52 6.2 The Memento taxonomy. .......................... 52 6.3 A trigger being connected to an action. .................. 52 6.4 The ObjectStateTrigger taxonomy. ................... 53 6.5 Rope as a Proxy pattern .......................... 54 6.6 Overview of the Edition Subsystem. ................... 55 6.7 The AddObjectsTab tab. .......................... 55 6.8 The EditObjectsTab tab. ......................... 56 6.9 The Droppable protocol .......................... 57 6.10 The composite CustomPaletteItem .................... 57 xiii LIST OF FIGURES 6.11 Sequence of events after the user adds an object from the palette into the scene. .................................. 58 6.12 Code Generation Subsystem. ........................ 60 6.13 General application parameters’ user interface file in XCode. ..... 61 7.1 Fire effect using a particle systems. .................... 63 7.2 Adding a sprite to an object. ........................ 66 7.3 Linked Cell method. ............................ 67 8.1 The different tabs of the palette, from left to right: the objects tab, the edition tab, and the triggers and actions tab. ............ 72 8.2 Special pop up elements used for selecting complex attributes. From left to right: an animation picker and a collision picker. ......... 73 8.3 Special pop up elements used for selecting complex attributes. From left to right: a color picker and an image picker. ............. 73 8.4 GUI functionality for scaling and rotating objects in LevelHelper (left),