So when i follow the tutorial for putting th level in the game i have no LevelSet, Level, or Tile classes. Do i have to write my Own?
Those classes are in RealmFactoryCore.dll. You just need to add a reference to it in your project. See the Set Up References section in the tutorial for how to do this specifically. These will take care of loading in your levels and such, but most people find that they want to turn the loaded levels into a more sophisticated game state object/class to make them more tailored to the game they're making. So you may need to write your own code, but not LevelSet, Level, or Tile.
Let me know if you have troubles getting the references to work, after looking at the tutorial again. I'd be happy to walk you through it.
Scrolling around is up to you to manage at this point. I intend on adding more features and more power to Realm Factory, but I had to start at a point where it will help the most people, and not everyone is going to want/need scrolling.
But it's actually pretty easy to do. Basically, you can treat the levels you make in Realm Factory as "world coordinates", and simply scale and translate them as needed.
So for example, let's assume that you are making a 2D game. (You could make your levels on the 2D grid in Realm Factory and then draw your game in 3D based on those levels if you wanted. I have an example of that coming, when I make my "game from scratch" tutorial set.)
When you load the level into your game, you get things in terms of rows and columns. You get to decide how to go about drawing those. Assuming they had the same width and height, you could draw this like this:
int cellSize = 40; Vector2 topCorner = new Vector2(200, 0); spriteBatch.Begin(); for (int row = 0; row < level.Rows; row++) { for (int column = 0; column < level.Columns; column++) { Tile tile = (Tile)level.GetTile(row, column); spriteBatch.Draw(tile.Texture, new Rectangle( (int)(cellSize * column + topCorner.X), (int)(cellSize * row + topCorner.Y), cellSize, cellSize), Color.White); } }
If you want to be able to zoom in and out, you might want to make the cellSize an instance variable of your class (up and the top of the class with spriteBatch, etc.) and if you want to allow it to change positions (move around, like you're saying) you'd want the topCorner variable to be an instance variable.
A couple of other things to point out with this… If you have huge levels, you may be able to speed things up by not drawing things that are not visible on the screen. Additionally, with the way I've got that code set up, if you change the scale (new cell size) you'll have to do some extra, slightly fancy math to get it to scale if (0, 0) isn't in the top left corner (which is usually the case). If you want that, and you're having trouble with the math, let me know, and I can give you some code that does that.
Luyanda, I can give it a try. I can definitely give some pointers on where to start, but perhaps you can sort of outline the things you want to accomplish. And… perhaps we can start another thread since it's kind of a separate discussion from this (at least the way I'm understanding your question).
I took the "pacman" map for testing, created a "Level 2" and draw something on it.
At C# I trying to load de 2nd level like this :
currentLevel = levelSet.GetLevel("Level 1").CreateInstance();
nextLevel = levelSet.GetLevel("Level 2").CreateInstance();
I'm taking an error on the line above. (Object reference not set to an instance of an object.)
What's about it ?
Sorry about my poor English. :D
Your general approach seems like it should be working. Make sure that you saved the modified level set (you probably did) and make sure the name in Realm Factory matches what you're asking for. ("Level 2".)
If it wasn't one of those things, I'm not sure what's going wrong. Any chance you could email me your .realm file?
Alternatively, you could change the extension to .xml (it's just an XML file with a custom extension so that you can do file associations) and see if there's anything odd in it.