Game Design Archives

Well I managed to fix the problem I was having in my previous post.  This works for both translations in X and Y, and also for camera scale (zoom level).  I haven’t figured out how to include rotation yet but as that isn’t particularly important for what I’m trying to do I’ll let that slide for now.

Assuming you have a 2D camera class that implements a transformation matrix like so:

transform = Matrix.CreateScale(
new Vector3((scale * scale * scale),
(scale * scale * scale), 0))
* Matrix.CreateRotationZ(rotation)
* Matrix.CreateTranslation(new Vector3(
position.X, position.Y, 0));

The world space mouse co-ordinates can be obtained like so:

float mouseWorldX = (mouse.X - camera.Position.X) /
 (float)Math.Pow(camera.Scale, 3);
float mouseWorldY = (mouse.Y - camera.Position.Y) /
 (float)Math.Pow(camera.Scale, 3);

Frustrations with Mouse Co-Ordinates

I’ve actually started working on something.  The last couple of days I have started work on a Map Editor for an undefined game, or game type, hence going against all principles of game design and development.  All that is defined at this stage is that it will be a 2D environment.

The editor allows complete camera control (rotation, translation and zoom) based partly on the Tiled Sprites Sample over at Creators.XNA.Com website.  That all works properly.  I have a collsion grid in place too, and it’s there that I have the problem.

I cannot manage to deduce the co-ordinates of the mouse in world space when positioned over the grid (or indeed any object in the scene).  Viewport.Unproject doesn’t seem to work, and probably isn’t meant to as there are no ‘real’ 3D projection/world matrices in play with this scenario.

Taking into account only translation in X and Y, I can retrieve the co-ordinates just fine, but any change in scale (camera zoom) causes problems.

So work on the editor is now on hold until I can find some help to get this issue resolved.

New Books

I have just ordered 3 books from Amazon which should keep me busy though the year.  Two are pre-orders which are scheduled to be released in the Summer and Autumn, which also helps spread the cost.

XNA 3.0 Game Programming Recipes: A Problem-Solving Approach

XNA 3.0 Game Programming Recipes: A Problem-Solving Approach

XNA 3.0 Game Programming Recipes: A Problem-Solving Approach

RPG Programming with Xna Game Studio 3.0


RPG Programming with Xna Game Studio 3.0

RPG Programming with Xna Game Studio 3.0

Programming an Mmorpg in C# with Xna

Product Description
“Programming an MMORPG in C# with XNA” is an advanced programming book which teaches not only the technical skills required to develop an independent or commercial title, but also the design practices and principles required to turn an idea into a complete multiplayer RPG. This how-to guide introduces the reader to the commonly used design patterns seen in video games, along with some less-commonly known and personal design practices used by the author. While there are many books which teach the reader how to develop the independent components of a game, none cover the entire software engineering process from analysis and design, to implementation and testing, and finally to the end result: a fully-functional and unique MMORPG. An accompanying CD-ROM includes the source code generated throughout the book, as well as helpful free tools including SoftImage|XSI’s Mod Tool for making 3D models and animations, as well as Paint.NET for creating textures.

  
Looking for a reliable WordPress hosting plan? We found the best!