Why Start with AtlasSince I had near to zero experience when I start this project, I need to do some experiments to learn something, I started with this one: create a game window and show a tank in it using atlas, this is a good candidate for experiments for following reasons: LibGDX's TexturePacker has a very smart feature to tackle this type of problem.Since this is a from scratch tutorial, I’ll try to explain how I create the game itself and the game engine underneath, also will talk about some reasons behind the way I chose.This post will focus on the basic skeleton of the game, How I organize the codes and assets, use the libaries to create a minimal runnable game that can load an image and show it on the screen. We’ve setup the environment, got these command line tools to be running: dotnet, paket, fake, now we are gonna use these tools to start development.If the TexturePacker cannot fit all the subimages into a single texture. The CMS prepends the file names with unpredictable letters and numbers, which makes PIXI unable to link the json and spritesheets together, and also the 'relatedmultipacks' value in json are. If it is open when not running the application, it will be closed at the.texturepacker I have been using TexturePacker and Pixi for animations, but now the exported TexturePacker files (multipacked) are stored in a CMS system. What to Cover in this PostTry the Unity Texture Packer tool or HDRP Mask Map Packer to pack the BC6H.Texture is a chunk of memory that holding image data that can be used when drawing sprites.Usually textures are loaded from images files, you can load individual images separately and create textures for each of them, though in most cases, we will use Atlas which is just a bigger images with several smaller images inside, and create textures for each atlas, main reasons for this way: Flexible enough, can experiment with different waysIn 2D game engines, a Sprite usually means a rectangle area that can be drawn on screen, it’s the very basic building block in 2D games. Complex enough, need to some learning to finish Well defined, plenty tutorials and documents around
Texturepacker Not Working Free To UseOriginal AssetsThe original assets are from Top-down Tanks Redux by Kenney Vleugels, which is free to use thanks for the author.It already include atlas version, though the format is not the one used in MonoGame. Ideally done by some automatic way.MonoGame has its own pipeline and tools, I spent a little time to try with it, think it’s not really needed in this stage and might make this tutorial more complex, so not using it yet at the moment. Change image format from PSD to PNG, pack individual images together. You may want to create different version of images for different screen resolution, then you can just create different sets of atlas, and choose proper one at runtime.Here is the atlas been used in the game Tank.png Notes about Asset PipelineSome sort of metadata about the individual images are needed to split them later, the format is different to the tool and library.Also the textures is only part of the assets, in game development, usually artists will create all sort of art assets, such as images, audio, music… It’s usually pass through so called pipelines, for different kinds of processes, e.g. Cleaner asset pipeline, easier to manage, e.g. Performance for texture transfer, all texture need to be transferred from CPU to GPU before they can used for rendering, fewer bigger textures are much faster comparing to many smaller ones, also it take fewer memory in this way.Dll files, which will be used in applications. NET Core, library and application, library will output. Library and Application ProjectsThere are 2 type of projects in. My experience is that I’ll try to slow down feature development a bit at first, get some basic logic, then try to refactor the codes to nicer organization, then add a few more logic, then tweak the structure, try to keep a flexible skeleton, do a few experiments before make big decision, and try not to be too hurry. I think even if the parts are never used in other projects, a clear structure is helpful to produce better code, and can keep my mind clear when working on it.It’s typical for me that I need to tweak the structure a couple times until I feel comfortable with it, since when start working on it, I don’t really understand the problems that I’m solving, and can’t anticipate what issues might meet, and usually I need to do a few iterations to improve the structure. Organization of the CodesWhen start a new project, I often spend some time on the way to organize codes first, normally I’ll try to separate the parts that can be reused in other projects and parts that are mostly relavent to specific project only. GraphicsDevice ) let spriteSheetLoader = new SpriteSheetLoader (this. Initialize () = (* Create the graphic instance *) let spriteBatch = new SpriteBatch (this. Tank.Playground/Tank.Playground.fsproj This is an application project, run fake -t tank.playground.run at project root, or cd to src/Tank.Playground and run dotnet run to run the application Tank.ContentIt’s not possible to mix csharp codes in fsharp project, so I create a very simple csharp project to hold the generated csharp codes and the texture packer library build.fsxType BaseGame = Microsoft.Xna.Framework.Game(* Create a simple record to put graphics related objects together(* The timing here is a bit tricky, can not create graphics manager here* since it need the object itself, but it's not working properly during* initialization, so using an option here.*) let mutable graphicsManager : GraphicsDeviceManager option = NoneLet mutable graphics : Graphics option = NoneLet mutable testSprite : SpriteFrame option = NoneOverride this. Tank.Core/Tank.Core.fsproj This is a library project, it’s quite simple, just list of F# source codes, other projects that it depends on, and packages with paket. Update (gameTime : GameTime ) = base. Initialize ()Override this. IsMouseVisible <- true base. Graphics.SpriteSheet.Sprite (Sprites.TankBody_huge ) base. Load (Tank.Content.Const.Texture ) } (* Create a sprite for tank image *)TestSprite <- Some <| this. Fl studio 1242 regkey reditDraw (gameTime ) Tank.Playground/Program. Graphics.SpriteRender.Draw (testSprite. Graphics.Device.Clear (Color.Black )This. Draw (gameTime : GameTime ) =This.
0 Comments
Leave a Reply. |
AuthorPatrick ArchivesCategories |