8.9. Game Loop: User Input

Total Page:16

File Type:pdf, Size:1020Kb

8.9. Game Loop: User Input Desarrollo de videojuegos de plataformas en 2D usando Simple DirectMedia Layer Aarón Ojeda Reyes Tutor: Agustín Trujillo Pino Mayo 2017 Agradecimientos A mi tutor, por su supervisión y disponibilidad a lo largo del proyecto. A mis compañeros en esta aventura que ha supuesto finalizar la carrera. Nada hubiera sido igual sin su compañía, bromas y consejos. En especial a Yarilo, David, Yeray y Luis, con los que la relación va más allá de lo académico. No puedo olvidar al resto de amigos fuera de la carrera. Gracias por interesarse por algo que a duras penas entendían y por obligarme a salir de «la cueva» de vez en cuando. A mi madre, a mi padre y a mi hermano, por el inmenso apoyo desinteresado que sólo la familia sabe proporcionar. A Itahisa, cuya paciencia y comprensión durante todo este proceso no han conocido límites. Índice general I Introducción 1 1. Descripción 3 2. Objetivos 5 3. Estructura del documento 7 3.1. Parte I Introdución . .7 3.2. Parte II Framework s2Dp .............................7 3.3. Parte III Editor de niveles S2PEditor ......................8 3.4. Parte IV Conclusiones . .9 4. Planificación 11 5. Estado del arte 15 5.1. Juegos de plataformas . 15 5.2. Herramientas de desarrollo . 17 II Framework s2Dp 23 6. Análisis 25 6.1. Establecimiento de requisitos . 25 6.2. Herramientas de desarrollo . 26 6.3. Determinación del alcance de los juegos . 26 6.3.1. Avance . 26 6.3.2. Estado del jugador . 27 6.3.3. Pantallas . 27 6.3.4. Objetos del juego . 28 6.3.5. Sonido . 29 6.3.6. Controles . 30 i ii ÍNDICE GENERAL 7. Comparativa de herramientas 31 7.1. Instalación y facilidad de uso . 31 7.1.1. C++/ SDL 2.0 . 31 7.1.2. C++ / SFML 2.1 . 37 7.1.3. C# / Monogame . 40 7.1.4. Resumen . 47 7.2. Presencia en la industria . 48 7.2.1. SDL . 48 7.2.2. SFML . 49 7.2.3. MonoGame . 50 7.3. Actividad de la comunidad . 51 7.4. Conclusión . 51 8. Diseño e implementación 53 8.1. Simple DirectMedia Layer (SDL) . 54 8.1.1. Inicialización . 55 8.1.2. Subsistema de video . 55 8.1.3. Subsistema de eventos . 56 8.1.4. Subsistema de timers . 58 8.1.5. Gestión de audio . 58 8.1.6. Finalizar SDL . 59 8.2. Estructura general del juego . 59 8.3. Objetos del juego . 61 8.3.1. Animaciones . 67 8.4. Estados del juego . 70 8.5. Niveles y escenarios . 75 8.6. Data-Driven Design . 79 8.6.1. Ficheros XML . 82 8.6.2. Parser . 86 8.7. Gestión de sonido . 93 8.8. Inicialización del juego . 96 8.9. Game loop: User input . 99 8.10. Game loop: Update . 103 8.10.1. Movimiento . 107 ÍNDICE GENERAL iii 8.10.2. Colisiones . 108 8.11. Game loop: Render . 109 8.12. Salir del juego . 119 8.13. Gestión del tiempo . 120 III Editor de niveles S2PEditor 123 9. Análisis 125 9.1. Casos de uso . 125 9.1.1. Proyectos . 126 9.1.2. Niveles . 129 9.1.3. Juego . 132 9.2. Enfoque del desarrollo . 133 10.Comparativa de bibliotecas GUI 137 10.1. Bibliotecas ligeras . 137 10.1.1. SDL2-widgets . 137 10.1.2. Game Gui . 138 10.1.3. libRocket . 139 10.1.4. Conclusiones . 142 10.2. Qt . 143 10.2.1. Visual Studio Add-in . 144 10.2.2. Usar Qt junto a SDL . 146 11.Diseño e Implementación 149 11.1. Interfaz Gráfica de Usuario . 149 11.2. Estructura de la solución adoptada . 150 11.3. Ventana principal . 154 11.4. Añadidos al framework s2Dp ............................ 155 11.4.1. Parser . 156 11.4.2. EditorState . 157 11.5. Clase EditorController . 159 11.6. SDL y Qt: clase QSDLCanvas . 160 11.6.1. Constructor . 161 11.6.2. Iniciando el editor . 162 iv ÍNDICE GENERAL 11.6.3. Actualización y dibujado . 163 11.6.4. Eventos de entrada . 164 11.6.5. Integración en la ventana principal . 166 12.Desarrollo de un juego con S2PEditor 169 12.1. Empezando . 169 12.2. Niveles . 170 12.3. Tilesets . 172 12.4. Imágenes . 175 12.5. Sonidos . 176 12.6. Backgrounds . 177 12.7. Objetos . 179 12.7.1. Gestor de objetos . 179 12.7.2. Crear un objeto . 180 12.7.3. Ejemplos . 184 12.7.4. Niveles finalizados . 189 12.8. Probar niveles . 193 12.9. Generar juego . 193 IV Conclusiones 195 13.Costes 197 14.Valoración 199 15.Trabajo futuro 201 A. Manual de usuario 203 A.1. Instalación . 203 A.2. Interfaz de usuario . 203 A.3. Distribución . ..
Recommended publications
  • Blotch3d User Manual with Just a Few Lines Code You Can Create Real-Time 3D Apps for Multiple Platforms
    Blotch3D User Manual With just a few lines code you can create real-time 3D apps for multiple platforms. QUICK START INTRODUCTION PROJECT STRUCTURE DEVELOPMENT MAKING 3D MODELS DYNAMICALLY CHANGING A SPRITE’S ORIENTATION AND POSITION MATRIX INTERNALS A SHORT GLOSSARY OF 3D GRAPHICS TERMS TROUBLESHOOTING RIGHTS Quick start (This quick start section is for Windows. See below for other platforms, like Android, etc.) 1. Get the installer for the latest release of MonoGame from http://www.monogame.net/downloads/ and run it. (Do NOT get the current development version nor the NuGet package.) 2. Get the Blotch3D repository zip from https://github.com/Blotch3D/Blotch3D and unzip it. 3. Open the Visual Studio solution file. 4. Build and run the example projects. 5. See IntelliSense comments for reference documentation. Introduction Blotch3D is a C# library that vastly simplifies many of the fundamental tasks in development of 3D applications and games. Examples are provided that show how with just a few lines of code you can… • Load standard file types of 3D models as “sprites” and display and move them in 3D with real- time performance. • Set a model’s material, texture, and how it responds to lighting. • Load textures from standard image files. • Show 2D and in-world (as a texture) text in any font, size, color, etc. at any 2D or 3D position, and make text follow a sprite in 2D or 3D. • Attach sprites to other sprites to create associated structures of sprite trees as large as you want. Child sprite orientation and position is relative to its parent sprite’s orientation and position, and can be changed dynamically.
    [Show full text]
  • GNU/Linux AI & Alife HOWTO
    GNU/Linux AI & Alife HOWTO GNU/Linux AI & Alife HOWTO Table of Contents GNU/Linux AI & Alife HOWTO......................................................................................................................1 by John Eikenberry..................................................................................................................................1 1. Introduction..........................................................................................................................................1 2. Symbolic Systems (GOFAI)................................................................................................................1 3. Connectionism.....................................................................................................................................1 4. Evolutionary Computing......................................................................................................................1 5. Alife & Complex Systems...................................................................................................................1 6. Agents & Robotics...............................................................................................................................1 7. Statistical & Machine Learning...........................................................................................................2 8. Missing & Dead...................................................................................................................................2 1. Introduction.........................................................................................................................................2
    [Show full text]
  • IT Acronyms.Docx
    List of computing and IT abbreviations /.—Slashdot 1GL—First-Generation Programming Language 1NF—First Normal Form 10B2—10BASE-2 10B5—10BASE-5 10B-F—10BASE-F 10B-FB—10BASE-FB 10B-FL—10BASE-FL 10B-FP—10BASE-FP 10B-T—10BASE-T 100B-FX—100BASE-FX 100B-T—100BASE-T 100B-TX—100BASE-TX 100BVG—100BASE-VG 286—Intel 80286 processor 2B1Q—2 Binary 1 Quaternary 2GL—Second-Generation Programming Language 2NF—Second Normal Form 3GL—Third-Generation Programming Language 3NF—Third Normal Form 386—Intel 80386 processor 1 486—Intel 80486 processor 4B5BLF—4 Byte 5 Byte Local Fiber 4GL—Fourth-Generation Programming Language 4NF—Fourth Normal Form 5GL—Fifth-Generation Programming Language 5NF—Fifth Normal Form 6NF—Sixth Normal Form 8B10BLF—8 Byte 10 Byte Local Fiber A AAT—Average Access Time AA—Anti-Aliasing AAA—Authentication Authorization, Accounting AABB—Axis Aligned Bounding Box AAC—Advanced Audio Coding AAL—ATM Adaptation Layer AALC—ATM Adaptation Layer Connection AARP—AppleTalk Address Resolution Protocol ABCL—Actor-Based Concurrent Language ABI—Application Binary Interface ABM—Asynchronous Balanced Mode ABR—Area Border Router ABR—Auto Baud-Rate detection ABR—Available Bitrate 2 ABR—Average Bitrate AC—Acoustic Coupler AC—Alternating Current ACD—Automatic Call Distributor ACE—Advanced Computing Environment ACF NCP—Advanced Communications Function—Network Control Program ACID—Atomicity Consistency Isolation Durability ACK—ACKnowledgement ACK—Amsterdam Compiler Kit ACL—Access Control List ACL—Active Current
    [Show full text]
  • Copyrighted Material
    Index abld build 36 AVRecorder 270 with C 40 abld freeze 226 IDE 32 abort() 74, 400, 402 MFC 214 abstract base class 46 Base Class Library (BCL) Mutex 388–391 active objects 31, 94–99, 237 C classes 53, 79, 85, 87 381 battery 10, 14, 43 C Wrappers 339–340 Active Template Library Bazaar 392–393 CActive 95, 97 (ATL) 134 BCL. See Base Class Library CActiveScheduler Adapter pattern 384 Binary Runtime Environment Add() 95–96 Alerts API 166 for Wireless Start() 141 AllFiles 130, 349, 355 (BREW) 253–254 CAknAppUi 155 Alloc() 64 Blackberry 11, 17–18 calendar 186, 251 ALLOC panic 45–46, 399 bld.inf 35, 36, 38, callbacks 147, 324, 381 AllocL() 64 115–116, 186, camera 165, 185, 253 All-Tcb 117 211, 292, 293, 316 Cancel() 98 Android 11, 12, 17–18, bldmake 36, 211 capabilities 228, 348–355 244–253, Bluetooth 127, 138 Android 369–371 369–371 Boost 107, 197 trusted applications ANSI C++ standardCOPYRIGHTED 386 BREW. See Binary MATERIAL Runtime 362–363 APIs 68–71, 103–131 Environment for untrusted applications applications, portable Wireless 363–364 375–396 CAPABILITY 37, 355 ARM RealView Compilation capitalization guidelines Tools (RVCT) 34, C 21, 28, 40, 103–131, 50–51 112 214 Carbide.c++ 32, 38, 72, ATL See Active Template C++ 21, 28, 31, 50, 59, 147, 211, 214, Library 61–66, 103–131, 368–369 auto_ptr 85, 143, 144 CArray 58 391–392 abstract base class 46 CArrayFixFlat 58 412 INDEX CArrayFixSeg 58 Common Language Runtime DLL. See dynamic link CArrayVarSeg 58 (CLR) 236 library CArrayXSeg 58 compilers 34, 39–40, Document Object Model catch 72 318–322 (DOM) 184 CBase 53, 54, 82, Component Object Model DOM.
    [Show full text]
  • Foreign Library Interface by Daniel Adler Dia Applications That Can Run on a Multitude of Plat- Forms
    30 CONTRIBUTED RESEARCH ARTICLES Foreign Library Interface by Daniel Adler dia applications that can run on a multitude of plat- forms. Abstract We present an improved Foreign Function Interface (FFI) for R to call arbitary na- tive functions without the need for C wrapper Foreign function interfaces code. Further we discuss a dynamic linkage framework for binding standard C libraries to FFIs provide the backbone of a language to inter- R across platforms using a universal type infor- face with foreign code. Depending on the design of mation format. The package rdyncall comprises this service, it can largely unburden developers from the framework and an initial repository of cross- writing additional wrapper code. In this section, we platform bindings for standard libraries such as compare the built-in R FFI with that provided by (legacy and modern) OpenGL, the family of SDL rdyncall. We use a simple example that sketches the libraries and Expat. The package enables system- different work flow paths for making an R binding to level programming using the R language; sam- a function from a foreign C library. ple applications are given in the article. We out- line the underlying automation tool-chain that extracts cross-platform bindings from C headers, FFI of base R making the repository extendable and open for Suppose that we wish to invoke the C function sqrt library developers. of the Standard C Math library. The function is de- clared as follows in C: Introduction double sqrt(double x); We present an improved Foreign Function Interface The .C function from the base R FFI offers a call (FFI) for R that significantly reduces the amount of gate to C code with very strict conversion rules, and C wrapper code needed to interface with C.
    [Show full text]
  • Game-Based Learning
    Game-based Learning Motion-based Educational Game Per Olav Flaten Henrik Reitan Master of Science in Informatics Submission date: June 2016 Supervisor: Alf Inge Wang, IDI Norwegian University of Science and Technology Department of Computer and Information Science Problem Description Title: Game-based Learning Sub-title: Motion-based Educational Game This project focuses on the development, testing and experimentation with motion-based educational games. The games will use body movement as input to provide a natural user interface and will provide learning through gesture based movement. The project consists of a state-of the-art study, prototyping and develop- ment, testing and experimentation with real users, and analysis of the ex- perimental data. The project will utilize technology like Kinect or similar. Assignment given: 13:01.2015 Supervisor: Alf Inge Wang Abstract This master's project is dedicated to investigate the potential for educa- tional games with a motion controller based interface. Through professor Alf Inge Wang at NTNU we were assigned the task of brainstorming and developing a concept that would utilize motion controllers, more speci- cally the Microsoft Kinect, and investigate if it could be useful outside of a traditional game setting. Additionally it was expressed a desire to have em- phasis on reusable software that would benet future projects investigating the same area or using the same technology. Throughout our research period we have discovered several interesting things. We found that although the Kinect failed to gain any traction on its in- tended area of use, it is a very impressive piece of aordable technology that is worth investigating further.
    [Show full text]
  • The Linux Gamers' HOWTO
    The Linux Gamers’ HOWTO Peter Jay Salzman Frédéric Delanoy Copyright © 2001, 2002 Peter Jay Salzman Copyright © 2003, 2004 Peter Jay SalzmanFrédéric Delanoy 2004-11-13 v.1.0.6 Abstract The same questions get asked repeatedly on Linux related mailing lists and news groups. Many of them arise because people don’t know as much as they should about how things "work" on Linux, at least, as far as games go. Gaming can be a tough pursuit; it requires knowledge from an incredibly vast range of topics from compilers to libraries to system administration to networking to XFree86 administration ... you get the picture. Every aspect of your computer plays a role in gaming. It’s a demanding topic, but this fact is shadowed by the primary goal of gaming: to have fun and blow off some steam. This document is a stepping stone to get the most common problems resolved and to give people the knowledge to begin thinking intelligently about what is going on with their games. Just as with anything else on Linux, you need to know a little more about what’s going on behind the scenes with your system to be able to keep your games healthy or to diagnose and fix them when they’re not. 1. Administra If you have ideas, corrections or questions relating to this HOWTO, please email me. By receiving feedback on this howto (even if I don’t have the time to answer), you make me feel like I’m doing something useful. In turn, it motivates me to write more and add to this document.
    [Show full text]
  • Studying and Enabling Reuse in Android Mobile Apps Andrew Steven Holtzhauer College of William & Mary - Arts & Sciences
    W&M ScholarWorks Dissertations, Theses, and Masters Projects Theses, Dissertations, & Master Projects 2014 Studying and Enabling Reuse in android Mobile Apps andrew Steven Holtzhauer College of William & Mary - Arts & Sciences Follow this and additional works at: https://scholarworks.wm.edu/etd Part of the Computer Sciences Commons Recommended Citation Holtzhauer, andrew Steven, "Studying and Enabling Reuse in android Mobile Apps" (2014). Dissertations, Theses, and Masters Projects. Paper 1539626959. https://dx.doi.org/doi:10.21220/s2-0fsx-bc44 This Thesis is brought to you for free and open access by the Theses, Dissertations, & Master Projects at W&M ScholarWorks. It has been accepted for inclusion in Dissertations, Theses, and Masters Projects by an authorized administrator of W&M ScholarWorks. For more information, please contact [email protected]. Studying and Enabling Reuse in Android Mobile Apps Andrew Steven Holtzhauer Stafford, VA Bachelor of Science, College of William and Mary, 2012 A Thesis presented to the Graduate Faculty of the College of William and Mary in Candidacy for the Degree of Master of Science Department of Computer Science The College of William and Mary August 2014 COMPLIANCE PAGE Research approved by Protection of Human Subjects Committee Protocol number(s): PHSC-2013-06-07-8782 Date(s) of approval: 2013-06-14 APPROVAL PAGE This Thesis is submitted in partial fulfillment of the requirements for the degree of Master of Science Andrew Steven Holtzhauer Approved by the Committee, August 20T4 littefe Cfiair Assistant Professor Denys feoshyvanyk, Computer Science The College of William and Mary Associate Professor Peter Kemper, Computer Science The College of William and Mary fessor Collin McM+tfar/Computer Science University of Notre Dame ABSTRACT In the recent years, studies of design and programming practices in mobile development are gaining more attention from researchers.
    [Show full text]
  • Xildoom Final Report
    XilDoom Final Report 18545 Fall 2010 Robert Waaser Shupeng Sun Soo Hwan Kim Summary For our project, we ported the classic 1993 first-person shooter Doom to a Xilinx LX110T Field Programmable Gate Array (FPGA). We chose to use a source port known as Chocolate Doom which uses the Simple DirectMedia Layer (SDL) library to achieve cross-plaorm compability. AXer building a custom computer system on the FPGA that was capable of running the game, we wrote custom drivers for SDL that allowed Chocolate Doom to run on our hardware. The final result was a SystemAce file that could be used to configure an FPGA to run Doom on boot, complete with keyboard input and audio and video output. Networking was also implemented, but not tested before the public demo. Our Project Idea For our capstone we were required to implement a game, a game console, or one of a number of research projects. For the game route, the game had to be complete with audio and video output, some sort of user input, mulWple players, and a way to keep score. Furthermore the game could not be of our own creaon, as the course was not meant to be a course in game programming but rather a course in systems-level design. We took a look at capstone projects from the past three years and noWced that projects that ported soXware games such as Quake and Descent seemed to have a relavely high rate of success. Typically these projects focused less on designing hardware and code from scratch and more on combining and modifying exisWng code and libraries to funcWon in an embedded environment.
    [Show full text]
  • Your Paper's Title Starts Here
    Advances in Computer Science Research, volume 71 4th International Conference on Machinery, Materials and Information Technology Applications (ICMMITA 2016) Design of H.265 Streaming Media Player System Based on QT * Yu-Hua Wu1, a, Min Zhang1, b, Ting Yang1, c, Shi-Jun Lid, 1Jilin Agricultural University, Changchun 130118, Jilin, China [email protected], [email protected], [email protected], [email protected] *Shi-Jun LI Keywords: H.265, streaming media player, FFmpeg, codec. Abstract. With the continuous development of video services, video applications gradually in order to meet the high resolution, high frame rate, high compression development demand, put forward an H.265 streaming media player system based on QT. Under the QT environment, the use of FFmpeg codec library for video file processing, while the use of SDL multimedia displays library combined with multi-thread display video files. Experimental result shows that the player can play a clearly and smoothly H.265 video files, and can support 4K high-quality video playback. 1 Introduction Video data plays an important role in information interaction. According to the research, it is compared with other information, the human brain accepts 70% of the information is from the visual information[1]. However, with the development of mobile terminals and network technology, people's demand for video is growing, according to research shows that the video data will occupy 75% of the mobile data in 2020[2]. In order to provide users with high-quality video information, and reduce the video file data transmission bandwidth, the ITU-T VCEG put forward H.265 standard after H.264 standard.
    [Show full text]
  • Protobuild Documentation Release Latest
    Protobuild Documentation Release latest June Rhodes Aug 24, 2017 General Information 1 User Documentation 3 1.1 Frequently Asked Questions.......................................3 1.2 GitHub..................................................6 1.3 Twitter..................................................6 1.4 Contributing...............................................6 1.5 Getting Started..............................................8 1.6 Getting Started..............................................8 1.7 Defining Application Projects...................................... 11 1.8 Defining Console Projects........................................ 14 1.9 Defining Library Projects........................................ 15 1.10 Defining Content Projects........................................ 16 1.11 Defining Include Projects........................................ 18 1.12 Defining External Projects........................................ 20 1.13 Migrating Existing C# Projects..................................... 24 1.14 Customizing Projects with Properties.................................. 25 1.15 Changing Module Properties....................................... 34 1.16 Including Submodules.......................................... 36 1.17 Package Management with Protobuild.................................. 37 1.18 Package Management with NuGet.................................... 40 1.19 Creating Packages for Protobuild.................................... 42 1.20 Code Signing for iOS.......................................... 46 1.21 Targeting the Web
    [Show full text]
  • How Are Issue Reports Discussed in Gitter Chat Rooms?
    How are issue reports discussed in Gitter chat rooms? Hareem Sahar1, Abram Hindle1, Cor-Paul Bezemer2 University of Alberta Edmonton, Canada Abstract Informal communication channels like mailing lists, IRC and instant messaging play a vital role in open source software development by facilitating communica- tion within geographically diverse project teams e.g., to discuss issue reports to facilitate the bug-fixing process. More recently, chat systems like Slack and Git- ter have gained a lot of popularity and developers are rapidly adopting them. Gitter is a chat system that is specifically designed to address the needs of GitHub users. Gitter hosts project-based asynchronous chats which foster fre- quent project discussions among participants. Developer discussions contain a wealth of information such as the rationale behind decisions made during the evolution of a project. In this study, we explore 24 open source project chat rooms that are hosted on Gitter, containing a total of 3,133,106 messages and 14,096 issue references. We manually analyze the contents of chat room discus- sions around 457 issue reports. The results of our study show the prevalence of issue discussions on Gitter, and that the discussed issue reports have a longer resolution time than the issue reports that are never brought on Gitter. Keywords: developer discussions, Gitter, issue reports Email address: [email protected] (Hareem Sahar ) 1Department of Computing Science, University of Alberta, Canada 2Analytics of Software, Games and Repository Data (ASGAARD) lab, University of Al- berta, Canada Preprint submitted to Journal of Systems and Software October 29, 2020 1. Introduction Open source software (OSS) development uses the expertise of developers from all over the world, who communicate with each other via email, mailing lists [1], IRC channels [2], and modern communication platforms like Gitter 5 and Slack [3].
    [Show full text]