2D Game Engine
Total Page:16
File Type:pdf, Size:1020Kb
BeEngine: 2D Game Engine Final University Project Video Games Design and Development Degree, UPC Student: Sunyer Caldú, Guillem Student’s plan from 2019 Director: Díaz García, Jesús Sunyer Caldú, Guillem BeEngine: 2D Game Engine Summary This document contains the description of the development of a C++ game engine named BeEngine, as the final university project. The engine is focused on 2D game development and aims to provide all the necessary components and tools to create and deploy a video game from start to finish. The result is a standalone program that can be executed in any Windows machine, that has the ability to load and manage resources (such as images, scripts, audio, etc.), and allows the user to implement the logic and test the results before generating the final game. This project goes through some of the techniques and the logic behind the modules and tools of this engine, and the process of implementation followed to accomplish the final results. The source code for this project: BeEngine 2D Game Engine, it’s public and under the Creative Commons Attribution-ShareAlike 4.0 International License in the GitHub repository ( W.2 ) BeEngine-2D. The build of the engine and the sample project can be found as a GitHub release at ( W.21 ) BeEngine-2D 1.0 Keywords Game Engine, Video Games, C++, C#, Scripting, GLS L , Physics 1 Sunyer Caldú, Guillem BeEngine: 2D Game Engine License This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. 2 Sunyer Caldú, Guillem BeEngine: 2D Game Engine Index 1. Introduction 5 1.1 Motivation 6 1.2 Problem statement 7 1.3 General objectives 8 1.4 Specific objectives 8 1.5 Project scope 10 2. State of the art 11 2.1 Game Engines 11 2.2 Libraries and Technology 15 2.3 Conclusion 18 3. Project management 20 3.1 Procedure and tools 20 3.1.1 Gantt 20 3.1.2 Github and version control 21 3.2 Validation tools 21 3.3 Swot analysis 23 3.4 Risks and contingency plans 24 3.4.1 Risks during development 24 3.4.2 Risk of the tasks 25 4. Methodology 30 4.1 SCRUM 30 4.2 Tools used for the tracking of the project 31 5. Engine development 33 5.1 Skeleton 33 5.1.1 External libraries 35 5.1.2 Expansion 36 5.2 Editor 37 5.2.1 Editor windows 38 5.3 Resources 42 5.3.1 Meta files 42 5.3.2 Asset / Library 43 5.3.3 File watcher and Asset / Library integrity 43 3 Sunyer Caldú, Guillem BeEngine: 2D Game Engine 5.4 Entity Component System 45 5.4.1 GameObjects and Components 45 5.4.2 Prefabs 45 5.4.3 Scenes 46 5.5 Rendering 47 5.5.1 Debug lines and Gizmos 47 5.5.2 Scene renderers 48 5.5.3 Camera rendering 48 5.6 Scripting 50 5.6.1 Visual Studio Project 51 5.6.2 Mono 52 5.6.3 Script compiling 54 5.6.4. Game Loop 54 5.6.5. Editor references 57 5.7 Physics 58 5.8 Build 60 6. Sample Project 62 6.1 Project development 62 6.2 Learnings 64 7. Conclusions 65 8. Acknowledgments 69 9. Webgraphy 70 4 Sunyer Caldú, Guillem BeEngine: 2D Game Engine 1. Introduction Every good worker that wants to create, build or repair something always has their tools close: a plumber has a wrench; a painter, his brush; a woodcutter, an ax, and an architect, the pencil. Those tools define the work that they do, the process, its limitations, and its strengths. This is true for every discipline, even for game development. If you are mildly interested in the video game world or industry, you have probably heard the word “game engine” somewhere; maybe in a new game release, a game studio’s conference, or a console advertisement. A lot of people have heard of it, but not everybody knows exactly what it is, or which role they play inside the video game industry. A game engine is a software that provides game creators with the necessary set of features to build games quickly and efficiently (we can see an example of a game engine editor on F.1.1). It is a framework for game development that supports and brings together several core areas. You can import art and assets (2D and 3D) from other software, such as Maya or 3s Max or Photoshop; assemble those assets into scenes and environments; add lighting, audio, special effects, physics and animation, interactivity, and gameplay logic; and edit, debug and optimize the content for your target platforms. F.1.1 - The game engine editor for, Godot Engine (W.13). 5 Sunyer Caldú, Guillem BeEngine: 2D Game Engine 1.1 Motivation Since a very young age, I have been very interested in computers, software, and coding, and I also loved to play videogames. The combination of these two interests made me ask the question of how video games were made, and how was it possible to create such things only with a computer. Therefore, I started researching and digging for answers, and rapidly a whole bunch of game engines was now available for me to start playing with. I did not know exactly what I was doing, but it was fun, and it was the closest thing I had ever been to making video games. Still, the way in which game engines were created and worked was unknown to me, it was just like magic that worked under the hood. Through my degree in University, I was very happy to start learning how to code, and how game engines worked on the inside. While learning and creating some basic ones, I always felt that I wanted to experiment more and create something that I could use to build video games, without missing any of the tools or utilities that other widely used pre-existing engines include, having control over all the features, knowing exactly how they work. In addition to that, I have had increasing frustration using standard engines like Unity or Unreal. As they want to please everybody (every platform, and every genre) they end up lacking in some important aspects (such as the barely usable input system from Unity, or the overkill rendering of Unreal for low-end devices). Finally, while working on the last big project of University (W .1 )1, we used the base code of a student's game engine that had a lot of code structure problems, so we had to improve it and add a lot of tools and optimizations to be able to finish the game in time. With all that new experience, I learned a lot about the things that worked and the things that did not, and how to better structure a big program. With all of this in mind, the idea of creating my own game engine from scratch, with proper bases and with all the features I wanted, became a reality with this project. 1 W1. h ttps://project-3-upc-ddv-bcn.github.io/Project3/ 6 Sunyer Caldú, Guillem BeEngine: 2D Game Engine 1.2 Problem statement The process of creating video games is not trivial and can vary widely depending on a lot of factors, like scope, time, budget, etc., and facing such uncertainty, a highly dynamic tool is necessary. Game engines allow all the different roles involved in game development to merge all their efforts into a final peace, and it must make that process as intuitive, fast, and robust as possible. When you start getting into game engines, there are are a lot of already created options that cover different ranges: Unreal Engine for 3D high-end visuals; Unity for 3D and 2D, especially mobile; Game Maker for fast 2D; Godot for 3D and 2D with an open source approach, and many more. These type of engines offer a lot of advantages since everything is already made for you to start working, but they also have some disadvantages. One of the biggest problems is that as they generally try to please every aspect of game development, they end up falling short in a lot of important aspects, which can cause major time loss and frustration. Another drawback is that on some commercial engines the source code is not accessible since it’s completely private, where it is not allowed or possible to inspect or modify, difficulting the development process. Facing these lacks, the only other option available is to create a custom game engine from scratch, built specifically for a project, genre, or view. This project wants to solve the frustrations and problems that come from using generic and bloated engines. It aims to create, a small but complete product, focused on 2D development, with all the tools necessary to build videogames. Instead of trying to please every aspect, it intends to contain a small but fully functional and useful toolset that works as expected. Also, there are a lot of engines that try to be drag-and-drop type (for example, Game Maker), with premade modules that are easy to use, but that at the same time limit the creativity and the options of the developer. This is also something that this project avoids. As a summary, the solution is to create a balanced engine, that has all the necessary working tools to make 2D games, without limiting the creator .