BBWoE:developerDocumentation

From EQUIS Lab Wiki

Revision as of 15:36, 15 November 2010 by Ameer (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page is a part of Big Bad World of Exercise project, backtracking.

Contents

Introduction

This section is for helping newer developers in BBWoE project. I create section for describe a specific part of the project most important than others, or a complete "How To" for adding functionality in the game.

How the entities works ?

As you can see on this pages BBWoE use a generic system of entities. Each entity use is own bunch of methods:

  • LoadContent() is for initiate all the content:
    • The spritebatch for drawing objects later
    • Each textures that you need for this entity
    • The origin for align the texture on the body
    • The body (the physics view of your entity) (read [physics] for more details)
    • The geom in some cases (the object use by farseer for detect collisions.
    • Adding of the body or the geom in the simulator (the geom include the body, so add the "bigger" that you can).
    • Adding the event for Enter and Exit method on the object, don't forget to add this event on the components list.
  • Action method will be call when the user press the use button and touch the object at the same time. You have the time and the strength of this action in parameter. You can modify this parameter for each entity in the game directly in CurrentGame.cs -> OnWheelCollision([..]) method.
  • Draw(GameTime gT) method is use for draw the specific entity on the screen. This drawing have to be between a call of spriteBatch.Begin([..]) and a spriteBatch.End(). The SpriteBatch.Begin([..]) contains different parameters:
    • SpriteBlendMode is use for apply different treatment to the transparent part of textures.
    • SpriteSortMode is for modify the order of drawing textures for this specific entity
    • SaveStateMode is for avoid to erase the older textures after each new drawings
    • ((MotherClass)_game).Camera.CameraMatrix is for using the Camera2D class
    • For each entity, you have to add this function for keep descent performance: Camera.ShouldDraw(Sprite, Position, Origin, Angle).

You can override Enter() and Exit() method for add a specific behavior to your entity when an avatar go in or out.

How adding a complete new entity in the game ?

Moving BBWOE from computer to computer

Assuming you're transferring from Eril's computer, you should have the following:

  • BBWOE Server:
    • BBWOE Server itself
    • MySQL Server 5.1
    • bbwoe_entities database contained in MySQL Server 5.1
    • MySQL Connector Net 6.2.3
    • Windows XP or newer
    • Visual Studio 2008
  • BBWOE Client:
    • BBWOE Client itself
    • Windows XP or newer
    • Visual Studio 2008
    • XNA 3.1

Procedure to move:

  • On the computer containing the database, first go to cmd.exe (in Windows 7 on the search bar, type in cmd and it should show up).
  • Here you should have a black command prompt. What you need to do is perform what is referred to as an SQL dump. This will copy the schema and data of the tables of the database into a convenient and portable file.
  • To do this, type in this command:

mysqldump -u(USERNAME) -p(PASSWORD) (DATABASENAME) > (PATH).sql

Anything in and including the brackets is to be replaced with the appropriate data. Typically the USERNAME will be root, and the PASSWORD will be whatever you set it to when you first installed MySQL Server. DATABASENAME is the name of the database that you wish to dump (in this case, bbwoe_entities). PATH is simply the path to where you want to store the dump. Mine was this:

C:\SQLDump\bbwoe_entities.sql

  • Now that you have this file, you can copy and paste, or move, wherever you want just as you would any other file. Remember that this only stores the schema and data of the tables, not the actual database into which it'll be stored.
  • Move the SQL dump to whichever computer you'd like. Make sure MySQL Server 5.1 is also installed and setup according to how you'd like it.
  • To import the database, return to cmd.exe (same way as it was done in the first step) and type in the following command:

mysql -u(USERNAME) -p(PASSWORD) (DATABASENAME) < (PATH).sql

All the same information mentioned in step 3 applies here. Make sure that DATABASE is already created in the MySQL server, since the dump will not create that. PATH is where you stored the dump. Also keep in mind the command here is mysql rather than mysqldump. This is a mistake that I made that cost me quite some time, and I hope that you, my successor, will not also make this mistake. :P

  • Install MySQL Connector Net 6.2.3. This will enable us to connect our MySQL database to Microsoft Visual Studio.
  • Now you can bring the server and client components of the BBWOE program over to this computer. Open the server project.
  • In Microsoft Visual Studio 2008, you need to find your way to "Connect to Database" (may be under a different name in different versions, "Add Data Source" was also another name I've seen). This can be found under the Tools tab.
  • Select MySQL database (this will show up now that the MySQL connector is installed).
  • Enter information, and test connection. Name of the server will probably be localhost, user id will probably be root. When this succeeds, simply select bbwoe_entities from the drop box. Now the program can see the database.
  • You are done! Simply launch the server, and then the client.

Also make sure that JANUS' StreamServer is begun before you start the server/client. Currently the server sends a startup command to it, but you need to make sure it's pointing to the right place. It's a line in the Program.cs class in the server component. Make sure it's referring to a StreamServer.exe that actually exists.

All tiny things that can create big troubles

  • All the entities that i've develop works, but should not support all possibles entry values.

for exemple the BeltEntity don't support different angles value. You have the same problem with the size of entities that you can modify, if a ground entity is too large, you will have a part of the entity invisible on the screen.

  • For the moment BBWoE use colors for appears action on the avatar on object, but we need to change that by choosing better color than green and red, or by finding an other feedback.
  • You can switch beetween avatars by using the start button, we have to create a menu for choosing the avatar before the game start (or an other thing).
  • The XML parser use for BBWoE is not perfect and have to be improve: Lot's of entities uses useless parameters or imperfect names.
  • The using of a 2nd thread for loading the game improve the performance of the online version of the game, however the game still have tiny freez cause by the using of the component list by both of this threads.
  • The server support up to 10 clients at the same time, you can improve this number by simply change numberClient variable in the client AND in the server.
  • Janus is limited to send messages without /n /r , but i need that for keep the house easier to write: I add space in Janus treatment for avoid problems. And i remove space when i receive a massage. The problem is that entities properties can still have space few time.
  • if an XML file fail to be add on the database, check the entities IDs.
  • if an XML file don't want to run, even offline, check XML syntax.
  • Sometimes the physics engine can crash cause by a too high speed (mass to low, force apply too high, etc). For helping with that, you should use the debug mode. The problem is that the debug mode is not include in farseer physics. I try to add it, but comment the lines (lines 152-155 of BBWoE.cs) for don't use-it because it seams to be bug yet.