Xbox LIVE Indie Games
Sort Discussions: Previous Discussion Next Discussion
Page 1 of 1 (4 posts)

Microsoft's XNA Platformer Starer Kit Level Editor? A != a, B != b, C != c...

Last post 11/15/2016 7:51 AM by Curtis Turner. 3 replies.
  • 2/3/2016 6:02 AM

    Microsoft's XNA Platformer Starer Kit Level Editor? A != a, B != b, C != c...

    https://bitbucket.org/FinalMirage/xna-platformer-level-editor

    I checked out this level editor, but it's having an issue displaying X versus x. It shows the difference on the grid, but not where you select the current texture...

    Do you have a solution or an alternative? You may have heard of Super Mario Maker by Nintendo. A level editor in game would be nice, instead of the usual outside WinForms or what have you in practically every game engine you see these days (Source, Unity, Unreal, etc).
  • 2/3/2016 5:58 PM In reply to

    Re: Microsoft's XNA Platformer Starer Kit Level Editor? A != a, B != b, C != c...

    Curtis Turner:
    ... it's having an issue displaying X versus x.
    Could it be because X and x are two different things? Case sensitivity matters.
  • 2/4/2016 3:47 AM In reply to

    Re: Microsoft's XNA Platformer Starer Kit Level Editor? A != a, B != b, C != c...

    In game editors are nice but they immediately start forcing all sorts of compromises.

    Billy the Kidney Bean uses Tiled's TMX files.
    It uses two background, two FG, a collision layer, an objects layer,  & parallax rear layers are done separately.

    That would be very tough for your users IN-GAME so you would have to greatly simplify it.

    The IN-game editor will force all sorts of limitations on your design if you don't plan it out.

    External editors are much more flexible and intuitive.

    EJS
  • 11/15/2016 7:51 AM In reply to

    Re: Microsoft's XNA Platformer Starer Kit Level Editor? A != a, B != b, C != c...

            private void LoadAllTextures() 
            { 
                //Check to make sure the directory assigned exists. 
                if (!Directory.Exists(pathToContentFolder)) 
                { 
                    //If the path to the Content folder doesn't exist, let the User know. 
                    MessageBox.Show(String.Format("The {0} directory does not exist. Please check that 'pathToContentFolder' is correctly assigned.", pathToContentFolder)); 
     
                    //There's no need to continue if we have the wrong folder, so just close the application. 
                    Close(); 
                } 
                 
                //For all tiles we have in the game, let's load their textures! 
                foreach (char c in CharactersDictionary.Keys) 
                { 
                    //Make sure the image exists before we load it! 
                    if (!File.Exists(pathToContentFolder + CharactersDictionary[c])) 
                    { 
                        //Blank tiles (.) are null because they don't have a texture, so skip them 
                        if (CharactersDictionary[c] != null
                        { 
                            //If it doesn't exist, let the User know so they can change it! 
                            MessageBox.Show(String.Format( 
                                "The file path for tile '{0}' does not exist. You tried to load {1}. Make sure 'pathToContentFolder' and the path for tile '{0}' in CharactersDictionary are correctly assigned."
                                c, 
                                pathToContentFolder + CharactersDictionary[c])); 
     
                            //Close the application so they can change change it to the correct value. 
                            Close(); 
                        } 
                    }  
                    tileDictionary.Add(c, GetTileTexture(c)); 
     
                    //Load an image so we can show a preview of it in our texture list view 
                    Image image = GetTileImage(c); 
     
                    if (image != null
                    { 
                        //Here we have to work some magic since _most_ of our players/enemies are in the 
                        //form of spritesheets instead of a single image. What we want to do is get the 
                        //first frame of the image and use that for our image. We use our List of PlayerAndEnemyChars 
                        //in the Tile.cs class to find out if we're dealing with a player/enemy image. 
                        if (AnimatedSpriteChars.Contains(c)) 
                        { 
                            System.Drawing.Bitmap original = new System.Drawing.Bitmap(image); 
                            System.Drawing.Rectangle srcRect = new System.Drawing.Rectangle(0, 0, image.Height, image.Height); 
                            image = (Image)original.Clone(srcRect, original.PixelFormat); 
                        } 
     
                        //Add it to our image list which we use to draw each texture in the texture list view 
                        imageList.Images.Add(c.ToString(), image); 
                    } 
     
                    ListViewItem item = new ListViewItem(c.ToString(), imageList.Images.IndexOfKey(c.ToString())); 
     
                    //And finally, add it to our list of textures to show up in the texture list view 
                    textureListView.Items.Add(item); 
                } 
            } 
     
            private Image GetTileImage(char tileType) 
            { 
                Image image = null
                string filePathFromContentDirectory = CharactersDictionary[tileType]; 
     
                if (!string.IsNullOrEmpty(filePathFromContentDirectory)) 
                { 
                    //Open a new stream so we can load the image 
                    using (Stream stream = File.OpenRead(pathToContentFolder + filePathFromContentDirectory)) 
                        image = Image.FromStream(stream); 
                } 
     
                return image; 
            } 
            private Texture2D GetTileTexture(char tileType) 
            { 
                Texture2D texture = null
                string filePathFromContentDirectory = CharactersDictionary[tileType]; 
     
                if (!string.IsNullOrEmpty(filePathFromContentDirectory)) 
                { 
                    //Open a new stream so we can load the texture 
                    using (Stream stream = File.OpenRead(pathToContentFolder + filePathFromContentDirectory)) 
                        texture = Texture2D.FromStream(GraphicsDevice, stream); 
                } 
     
                return texture; 
            } 
Page 1 of 1 (4 posts) Previous Discussion Next Discussion