Game State (Map, Level, Title screen etc.)
Handled by the GameState enum in the main class. All scenes implement the IScene interface:

public interface IScene
    {
        void Initialize();
        void Update(GameTime gametime, KeyStates keys);
        void Draw(GameTime gametime, SpriteBatch renderTo);
        void Debug();
        bool IsDebugging { get; set; }
    } 

Input
Handled by the main class. This will load input settings from file and register keystrokes, then pass them on too Scenes in the KeyStates struct (boolean values indicating what keys are pressed). This means each scene does not need to worry about key settings etc. - it just gets passed the inferred keystrokes.

Graphics
In the current release there are several types of sprites, which get drawn in different ways:
StaticSprite - contains one Texture2D that gets drawn every draw cycle at the sprites location.
Sprite - contains one Texture2D. The current frame is set by the sprite using a Vector2, and cropped in the Draw cycle (uses GraphicsHelper.GetCrop - gets the source rectangle to draw)

The second release contains a third type:

AnimatedSprite - Contains an AnimationPlayer ('GfxPlayer'). The sprite calls 'GfxPlayer.PlayAnimation', which takes an animation parameter and plays it. AnimatedSprite calls GfxPlayer.Draw in its Draw method to render the animation. (AnimationPlayer and Animation are also new)

Sprites
The level contains a 3 lists of sprites:
  • Sprites - This contains all the sprites in the level (even the ones in the other lists).
  • ActiveSprites - These have an Update method, which is called by the LevelScene's Update method.
  • VisibleSprite - These get draw to the screen.

The Tile system is exactly the same, with 3 lists of tiles (Tiles, ActiveTiles and VisibleTiles)

In the Update method, the scene works out which sprites should be in what list based on camera location. (next release)
The SpriteSet<T> class contains an encapsulation of these three lists (also next release)

Sprite Inheritance

Base Types StaticSprite Sprite AnimatedSprite
Inherited Types Tile ?? NPC, Background Object (To be implemented)


Primitive types: (new release) (Will be inherited from NPC. Currently inherited from AnimatedSprite)
  • Faller - an object that supports jumping and falling. It uses the JumpState enum:
public enum JumpState
        {
            Jumping,
            Apex,
            Falling
        } 
  • Collider - Handles collision and raises collision events. (2nd release collision is even worse than the first. :)
  • FallerCollider - Falls and handles collisions (unfinished)
  • FaceCollider - Inherits Collider. Uses a FaceDirection (Left or Right) enum to auto-flip images in the Draw call, and auto-flip movement in the Update call. (Inherited by player)

Player state
The player contains a PlayerState enum to specify current player state (dead, normal, super, fire... ).
It also contains an isInvincible field (bool) and invincible time (float) (new release - thanks to smcgamer for pointing this out)

The player's power-up state can be set from outside through the SetPowerup method. (new release)

(new release) The player contains an IProjectileEngine, for shooting projectiles. The IProjectileEngine exposes AddProjectile and AddUpwardsProjectile. All projectile engines will implement this (FireEngine, HammerEngine etc.). This make sit easy to have several power-ups use one engine (e.g. Ice flower & Penguin suit use IceEngine). No engines have been made yet (I haven't even made the projectiles! :)

 public interface IProjectileEngine
    {
        Player player { get; set; }
        Scenes.IScene owner { get; set; }

        void AddProjectile(int facing);

        void AddUpwardsProjectile(int facing);
    } 


Block data
Block data is (currently) in the Block.dat file and in the following format:

1.1.1.1,16.16,0.1,Block/block1:
0.1.0.0,16.16,0.1,Block/block1:
0.1.0.0,48.48,0.1,Block/block3:
1.1.1.1,16.16,1.1,Block/block4


Collision - l.t.r.b (cast to TileCollision enum) Size (w.h) Gradient (rise.run) Graphics location Next block
1.1.1.1 16.16 0.1 Block/block1 :


Levels
Level data is similar to block data. Example level:

head
|
1,0,-16,176:
1,1,1,192:
1,1,16,176:
1,1,16,192:
1,1,32,192:
1,1,48,192:
1,0,64,192:
1,0,80,192:
1,0,96,192:
1,0,112,192:
1,0,128,192:
1,0,144,192:
1,2,112,144:
1,1,160,192:
1,1,176,192:
1,1,192,192:
1,3,192,176:
1,0,32,128


"head" - layers, events, player start locations etc. (currently not used).
1st "1": Object type (1 = block).
Next number: Object id (1 = block1, 2 = block 2 etc.)
Next two numbers: Location (x, y).

I've also experimented with some networking and demo recording stuff, but there isn't much there currently.

Where to from here?
Make a better debug form and game event logger.
Better collision, including slopes.
NPC Scripting system - I've done some basic work on this.
  • Multiplayer
  • Reading a Keys.xml file for input key settings.

Last edited Nov 9, 2012 at 3:06 AM by fbrookie, version 1

Comments

No comments yet.