Thursday, August 11, 2011

Baddies 3–Editor

Showing the game in a PictureBox

The first hurdle when making the game editor with windows forms was getting it to render XNA in a form. For this I used a picture box and followed the tutorial at http://royalexander.wordpress.com/2008/10/09/xna-30-and-winforms-the-easy-way/ The only change I had to do was to make sure the back buffer size of the xna game was the same as the size of the picture box, otherwise weird stretching ensued.


 

Coupling game and form

There is a high coupling between both game and form in the editor, as this is the fastest and cleanest method of working the interaction between both of them. None of the two classes are intended for any reuse or generic use, so it’s the best decision. For this, we just store a reference to each other during the initialization of the program so they are linked, and provide methods to access whatever is needed.


 

Creating a map

Creating a new map is an essential part of the editor. I created a new form that took care of receiving all the necessary information and then launched an event with this data.
This event was caught by the main editor form and then passed on to the game class, where we just create a MapGrid node and add it to the root.


 

Loading a TileSet

To load a new tile set we create a dialog that uses the windows interface to load the required image file with the tileset. If the image is found, we create one TilePictureBox out of each bit of the image that is of tileSize x tileSize size and set it in the appropriate form container, so when the user clicks on one he can use it to draw.
Making a specific class instead of just using a normal picturebox was necessary to make the tiles react to the OnClick event.

2 comments:

  1. For this, we just store a reference to each other during the bingo online initialization of the program so they are linked, and provide methods to access whatever is needed.

    ReplyDelete
  2. I created a new form that took care of receiving all the necessary information and then launched an event with this data.
    This event was caught by the main editor form and then passed on to the game class, where we just create a MapGrid node and add it to the root.
    игровые автоматы





    игровые автоматы

    ReplyDelete