Lessons learned from building Candy Crush for Windows 10 - CFS3007

Lessons learned from building Candy Crush for Windows 10 - CFS3007

Show Video

Hello. Were, welcome to this second. To last session, of Bill 2019. Have, you had a good build. Good. Looking forward to the party tonight. Good. So. My name is yuan, lien for I work. As a computer. Consultant, currently. Focused on building games, the last five, years I had, the great, fortune and, happy. Situation. In helping, a company called Kings I've been a part of a team for. The finalists almost, five years building. A lot of cool, games, on the Windows platform. If. You don't know what King is and who they are they. Are one, of the most famous, casual, or a mobile casual game company, in the world they, have a couple of franchises. That are kind of familiar maybe. Even more familiar than the King brand they have candy crush naturally, their. Pet risky form heroes and the bubble Witch Saga brands, the franchises, they. Actually have more than 200, titles available that you can play all over the world it's both. On the mobile and on the web and not in different platforms naturally and, they're, also hugely, successful when it comes to reaching I have a good strong, fan base like. This first quarter of 2019, they had more than 270. Million monthly, active users that's, a huge fan base a lot of people playing the games and, actually. Met. A couple of people this during, lunch and they asked what I'm gonna present about and I talked about that counter crush and they. Said so are you gonna tell us how to get, rid of the Start menu icon, or the Start menu tile on widows then I'm not, gonna do that because it's supposed to be there. Being. Pre-installed, it's a very good thing actually but. Also King. Was acquired by Activision, Blizzard for a couple of years ago as well so they are part. Of a huge. Gaming. Community. In gaming company. So. During these five, years. We. Have done. A couple. Of games for the windows 10 platform, we, have also not. Just released the games we do usually, like try to do bi-weekly, updates, bi-weekly meaning every, other week not. Twice a week every. Other week we do updates of these games and, and. Also night naturally maintain. The games new. Features, test. Stuff on Windows try to make your cool, implementations. Leveraging, the windows ecosystem and the windows technologies. And. We also learned a lot of this stuff how, to write games naturally, but, also how. To actually, take leverage of the platform. That Microsoft, provides. For, the universal Windows platform what's. Interesting is that the games that we have built for Windows 10 they are pure, you, do WP, applications. And games so. I'm. Gonna talk about this, as well and I'm going to show you a, huge. Amount of code I think actually I'm not gonna write that much but I'm gonna show you a lot of code and. It's. Almost all of the C++, so I hope that's fine, I also. Was told that I should probably put that in the session title because people, have lost. This. Doesn't, seem to be a lot of C++ content. Build. So let's. Let's keep that up I think. So. We have a couple of lessons that we've learned and some of these lessons you will find are really, common sense it's. Like there's. No big, secret entities. With, these, things but still I'm gonna demonstrate some, of the topics within these lessons, also trying, to get you educated, in how we build games and how we build game engines and such but, also what, you can take with you when you've done when you do Universal, Windows platform applications. So like, actually development, in common so. The first lesson that is kind of important for us is that successful, engines, and I can also say framework. When it comes to apps they, aren't really built they should be refactored.

Meaning. That putting. People, too in, a situation where they're supposed to build the next version, of the framework or the engine that our company is gonna use when we build applications that is bound for failure. Because. You don't want to take the best people that you have and building this framework because they also want to keep. Maintaining the games and such instead, it's much better to build, application, or a game then, refactor. What is really success successful, from that application into. Something that is reusable, for, other applications to use and then try to build sort, of like a an. Engine, based on that. The. Engine. That, we have worked, primarily with it's, a native, it's a it's actually a proprietary, engine is an in-house engine, that has been developed by King it's, called fiction factory this. Is a native C++ engine. With. With kind of kind, of cool focuses, I'm also gonna demonstrate in show and and it's it's, targeted, towards several, platforms. Meaning. That it should also be easy to add additional, platforms. From. From. The from, the architecture, from the design of the engine so. For us to inject, or create the you know about you w P. Version. Of the engine it shouldn't be too hard I mean it wasn't that hard actually I'm, gonna talk, about this as well and we currently support like Android iOS UWP, win32, pure desktop Windows Mac, OS Linux. Html5, 3m scripting and such and. It's a native C++ engine, and it leverages very, specific, platform. Implementations, by, for. Android is actually using Java for. The platform specific, nicole's into Android and j'ni. For, communication. Back and forth between C++, and Java and objective-c, for. IOS and for the win32, desktop. Version of, application. Games using plain. Vanilla C++ and when, we started, building this engine, for actually. We started with Windows Phone 8.1, and, then we went, all the way up to, the stack that we have today we. Actually decided immediately that we wanna go for a native implementation. Not. Going with the c-sharp dotnet, version, or a c-sharp. You people version instead. We went for C++ /cx. But, have lately migrated. Pretty much all of the code that is existing in the engine to C++ flash WinRT is that I'm, gonna talk a bit about that as well the, experience is there, but. Also, was. Interesting for us when we started the program was that this is an engine using OpenGL ES. Calls. For the 2d and 3d rendering, and that. Is something that could be a hurdle, I'm, gonna explain how we solve that as well by. Using third-party. Tools. So. The overall structure of this engine, is actually that we, have some. Initiatives. That we want to make sure that it should be easy to create new games that when we set up a new game team it should be easy to set, up the. Game leverage, the knowledge, and the skills and the technologies, that is available from their engine and all the, earlier. Games, such as such but, there should also be naturally unique, code for the game not just code a game, you should also consists of a lot of resources, like assets like textures.

And Atlases. Models, meshes. Animations. Shaders. And such. So. These these, two buckets. That is pretty much the thing that is unique, for the game so. What comes the engine from that instead well the engine is sort, of like outside. The scope and we have considered this like to be two, buckets actually we have internal, dependencies, which is actually the engine that we've built them sell ourselves there the packages, and systems within fixture factory and then we have third-party, packages, as well our third-party dependencies. Talk. About those as well and, the. Engine then is partitioned. And, separated. From each other in, like. Reusable. Components, you can call them packages, you can call them systems. Or. Just, buckets or whatever and these, are like suggestions, on how you can partition an application you can have a rendering pipeline you, can have like a file system package that handles all the isle. Not. Trying to be dependent, on other packages, such trying to be very very focused. On specific. Purposes, we have texture, management, like storing, textures, and atlases we. Have input handling the application, for bootstrapping, the application, making sure the games making sure that that's efficient, have a strong. And high-performing. Game loop that is both, battery, efficient, resource, efficient but also very high performance, handling. Threads, and such is also naturally important and then we might have a scene graph making, sure that the views, and the the cool effects. Are we gonna do this bar is completely, correctly. Render. These are suggestions, on the internal. Implementation that we have and, then, we also have these, third-party. Packages so third-party. Systems and, like. For win32, we might be using glue and Curl Curl for network traffic. Open, SSL for secure communication, back and forth with servers inside, lab we have Limpy and G's to low dimensions and such but, for. Uwp, we might have different third-party. Packages, or third-party dependencies like, angle. Which I'm gonna talk about later on is one of the most important, one that we are using and, we might instead. Of using Limpy G we might use the internal, API. So that EVP provides in. Our implementation, they. Might be even more performance but it also might be easier, just to make that one. Thing that we also want to do when, we write the. Code for the onion and we write these, platform. Intentions you want to share as much code. As possible between the platforms, so we want to have a little, unique. Platform. Code, as possible, that, is also why it's good for us to be a C++. Implementation, because. We can leverage a lot of the lot, of the stuff that is common but also a lot of the stuff that is running. On other platforms as well. But. This is not actually enough having, these components, because we need to have something that lose this together keeps it together and that is what we could call it the pipeline, or the build Python, or something at that and this, is also something we consider to be like a separate. Bucket itself and, the. Pipeline that we are using and. It's. Based on C make and if you were here this morning listening, to the cross-platform Toto, for C++ they also talked about C make if you're not familiar with C make you're. Gonna have sort of a difficult, time falling along the code here but I try to be as. Explainable. As possible but, the C make is actually a tool that makes. Us not. Have. Stored, project, files and solutions, in the, repository. So instead C make generates, these projects, files for Xcode, and for wishes studio and for what have you actually to and, also helps us build this, these. Systems, of these applications. Very efficiently. But. See make has a lot of parameters you if you want to really, leverage see make and to generate, the wishes to the solution for instance or the univer, Universal Windows, platform version. We, also have to param as Rises we have to send them parameters and specifying, which version of the SDK you want to use and such so, there we also have to have some sort of, configuration. System, on top of this and we are using Python, for. This engine you can, also use we use, something called crawl or K or K R al, which is available on github to. Configure it and in the engine, that I'm gonna show you I actually using PowerShell, instead so I'm using PowerShell, for the configuration, of the, seeming pipeline and. Then we using naturally continuous integration deployment.

Using, Git for version control we using Jenkins for automatic, builds and. Also deployed two, different internals, and external, stores. So. What I've done in preparation for this is actually I've created a sort of a I can't, show you unfortunately. The the preparatory code, that King has instead. Have created, sort of a mimic, or sort of an influence. A fiction. Fiction factory, or something like that we can call it and it's already available a bit late build, slash, build, 2019. - GES. If you want to follow along and you'll get links out afterwards, as well, so. Let, me just, switch over here and, I'll try, to introduce. You to this engine. So, it's available on. Github, slash, github.com. Start, code rocks that game engine sandbox, i'll call it if. You want to clone it you're fine to do that and you can build it as well I try, to be as thorough as possible explaining, on what you need to set up and and the preparations, that you have it, builds with which to 2019. 2017. You. Need. See make. You. My. Yeah you need Python as well installed I should probably write that as well okay. So, what, is this engine. Then, well. When. You clone this repository. You. Will see it structured. In like, it's sort of a it's. Kind of simple it's specifically. If you saw the, remember. The image, I shown you with the game, the resources, the engine the third party packages in the pipeline so. We have the game which is this turn is snake, so, when, I try to learn new languages so such I try to implement snake kind, of rapidly so I've done snake, with this game engine sandbox as well. And. This. Includes. Resources. Which is actually all the assets textures. And audio. And sound such that are common for the game like. Apples. And logos, for splash screens and such it. Also contains, source. Code so, it has common code which, like the game, state, machine, it. Has source. Code like objects, it has source, code line with scenes, which actually are the different views we're going back, and forth between as a game States. We. Also have platform. Specific, implementations, so you can already see how we've structured the code is that we have a common directory which with, the code that is common to all the, platforms that we're going to build and then, we have platform. Limitation in different folders. Like win32, uwp, linux, if we're ever gonna do that as such. Okay. And, then. We. Also have the dependencies. And the dependent system is the engine the, third-party packages and the, pipeline the pipe and in this way being the functions, that I'm gonna call from. The the, PowerShell script, and. Also, have a couple, of platform. Specific, files. Like, the manifest. File that has to be particularly, used in all the uwp, applications. That. A temporary key used for Saints I'm signing the application I'm, gonna talk to inject PI as well later, on. We. Have third-party packages and, this is actually just sub modules of angle, and VC package for this purpose, so. You can use them as well and just use some when you update, to. Get those down and. Then. We have the engine and these, are the packages, that I've currently created, for this purpose of this demonstration so, we have lovak like an application, which is a bootstrapper, we have an application slash -, c XX that. Is actually the old implementation, because, when I talk about migration to be not simply flossman RT we, have a file system package we have a game loop package we, have systems, which are an other another, abstraction, of packages, and then, we have. Utilities. And update us so we have a couple of packages these are some of those that, you can possibly. Use them in in this type of games, and applications. So. Just. For I mentioned. That different, types of partitioning, so the. Application, well let's let's look at the file system package for instance, that. Has this source, code and it's pretty much just the file system but if. You look at the systems. Package, it, actually has, several. Different systems so depending. On what your purpose is and how big your game engine is going to be you can partition reuse, separate.

These Different. Structures differently. And it's just I'm. Gonna separate, this out later on as well but it's just the demonstration, purposes say that I can have these as, separate. Projects, or packages and. It's also interesting because all of these packages, that they're rendering and they will be separate, projects, in Visual Studio and, building. UWP with, vicious dojo and using. C make actually, has some some flaws currently, meaning, that if you have too many projects, in which. The studio were generated, by C make it, takes a long lot, a lot of time to open the project also, it will take a lot of time every, time you open the project because these projects are cached by which Studios is it as win32, projects are so, that's something you have to consider. As well when building these. Okay. And let's. See well go back to you, we. Also have this pipeline, here so, I have already generated. The uwp version, of this project because that takes a bit some. Time but. If I want to generate I. Want. You generate. Or. Yes. This is the demo ghost, if. We want to generate a new project a new solution for uwp, i can use this powershell, script and, just say pass. The flag UWP. Say I'm gonna do a debug and I'll. Do eight generate. Will tell. Simic to generate all the products files based. On the C make configuration. That is available and those are, actually macros, or scripts, that tells which files should be included in the projects is that you, can look at that in the in the source tree as well I've. Already done that so instead I'm gonna do updates. That. Doesn't take too, long but now it has updated the. Project files I can. Go, back to you like wishes do the 2019, may, hit reload, and this. Is the project structure the. Solution, solution structure that has generated for me in, the bottom I have the snake project which is actually the client it's also marked for starting. To debug and. Then I have the engine, in the folder with the application, those packages are interesting, for you WP and I have a third-party package as well and the third party dependencies and.

It's. Actually just angle, which in turn actually has a couple of packages instead. So. I can run this. We. Build it and just, have a small. Splash screen very. Humble and then a. Small. Game, of snake, which, I can play on I can pause it and, I. Can also die, in the game if I if I do it correctly, or wrong actually. What. I've also done for, demonstration. Purpose and also for make it kind. Of more interesting, is if I'm using wishes, to the code I can, just open this folder. In, which the studio code I'm just gonna close these notes and if. Everything, works correctly see make tools I have installed the extension for, wishes, to the code we'll. Just configure, this project, right. Away for win32. So I've configured wishes. To the code be able to build this solution. Or this this game engine and snake game. With. C make so. It the, texts which compile is going to use and it does all the magic that Simic does. I'm. Gonna close. This now, it has generated, everything, everything, worked fine so I can do. F7. Which. Is actually building it now it builds, the game as well. And. When. It's done I. Can. Use wishes. To decode to debug, this, game, and game ending as well. Setting. Breakpoints and, everything that you expected, you with vicious to do code. Here. We go and I just hit ctrl, f5. And. Here we have it in winter the win32 version, is dead it's, it's actually the same. Actually. The same code running with these puffin specific invitations. So. This is the engine, that is available right now and, as. Mentioned you can absolutely, download. It or clone it if you want you I'll. Give you that link once more if you want to check, it out and. I'm. Gonna continue working on it because it's actually a really really fun. One. Thing that we stumbled upon when, we started, doing this port 2 year WP was that vicious dude you have some specific requirements, when. It comes to content for that, has to be packaged. With the application, and, we have something called the resource pipeline, meaning that we also want to take, all the assets that the artists create so we want to make them available for the game in the format. That game can leverage as efficient, as possible we don't want to do. A lot of conversions during, runtime or. We. Want to be as efficient as possible meaning, that we want to generate, the resources. That. Is really. Mentioned. For a specific. Platform so, after, the project, has been generated, we kick off this resource, pipeline that produces, all the resources, that is available for, like uwp or win32 your iOS or something the, problem with that is that see. Make has already produced, the, project, file that we are going to use to build the, project, so. How do we make sure that all of these content, files then are being thrown. Into, the, epics. That we're going to deploy to to the store and make, it because, that is something that has to be in the program file all the resources.

Has To be referenced, in the, project file this, took us a while actually we evaluate. A different option. But I'm gonna share the solution that we went. For and it's, it's, kind of cumbersome, to get. It working properly let's. See. So. What we did was. That I'm, gonna continue, using we should do the code here. If. You're familiar with. You're. Familiar with see, Mike you, have this see, make list of TC for each project that you want to create and here you can specify, the. Dependencies. On top like these packages, that this project, is dependent, upon like the application, in the game loop package, your system then, we can also say that if we are running on a Windows Store. Configuration. If we were trying to build the UW peer we, want to set a specific a, couple of properties, like the name of the game the. Publisher, ID. Like. The version number of the game is such that we want to inject. Into the manifest actually, and. These. Placeholders. Can. Then be in the let's, see in the pipeline. In. The pipeline they. Can be injected. Into. The manifest like. The game package name like. The project, name as such by having. C make. Sorry. Have. You seen make call, a command called configure, file, this, tells the C, make structure that configured, this file the app makes manifest, and put, it in this position is dead and then we can reference that that, file, from, our project, we. Can do the same with, the resources, but in a different perspective, so instead I'm gonna configure a Python, script so. I have also in this folder. A small, Python script, which. Actually has two small. XML. Snippets, and these. Snippets will also be configured by. With, bazi make so at first I configured. This Python script I put, it in a position where I can execute it and then, during, the, pipeline, generation. If. I'm. Configuring. A uwp application, and I'm. Doing a generate, build or update which are the commands that I can do with this I also make sure to call with Python, this, file. That. Will inject, these, XML. Snippets, into, the project, file after. It has been generated, putting. It in a position to, look like this so I'm, going to open it. In. The end here so it actually has injected. Let's. See. Sorry. These, snippets and as you can see they have been now configured, with the snake. Game which is the project, so. What this snippet, does actually it says that it has a target that runs before it starts, compiled, application and. Calls. The resource, of pipeline output or actually the custom resource includes. All the files in the resources now have been produced and configured correctly, and then, links, them as deployment. Content in the project file this. Is really efficient for us because the trolly file is really small it skids rapidly. Inject this code again and it, also helps us when we build application, actually. So. If you want to use that snippet I also put that on exists. So you can just copy that it's like bitly /v s assets, I'm trying to be creative of these names here but that, works you, could take a picture as well when you can type it up what you have to remember is that there's. Two things that you need to fix. And first thing is you, have to figure, out the correct path for, the include, specifying. You have to know where the project is being properly and. Where the resources are and then you have to parse it parse. Them but. Also you have to figure out yourself how to inject, this, logic. Into the generated profile and you can use the code that I provided that, that, Python, Python script it's it's a very naive. Implementation but. Still it's something that is working work. Ok. That. Was the first lesson regarding, engines, and. That was so some. More practical, experiences. Naturally then we comes to that. More code that we think can actually be we, call it common eyes or whatever it we can really, leverage a lot of shared. Common, code not. Just by saying. That we have common code that is available. For all platforms, like. For iOS. Android and Windows but we also might say that for win32. And uwp there are absolutely. More stuff, that is common than between, other platforms and other platform does have sin self, so you can actually structure, these folders. That we have like the UWP win32. Linux. OSX, Android, you can have like an MSFT, folder. For instance that is common code for, both win32. And uwp and just makes me make sure that see make in the scripts you have this also in this this small. Engine actually. Pop. Populate. Or take those codes, as well both, when, it generates win32 and uwp so, it's a highly efficient that so we can very really share code, but. There are stuff that needs to be. Implemented. In a platform specific way like file system I mentioned. Input. Handling threading. Keyboard. Handling web, views or web browsers. Bootstrapping. The application, is different, between the, applications. So. I want to show a couple, of patterns, in, C++, that we've used for.

Separating. Platform. Specific code actually how, we can use this, so. Once again I'm going back to the witch, studio code. Yeah. So. The first one I'm just gonna take. My notes here, the. First is. The. File system, system, in, the engine. So. If I look at the. There's. A header here the. File system is most interesting, it has this, as. Two methods it says get the resource dictionary which actually is there the dictionary, in or, actually the director. It says yeah the the folder. Where the resources, are, packaged. In the application, and. It returns this as a w, string of e string and. Then we also have the load file so. These two methods are these the naive, implementation of, the file system in this purpose and. In. The implementation, I, could, do, this in a CPP file I can, say that okay I'm gonna use. These. If depths or. The. Preprocessor directives, yeah that's right, to. Make, sure that I actually use. Sections. In the code that is included, important. For different limitations and then, once, again I'm going back to to see make and saying. For. This were this one it's in the pipeline. In. The actually. In this functions. So. In this initialize, pipeline, I actually specify, that if you're, doing. Windows. Store. Then. Also make sure to define, you WP and if you're doing if you're not I mean Windows Store but still in a max, of compiler then you do define, win32, is dead and you can do Linux as well and such. Meaning. That the. Implementation all. The, code is actually in the same file if. The sections, are very interesting we, don't really like this I think it's a bit too. It's. Not really clear on what's what's happening is that it's. Actually better in vicious to do but, it, might also be this color buying. A color scheme but this. Is not the way that we really want to do it so, instead we, have a different, set up we could press this use like this, I file which is not that interesting but we have these. Include, folders and we have different, headers, for, different.

Platforms. So. They have a common. Common. Specification. Where with this open, and close and it's, open as well but, then they have this. Get. Method, in which we return. The platform specific, handle. For the file when, we open a file for instance so, we can order yet, for the file, so. You do P is using I storage file and. Win32. Is using a file handle, and. Then the implementation for these are, clean. As well so it's just a specific file for, each specific platform. And. This. Gives a. Better. Structure, I think and also better logic, and seeing what what would. Work for us. In. 32 is similar what, might be interesting. To know is that, the. Structure, that we are using for. Source files and headers this include, and source all. The headers that are posted, are put in the include, director, in all of these packages they. Are also shared or actually actually. Exposed. Externally, for other packages, so if I refer to if I reference, a package like the file system I can, get a handle I can from, the other packages I can include the, headers from the include, directory, make. Sense but, everything, in the comp in the, source. Directory, is private. To that package so that doesn't get shared that this package, specific, implementation. There's, also one other pattern, we've used and that is. For. Let's, see for I. Have. To close them. In. The engine, in the systems, we have this. Texture. Manager. So. You have a texture, manager which actually is a sort of a repository of, textures and. It. Has a, header. It. Has a common, implementation. In. The common directory and then. We have something called well. The texture manager also has a, unique pointer of a texture loader and, the texture loader is also common. In the sense that it has a method called load texture and it has an unique. Point of its implementation. So. This is actually a four were declared declare implementation, class here and then it's just declared there and then we can in the source file, for each implementation like, for uwp in the texture loader we. Just implement, or actually create an instance or a definition, of the, texture, loader implementation. And, then in the, actual. Functions. For the texture loader we, just make sure to forward these calls into, the implementation this. Is also kind of efficient for us because it makes us using, if you have a lot of structure a lot of functions lot of logic maybe, also stuff that it's not just property. Bags being sent back and forth just in the file but we also might have systems, like to have to keep, states we can have an implementation that keeps that state even though it's platform-specific or something like that. Makes. Sense. Some. Heads up when it comes to writing cattle specific hole or sleeper specifically, then in C++, and what, we stumbled upon occasionally. At least I should say and, still. Do occasionally, I should say it's stream handling in C++ it's just a pain and. Specifically, Windows is using utf-16, for encoding and now the platforms are more, familiar with the utf-8. I should say so. This is something that you very early in the project must fix and and get a thorough. Infrastructure. Of handling these conversions, back and forth between strings specifically, if you pass. These strings, between. Common, code and plat, response if ik implementations, then you have to decide which is the common. String. Handler we're, gonna do usually. It's, a, preparatory. String. Class that's. Being used that they capture this but. You for, this purpose in this the engine I'm just using SDV string or that it. Makes sense for the initial. Implementation of Windows 32 and EP. Also. Exception. Handling if you're familiar with the Windows runtime you know that when much that is really. Using. Exceptions. From the Windows, runtime api to say that something has failed and such not just by something has really really, crashed. It. Just doesn't work like open, a file or something they have started doing this try open, and try get five and such but earlier. It was just a lot of exceptions, being thrown so we had a lot of trying catch in our pad for specifi compliment a shion's which, was also something that the engine team didn't, really enjoy, so, we try to remove, this as possible as much as possible.

Exception. Handling is something that you need to be familiar with, specifically. Also when it comes to handling exceptions, in a synchronous code when, you have callbacks, coming back from server. Calls or and background threads as such if something, happens on background threads it's a pain actually so, you have to really, be though. And really be, skilled. In handling this. Synchronization. Marshalling, back and forward and specifically, handling errors. When. It comes to asynchronous, and synchronous, patterns. As well there's. Also something that we have to handle in you using. Wwp since, there are a lot of async. Methods. Like, methods that we expect, to take well it might take more than 50 milliseconds, something they have this async, implement. I. Recall. It. Method. Method, name, so. We, but we also have. To if the, overlay. Over. The. Design is actually tried considering, this to be a synchronous, call but we are doing it a synchronously, we have to handle. This we have to call, this asynchronous, method in a synchronous, way we, have to lock and such and do that with, events, inside so, there's different patterns, we can use there but. What we also. Realize. That we had to do really early, is that we have to be really, thorough in scheduling. Our callbacks. That comes back if you are on a background thread or our UI thread that that, windows using for touch inputs, and like, web browsers, and events from web browser handling on the UI thread you, have to be able to marshal that, call, or those, calls into. The render, thread or the actually the actual game thread the game loops and somehow and, the scheduler, that is available can't, really do that specifically, in the way that we develop. This and the game. Loop that we have so. I'm gonna show you so. Not. A really. Good example of this but it actually shows, the code as well at least how it works I'm, gonna do this in which the studio. And, because. It has been a lot better I should say with C++ minority, with doing. Asynchronous. Calls, and things we used we used to have this parallel or, parallel, pattern library. Library. Tossed pattern library. With. This create tasks create a sync we, had this like a lot of call, chains are being done, but it's not much easier, with coroutines in there. So. I'll just. Change this you to the. The. Bootstrapper. For, window. You know you know you do you WP, we. Have a this page. Which is actually a. Sam'l. Page or a page that that's being leveraged, that we put. Into this core window and then. We maybe this page is being loaded we kick, off, throw. A thread, on the, thread pool we call this the render loop. Actually. It's a function. Called rent loop and we also make sure for, debugging. Purposes you. Can check this code out in. The. Engine as well how we set, the thread name so that in the drop-down, lists, in, vicious to do it will say game thread or UI thread instead, of like entity L or SH thread or something like that it's, much more clearance, and when we did debugging. Seeing how emotionally stuff back it forward. We. Initialize, some, stuff for the, OpenGL, ES, device. And, then. We go into this game loop actually and this is what the, magic. We. Have this game, that's ticks so. Every. Frame. It's just ticks and we. Have a timer, in, the game loop that handles this that it's supposed to take in a specific frame, per second like 60. Is more probably the most usual but, actually configured this game to, don't run on 15, frames per second but otherwise it's just way too fast, so 15 works fine for sneaking. Okay. So. When. We're using this while loop the scheduler, is having a difficult time to, schedule back, stuff, back and forward into this. Game loop or. This wire loop actually. By. Itself so we have to be a bit more. Explicit. So. We have created something called a dispatcher, wrapper. So. In the, utilities.

In, The, source for. Uwp, we have something called the dispatcher, wrapper. And. This. Takes the core dispatcher for the window. Cap. Capture. That or caches, that as a member, and then, we can use like a run async that will cause, this, lambda. To be run. On the UI thread or, we, can also say schedule. This. Buddha or, this function, on the, game thread or the get ready and we have this concurrent, queue, that. We pushes. This lambda into and. Then at the end of the game loop. We. Make sure that before we return, or create, a new frame we, process. All the scheduled functions, that, is leveraged. Actually. That has been submitted. So. In the texture manager oh, sorry. The texture loader for UWP I. Just. Show you even. Though it's not really required with this purpose, so. It can, look like this I do a load texture, I have this get, pixel, data from image async, that, might come back on a background thread or a UI thread based, on where we have to run stuff in WEP. And then. I can. Make sure that everything. That, happens here. Goes. On the game thread just, by scheduling this on the game thread so, it's a lambda that just bet gets put in this concurrent queue and then it's getting run on the proper thread this. Is important, for instance, when we load the textures because when we create the texture and when we load the directly set the pixel texture, that those GL calls the OpenGL, calls has to be made on the same thread otherwise everything will just crash. Okay. Another, lesson learned business. Values and Risa's supersedes. Technical, ones this is something, that we got. To realize, kind of early in the project specifically. When it comes to, OpenGL. And Windows. Platform that we mentioned I mentioned this earlier. Since. We. Are using OpenGL, or Apple II OpenGL, ES for. Rendering and there's no native drivers for uwp we, were like really psyched about hey we're gonna the first thing we're gonna do is we're gonna create like a direct. Explain, instead, for the rendering engine and that will be a super, cool project, like there's. Not a lot of people that can create this type of project. We're gonna learn a lot about that but. We, learned really rapidly thanks, to the help from Microsoft, actually that, there's a project called angle, which Google has created and, it's something it's called, almost native graphic laser engine, which, translates. These OpenGL, ES calls to, the plat for six, and, for, our purpose, it translates. Them into directives, calls, and. This, is variants is used by Google Chrome Ian and Osceola Firefox on running. On Windows so it's a really. Thorough. Done project, it's it's being continuously, developed, and they really want to have a high performer, here and what, we realized kind of rapidly is like there's no reason, whatsoever other, than coolness. To, write this. Rendering. Python on direct sx2, do our own pipeline so instead we just used angle we put that in on Windows Phone and Windows Windows, Windows 10 and it just worked it's, amazingly. Cool technology, actually we were using the Microsoft, fork that. Marshall created early, in the project because. That was actually targeting, WinRT and you know you, uw. As well and, there's some couple of things in the marks of Forks are still available like the DDS loader is not available in Google project and they also have some actually experimental, hololens support we haven't really looked into that as well unfortunately. That has gone stale, since like 2017. Or something we have done a small contribution back, with, C make and such for that but, it's not something we would recommend that we are actually now using, the native, open, and Google. Version instead. Which. Is really cool actually and. That. Works also if you want to check these out these are the links as well I created for, angle if. You want to see how that actually works. Just, kind, of rapidly. We. Can do, that also in missions to do so in, let's. Open a. Small. Class. In the. Game. A common. Game, object called Apple. No. That's, not, we're on Microsoft, conference let's do snake is dead oh, that. Was really bad that was poor me that was really bad but I, have. To do snake sorry. That. Was really bad that, was low, okay. We, have a draw method here. And. Which. Actually when we want to draw this snake, object, it has a sprite, we, pass in a renderers so let's look, at the render because this is everything that the draw method is actually make, sure that we take into consideration the, actual screen dimensions for despite in this because, we can resize.

The Windows back and forth. So. In the systems. In, the engine, in the systems. We. Have. In, the common we actually have the rendering, the. Sprite renderer, so. This is a sprite render, header that, is included, that we, can leverage. Please. Pay attention here, that this is actually. Platform. Common. Code so this is actually code that is transition. Over, all platforms even. Though we have like, specific. Gr. GL, definitions. Of you know unsigned. Integers, and such and if. You look at the implementation. The. Common rendering. This is also. Common. Code so everything here is actually compiled. For all the platforms that is available and, even. Though we are doing this GL, delete buffers, we. Are using the, angle, version by, in the utilities, project, making. Sure to include a, specific wrapper. For UW, P which, in turn actually says you're, gonna use the headers from angle, and the, utility's project which is the wrapper for this have. A dependency. On the angle. Packages. Or the dll's, or the static libraries that we are including, so, that gives us a really nice, and very, simplistic, way of rendering. Stuff, with 2d or 3d and it just works and it works with shaders and, everything. Just worked pretty much it was really really cool. But. Sad that we couldn't do a DirectX, pipeline. So. These third-party, dependencies then, so angle was a pleasure to use but, we do have some third-party dependencies that actually is a pain to use as well. Unfortunately. One of them is Facebook, so, we want to use Facebook for authentication, and to, actually. Make. Sure that we can play the game on different devices and, still, keep the state, of the game where your active in game. Synced. Between that but. There's no official, Facebook SDK for. UWB so. Instead we have to go back to Microsoft and they have something called the win SDK. Win, SDK. FBI, FB. So it's available on that bitly, and. That has like authentication, as dialogues, with. The web views using, actually actually the the JavaScript, API, so. It calls and. But it renders in sam'l, views and such and really really nice and really worked really good for us that, was that was good for us unfortunately when we use this third-party. Open. Source SDK that is not. In sync with what my what Facebook is doing on the back end we. Have had, a couple of issues. Actually, where, Facebook, does a major. Update, without, letting everyone know what's, happening and they, push out new versions of the SDK that, the other game. Platforms, can just use and, we have to like either reverse engineer, or wait for something, that we fixed in this decay or maybe do contributions, ourselves, but it takes a lot of time and and, between, those we. Might, have users that can't authenticate or, they lose this data set and that is a poor experience. What. I've also done is, I, created a C++, WinRT version because this win SDK. Pay it's actually a c++ /cx, windows runtime component, but, there's a winner. T version as well if you want to help me there you just ping. Me or just check. Out the github, repo as, well. There. Are a couple, of others append. Appendices as well like we using limp in G curl open ourselves ad lib I mentioned this angle and. What, we've done is that we have used like VC package occasionally. - maybe. Not include, that in. In. The project but. We pre-built. Some of the libraries that we want to use for for, our, purposes like when. We've used curl or OpenSSL we use VC package to build that for you WP because then we don't have to configure that themselves and clone, that code it's really efficient so we see packages or something that I would really recommend that, if you're interested in C++, and cross-platform, development should. Really look into that package manager, or a library manager. That. Brings us to the, migration we did two c++, slash WinRT, and. And, this, is something that has been really fun actually and really good because can. Occur and his team but which is the with. The done the c++ minority, language. Pre action for Windows runtime they are a super, skill and it's really, open with what, they're doing and transparent, in how they're were they heading as well if, you didn't look at this session yesterday you should really try to look at it afterwards it was a really good C++.

We're Not e 2.0, session. So, what this is actually is actually in standardized, C++. In headers that projects. The Windows runtime that we can use from from. Any, compiler, actually and build these types of applications, it's. Also included in the Windows SDK so it means that it's it's, not something that we have to inject ourselves it actually just works it's really nice when. We did this migration, we actually also, could leverage the coexistence meaning, that we didn't have to migrate all of the packages at one so all the systems we, can take one package and crime we can actually take one file at a time as well because, we can just make. Sure that we use the correct name spaces, which actually mimics a. Represents. The namespaces, that were available in the Windows runtime earlier as well but now with the win or T prefix, instead. And, that gives us a really efficient. Migration, process and that helped us a lot, it should be however aware. That if you're gonna do, migration. And want to co-exist you can't do that if you have a lot of sam'l files with some a compiler or actually, windows runtime, windows, runtime components because, that has that, leverages, IDL, files those. Are that, cost some issues specifically. Identifies, cost issues with C make which is unfortunate, so, we hope I hope that they, will fix, those. Moving. Forward because they are considered. To be very specific and not used for this purpose like sam'l, descriptions, of in generate, win MDS such. So. I. Remember. Just. A short. Hint. On how we did the, migration you, can actually look at this as well yourself, but if you looking at the application, see xx this should be is. It was when I created, it should be a direct, CX. X version, of the application package which is used in C++ minority the, modern version, and so you can reason. Say it ok I want to check what, what, did you have to do with. In. The, GL. Page for instance and then compare, that to. The. Winner TV version. Interesting. Everywhere. And. Then I can see the difference since I had to make like, I included, the winner t namespace, for instance in the winner, t version. There's. Another syntax, we don't use these revenues. To instantiate grids, it's actually just structure and being. Created by runtime. Here so we just we. Don't use these arrows in taxes either use, points instead and. When. We hook up a event handler we, don't use plus equals, revenue instead we just call, the method and passes in this. Structure. Which says which method. We're going to call on, page loaded you. Can look into this as well and there's some some differences, that you may must, be aware of that the platform, object is actually a Windows, Foundation, is. A inspectable. Instead. There's. No these, are fun, these aren't there are no hats in taxes or it's. Called circumflex, I think. Instead. We're passing these as const references. But. You can look into that and. If you want to run it if you, want to use the CX x version the, only thing that you actually have to do is, i'm gonna close these stance again is. In. The, c. Make lists. For. The, engine. So. In this in, this folder I have this. Seeming, list which actually just add sub directories, if, I just do this - C, X X, and, then hit update or, do use the pipeline and update the you, get new WP version again I'm using the old version and, that that should use the CX x version and then you can look, how, that works in the back. Ok. So, that shifts our focus now and talk about native. Features, because. We actually wanted, to use native. Features, of Windows to create native experiences. We when, we try to implement. Stuff that was only available in Windows we notice, that users really liked it we saw increased. Engagement increased. Usage and increased users yourself and that was a good thing but, not only when it comes to features it also comes to us, understanding. The strengths, and weaknesses, of the, different. Features. Of the platform an ecosystem such, as Windows Store when. The store is there that, naturally the the deployer of our our games make, sure that people, can find them as such so we have, to spend a lot of time getting a good, PDP, excellence or the product description page has to be really good we use videos, we register. Hero, banners, and keywords when, you search for games, this. Is really important also what, should you be aware when you try to when, you want to create a new game you should not, you.

Be. Aware of that people, likes, to reserve product, names even though they are trademarked. Meaning. That if you try to reserve, if, you try to reserve your your game that you have the trademark for you. Might have to talk to Microsoft, and get help have, them help you unlock, it because. It's it's yours to keep it such but but it's something that will take a couple, of weeks and. If. You have a launch coming up and you have your late in your submission, then, your you might be up for a treat so, make. Sure they have that set. Up, also. What she might, be aware of and if you don't know it's kind of interesting like the purchases, like in-app, purchases, you can't test those, if you submit, or the, application, as a private, available. Application, you have to be publicly, available to, do purchases, yourself, but. You can hide the application, from search meaning, that users can only find application, if you have a direct link. I. Form. I have four minutes left. Okay. So that's. Something that might you should be aware of also, there's something called the store services REST API this is actually a REST API that Yuki from Python, or Java and there's powershell, commandlets. As well that you can use, unfortunately. Though it requires, a, sure active. Directory which are a bit cumbersome, if you are not using that today you have to get that set up also. You might also be aware that some of the properties, in the submissions. Like for an IEP, in. A purchase they are not exposed, through, these rest api so this. Means that the process are occasionally broken meaning, that if you cry if we want to create a submission or an IEP the first time you create the IEP you have to do that through the UI but. Then you can update the IEP, with, the store services, and this is REST API so you can do batch description, such that helps you, automate. New, new submissions. Change prices create, campaigns. Icons. Descriptions, and such also. Be aware that you. Shoot you when you do as update, a submission, on an, IEP or anything, you, either go for the UI or you go for the script you can't like create, and a submission with the script and then play, around with it in the UI these are actually separate processes, so, you have to choose any, of these and, one of it also. Be aware that the API is capped, meaning, you, can't do a lot of calls at the cemetery specifically, posts, and updates that. It. Takes sometimes you have to implement retry, logic, or sleep logic or something like that make. Sure that you don't spam, the API too much. Another. Lesson this is also one of my favorite quotes with great power comes great responsibility because. You can use some really cool stuff on the Windows platform but. You should also be, not. Too aggressive with this one, thing is the tile updates naturally if you have if, you if your customers, are pinning your application, to the Start menu you can, use tile updates making sure that they are updated. With content, and updated with like cool graphics, or such making, users. Aware of that there are some new, new stuff available in the game or add application, and these, can be pushed from push notifications, no secret it can also be pulled from the tile manifest, over the actually the application manifest you, have a schedule, where you can say the fetch. New version, of the tile, schema. From, this URL and it will fetch, the endowment you can change that schema, than in the cloud and then, you can change with graphics inside you can make that happen without having, to do anything any binary updates, on the application, which is kind of nice you, can also schedule naturally, updates through code and what's. Really cool here, is that, you. Can use something called update tasks this is like a hidden gem on the uwp this, means that there's a background task, available. Called Windows dots, update, tasks that, you can subscribe. To actually create and implement which. Will run. Its logic even. Though the client have never run, the application, when. It gets updated from store when, the application, gets automatically. Updated, from store this. Logic will be run you. Can schedule stuff there you can schedule tighten, up the tail updates ties notifications, you can do toast notifications. You can do really cool stuff but, please. Don't. Be too aggressive, instead. Try to be humble and do, but it's still.

It's Important because if your, application, has been updated, like three or four times and the. Customer has still not played the game or whatever make, sure you do like, a hint hey I want to play the game. Let's. Do this and let's, do a tile update or name a small toast notification, saying here's, a couple of gold bars or something like that there's. Also something called the store services, SDK. Which. Is actually an Microsoft. SDK with, some features. That you can use for, doing notifications. Push notifications, from store, instead, of your own infrastructure. This, is also interesting because then you can use metadata, for the users from store like. Specific. For users. In the store as. Their profile is on on Windows instead of the metadata that you have as a client or your in your infrastructure, you, can do kind of cool stuff there as well be, careful though you can also use this store services SDK for running experiments for a bit testing which is really hot on the game game, development area and, you can do this for logging if you don't have that infrastructure, set up as well so. My. Last slide or last lesson, here is actually I've. Showing, you a couple of. High. High level lessons, learned I also shown you a couple of detailed. Things in C++, and uwp but keep it simple because less, is usually, more our, team that has done this part. Of the engine to do WP, and release all of these games about three people one, project manager and three. Developers actually and, we do, handle. All of these games for, the Windows platform we. Don't want to be too many people because we find that we are better, aligned, when we're just not, that many we. Are kind of we don't we don't want to be bothered with too many meetings and such as well so we are really efficient, when it comes to working so. We can't try to keep our the, efforts that we do as simple as possible and also have like a fun experience is doing that that's, also why we don't want to over do an over architect, stuff we want to make really, fun, and cool games because, that is what we we're interviewing it. These. Are some, of the lessons then that, we've learned, for the last couple of years I, hope. That you have had, a good time listening to this and there's at least some content that is vital. To you as well and please. Share. Your feedback and, also. If you want to tweet me afterwards this is my Twitter, areas, if. You want to have any quite ask any questions I'll be sticking around somewhere, here I just have to get off the stage I guess because there's another other, speaker, coming, with. That have, a good day thank you.

2019-05-10 06:11

Show Video

Comments:

First

Other news