Jump to content

  • Log In with Google      Sign In   
  • Create Account


BlueSin

Member Since 17 Jan 2006
Offline Last Active Dec 26 2013 04:11 PM
-----

Posts I've Made

In Topic: 2D Sorting map tiles into map chunks

26 December 2013 - 04:14 PM

Thanks so much for your tips Postie, I really appreciate it!  Before checking this though I actually was able to get it resolved by modifying the Create Tiles code to this:

// Create map tiles
        private static Map CreateTiles(Map map)
        {
            // The current X position of the map
            float mapX = 0;
            // The current Y position of the map
            float mapY = 0;

            // Traverse chunk rows
            for (int chunkX = 0; chunkX < map.Chunks.Length; chunkX++)
            {
                // Traverse chunk columns
                for (int chunkY = 0; chunkY < map.Chunks[chunkX].Length; chunkY++)
                {
                    // Initialize tile rows
                    map.Chunks[chunkX][chunkY].Tiles = new MapTile[MAP_CHUNK_WIDTH][];

                    // Traverse tile rows
                    for (int tileX = 0; tileX < map.Chunks[chunkX][chunkY].Tiles.Length; tileX++)
                    {
                        // Initialize tile columns
                        map.Chunks[chunkX][chunkY].Tiles[tileX] = new MapTile[MAP_CHUNK_HEIGHT];

                        // Traverse tile columns
                        for (int tileY = 0; tileY < map.Chunks[chunkX][chunkY].Tiles[tileX].Length; tileY++)
                        {
                            int chunkStartX = (int)chunkX * (map.GetTileWidth * MAP_CHUNK_WIDTH);
                            int chunkStartY = (int)chunkY * (map.GetTileHeight * MAP_CHUNK_HEIGHT);

                            // initialize this tile
                            map.Chunks[chunkX][chunkY].Tiles[tileX][tileY] = new MapTile(
                                0, null, new Rectangle(
                                    (int)(chunkStartX + (mapX * map.GetTileWidth)), 
                                    (int)(chunkStartY + (mapY * map.GetTileHeight)),
                                    map.GetTileWidth, map.GetTileHeight
                                    ), 
                                Noise.GetNoise(mapX * 0.1f, mapY * 0.1f, map.GetSeed));

                            // Increase mapY
                            mapY++;
                        }

                        // Increase mapX
                        mapX++;
                        // Reset mapY
                        mapY = 0f;
                    }
                    // Reset mapY
                    mapX = 0f;
                }
            }            

            // Return map
            return map;
        }

I just need to optimize it in this case.  But I fully agree with your advice on using .Length.  However, the map is generated once and once generated it is static.  The map size and chunk size can never be changed, nor will this code block ever run again (unless a new map is created).  Thanks again!


In Topic: Generic Class Questions

30 June 2013 - 10:13 AM

Thanks that helped me understand it a bit better.  Appreciate the help!


In Topic: Map Editor Help

28 June 2013 - 08:10 PM

That is helpful too, but it is lacking on features for what I want to do in the long run.  I think I am going to go with Andy's idea here and create my game project in XNA then create an XNA library for my map editor so that I can trigger that mode as I see fit.  Thanks all!


In Topic: Map Editor Help

28 June 2013 - 11:35 AM

That is true, there is no REAL reason not to make the whole thing in XNA.  Albeit would be a little more work as an editor would require *some* controls at the very least to be partly functional.  The GUI just helps it feel more professional and clean I guess.


In Topic: From start to finish (Questions)

17 January 2006 - 06:16 AM

Okay well, where do I go to learn about programming a very simple tetris type of game or something to start? I mean like I said I am not an uber programmer, but I do have an associates degree in computer programming. Most of the guides I find to program things like a tetris game, wind up losing me on the first couple steps. I guess I could always look around gamedev.net more and find out for myself, was just wondering if you guys had any suggestions.

P.S. - Thanks for the kind words, they will help =P

PARTNERS