Big Bad World of Exercise: Implementation Design

From EQUIS Lab Wiki

Jump to: navigation, search


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

Contents

Overall project

This is a view of different classes in BBWoE:

7fe0a844.jpg

The next points will introduce contains of this classes.


MotherClass

For the moment this class is useless, just for editing screen resolution. But the idea is to keep this class to add easily further fonctions.

BBWoE

The main class of BBWoE project. In this class call loading function in LoadContent() method, update data in Update() loop and call object to draw in Draw() loop.

CurrentEntities

This class has to keep all object and there palette to draw in memory.

CurrentPhysicsProperties and BackgroundTextures

CurrentPhysicsProperties will store all the physics properties of the current place, It's the same thing for BackgroundTextures, the feedback of an other texturing should be using to differentiate physics properties like gravity.

GameEntity

This class is generic class of an object, or an avatar.

Other *Entity classes

This is all object of the world, with generic definition to be easily reuse or adapt to the context. You have just to call <name>Entity(<param1>,<param2>,...), add this object to the Contains. See object hierarchy part for more details.

Avatar

This is a generic class of the already implemented avatar: Monocycle and tank. See object hierarchy part for more details.

Other classes

Camera 2D

Manage camera gesture, zoom, and other properties relatives of the view (object is in the camera's field...)

InputControl

Manage all key, pad, and ipower event, change values of global variables in the avatar file.

InputHelper

Manage input for change camera properties, this file will probably be delete, it depend if we want a control of the camera by the user, and if the user prefer that too.

XMLReader

A class to easily create a world using a XML file.

Focus on the object hierarchy

This is a view of the objects classes:

161f5d57.jpg

GameEntity

This class is a generic class that contains generic approach for each object: a position, a size, a mass ... The applyPower() method should move easily an object using the avatar and his use function.

The avatar

The avatar class is an specific class inherit from GameEntity. So the main difference is a orientation of the avatar. This orientation as type of enum Orientation : Up,Down,Left,Right. The camera will track the object call Shape1 include in our avatar.

MonocycleEntity & TankEntity

Real implementation of each avatar: Loading of bodies, textures, and geometric in LoadContent() Drawing of this bodies in the Draw() method.

* Entity

Each <objectName>Entity class is use implement object: Loading of bodies, textures, and geometric in LoadContent() Drawing of this bodies in the Draw() method.

Like the avatar entities, the difference between two objects can be important. For the moment the most complex (unique) is the BeltEntity. But i have to add lot of objects.

Focus on the loading phase

Before the game is able to run, the program have to load. More the project progress, more this phase have to be complex. It's the reason why i try to describe how does it works. Like the first diagram, the first class to be call when the game start is BBWoE (MotherClass is useless for the moment).

This diagram try to present the BBWoE classes from a loading point of view. He as to be read from up to down:

5aa56823.jpg

The BBWoE diagram call BackgroundTextures class to have a list of possible background. Next, BBWoE create an instance of CurrentGame. This class will use a class call Palette to have a texture name for each name of object. It's the call of an Avatar class (tankEntity, MonoCycleEntity, or ToyzCarEntity) by CurrentGame who start the real loading of object. This will LoadContent of the object. The last step for CurrentGame is calling of ReaderXML to load all the other game object. After that, all the LoadContent() method have been initialize, the game can start to run.

Focus on GameEntities properties

This properties are sum up in level.xml. For exemple, this is a GroundEntity:
<ground
id="1" (int, range: [1,oo[)
texture="box" (string)
friction="0.8" (float, range: ]0,+oo[)
restitution="0.1" (float, range: ]0,+oo[)
mass="100" (int, range: ]0,+oo[)
angle="1" (float, range: ]-oo,+oo[, but between ]-Pi,Pi[ is enough)
heightWidth="new Vector2(1000, 100)" (string, with int between ]-oo,+oo[)/> startPos="new Vector2(-960, -700)" (string, with int between ]-oo,+oo[)
achievement="false" (bool)
gravityless="true"> (bool)
</ground>

  • Note: You can write the vector2 with this shorter format: heightWidth="1000,100"

All the gameEntities use this Entry format for the moment (except BeltEntity), Probably in the next days I should add 2 other properties for each GameEntity: IsUsable():bool; and IsEntrable():bool The Id property is just use for make easily de difference between two object.
<belt
id="1"
texture="belt"
friction="0.8"
restitution="0.1"
mass="100"
angle="0"
size="150"
startPos="new Vector2(4400, -500)"
achievement="false"
speed="100">
</belt>
For the belt i should add a second texture parameter.

How the avatars works ?

Each avatar have been created by an assembly of different bodies. Some bodies as implemented as Geom in to add collision detection (see Farseer Physics manual for more informations).

Even if this picture use olds avatar sprites, all the physics still true.

A picture to illustrate a body view of each avatar:
avatardetails.png
About the legend:
Motion: Wheels where the torque force is apply when you pedaling.
Rotate: When you press a rotate button, the torque force is apply on this body.
Collision: Theses objects have a listener to check if something is in contact (for detect object to use for example).
StackBack: This body (call UpBody) is use to detect when the avatar is stack after a Big Bad Jump.

Note: Even if the sprites of the Unicycle and the Beetle have been changed, the objects for the physics engine didn't change at all. So this picture still completely true at the end of the project, like others parts.