Wednesday 8 February 2012

Terrain, Weather, and more!

So today was a rather unproductive day in the ongoing development of Fathom. I am still trying to figure out the best way to present information in a logical manner, so bear with me here.

The Camera & MousePosition
I utilize a freely available 2D camera class for Fathom. I am still very early in my development, and haven't had the need to add any advanced features, so why reinvent the wheel? One major issue with this camera system lies in it's translation matrix:

Matrix get_transformation()
{
  _transform =
     Matrix.CreateTranslation(new Vector3(-_pos.X, -_pos.Y, 0)) *
     Matrix.CreateRotationZ(Rotation) *
     Matrix.CreateScale(new Vector3(Zoom, Zoom, 1)) *
     Matrix.CreateTranslation(new Vector3(_graphics.Viewport.Width * 0.5f,
          _graphics.Viewport.Height * 0.5f, 0));
    return _transform;
}

As you can see, the last translation in the matrix is shifting the camera to center it in the game window. This will instantaneously your mouse position by half of the width and height of the viewport. To overcome this, and convert the mouse co-ordinates on screen to world coordinates, I used the following function:


public Vector2 MousePOS(Vector2 mp)
{          
    return (mp + new Vector2(this._pos.X - _graphics.Viewport.Width / 2,
               this._pos.Y - _graphics.Viewport.Height / 2));
}

This quick function will ensure that the mouse position is always accurate to the world coordinates and prevent skewing of the relative values.

Weather & Clouds
This feature is very, very rudimentary. Basically, I am generating a list of clouds that move across the game world. They culled when off the screen to avoid additional, unnecessary system resources usage. Eventually, it will support a variety of weather conditions and constantly change. I am still a ways off from that.

Terrain Manipulation
I finally got around to adding two functions to the terrain engine. These allow blocks to be removed and placed at any world coordinate. Obviously, this is nothing new, but it is new to Fathom so I will count it as a feature - for now. I am unsure of whether or not this will become a gameplay mechanic or not. I am not going for a MineCraft or Terraria knockoff here.

Trees
Finally, I added a (very) basic tree generation function. It is nothing worth spending a lot of time on at this point. Eventually I will flesh this out a little more.

Tomorrow I will post an alpha build for you to download and play with.

No comments:

Post a Comment