Wednesday, March 30, 2011

Hawken Development

This is what the devs over at http://www.hawkengame.com/blog/ are working on.

OH
MY
GOD

This game emulates reality so well, I almost got motion sickness from watching the video. It makes me tear up seeing how far graphics have advanced. I MEAN COME ON, DYNAMIC SHADING ON THE HUD WHICH BY THE WAY IS EMBEDDED INTO THE MECH, A++ GAME ALREADY.

The only thing that could make this game better would be destructible environment; other than that, this game is insane! I would give everything to work at their studio to work on Hawken.

Collection of Websites for Gamemaking in general

I have here a list of websites that may be use to some game makers out there

This is a list that is un-organized and may not be of use to you, but is good to check out.

Francesco's knick-knacks
http://itaprogaming.free.fr/index.php?x=p&pag=50
desc: This website hosts a Gameboy Advanced SDK. Its cool to check out, i made pong and ended up working on my GBA emu.

Aaron Stebner's Weblog
http://blogs.msdn.com/b/astebner/
desc: This blog by Aaron Stebner contains valuable information about how to do great things in XNA from the mind of a developer.

Blijbol
http://www.blijbol.nl/en
desc: A pretty good Game Maker developer, he has some useful plugins, some-what useful programs, and some games to look at for reference.

Blue Rose Games
http://www.bluerosegames.com/brg/default.aspx
desc: Blue Rose Games has a great beginner tutorial for XNA on 2D and 3D game programming, as well as Silverlight for those interested in MSN games.

Catlin's XNA Blog
http://www.catalinzima.com/
desc: This XNA developer may be average, but has created some interesting blogs about certain techniques in XNA from a beginner's perspective.

Metal Slug Sprites
http://www.metalslugsprites.net/
desc: A sprite site I used when making a Metal Slug remake for Game Maker. Contains most of the sprites seen in-game in .GIF form, as well as some sprite sheets.

RB Whitaker's Wiki
http://rbwhitaker.wikidot.com/xna-tutorials
desc: This is by far my favorite collection of XNA Tutorials; those that make sense the most, and have taught me the basic fundamentals the best.

Riemers XNA Tutorial
http://www.riemers.net/index.php
desc: If you have ever asked:
"How do you program terrain generation like in Worms or Minecraft"
this may answer your question. These are also great beginner tutorials on 2D and 3D game programming in XNA.

Safari Books Online
http://my.safaribooksonline.com/
desc: This website has thousands of e-books available for online view (preview). Ive seen many programming e-books available on this website such as the Mastering Unreal Technology (http://my.safaribooksonline.com/9780768689006) series.

Sprite Database
http://sdb.drshnaps.com/index.php
desc: This is an incredible sprite database. I am currently using it for a metroid remake (no, it's not going so well).

The Video Game Name Generator
http://norefuge.net/vgng/vgng.html
desc: Obligatory video game name generator.

Tile Studio
http://tilestudio.sourceforge.net/
desc: Never used it, but my artist says it is a great tool for creating tile sheets for platformer games. Could also be possibly used in 2D RPG games.

Unreal Development Kit (UDK)
http://udk.com/
desc: The Unreal Development Kit (UDK) is an outstanding developer's kit to allow the developers to get past quite a few walls of development, and can also bring 3D games to life. A very tough tool, but mastering it may be the true start of your indie career. [/viraladvertisement]

XNA Resources
http://www.xnaresources.com/
desc: Yet another website dedicated to starters on XNA.

XNA Tutorial
http://www.xnatutorial.com/
desc: Yet another BLOG dedicated to starters on XNA.

XNAWiki
http://www.xnawiki.com/index.php?title=Main_Page
desc: This is an extremely crucial wiki for those XNA developers. It can be used as a resource guide when programming any game in XNA.

raven67854's Youtube UDK tutorials
http://www.youtube.com/user/raven67854#p/c/0C836EF4FD8D91B8/0/OcJ3J2Yf_Wg
desc: Most guides on the UDK can be confusing and troublesome to the common beginner. This youtube series can be argued as a godsend to those struggling to learn the UDK.

FlatRedBall
http://www.flatredball.com/frb/blog/
desc: FlatRedBall is a great 2D engine used in XNA, and can simplify the process of many 2D games.

Setting up a 2D Game Camera in XNA

I actually took some of the code from a few websites, but this shit was incredibly hard to find, so i put together what worked for me for you guys :3c


The Camera2D class
-----------------------------
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

    public class Camera2d
    {
        protected float _zoom; // Camera Zoom
        public Matrix _transform; // Matrix Transform
        public Vector2 _pos; // Camera Position
        protected float _rotation; // Camera Rotation

        public Camera2d()
        {
            _zoom = 1.0f;
            _rotation = 0.0f;
            _pos = Vector2.Zero;
        }

        // Sets and gets zoom
        public float Zoom
        {
            get { return _zoom; }
            set { _zoom = value; if (_zoom < 0.1f) _zoom = 0.1f; } // Negative zoom will flip image
        }

        public float Rotation
        {
            get { return _rotation; }
            set { _rotation = value; }
        }

        // Auxiliary function to move the camera
        public void Move(Vector2 amount)
        {
            _pos += amount;
        }
        // Get set position
        public Vector2 Pos
        {
            get { return _pos; }
            set { _pos = value; }
        }

        public Matrix get_transformation(GraphicsDevice graphicsDevice)
        {
            _transform =       // Thanks to o KB o for this solution
              Matrix.CreateTranslation(new Vector3(-_pos.X, -_pos.Y, 0)) *
                                         Matrix.CreateRotationZ(Rotation) *
                                         Matrix.CreateScale(new Vector3(Zoom, Zoom, 0)) *
                                         Matrix.CreateTranslation(new Vector3(/*Application Window Width*/ * 0.5f,
/*Application Window Height*/ * 0.5f, 0));
            return _transform;
        }
}

-----------------------------


Then you implement it as follows


-----------------------------
Camera2d camera = new Camera2d();

camera.Pos = //some vector2 that represents a position
camera.zoom = //some float that represents a zoom. anything > 1 will be "zoomed in" and anything < 1 will be "zoomed out"

-----------------------------


Then when you go to call the spritebatch.Begin function, you use the following overload


-----------------------------
spriteBatch.Begin(
                            SpriteSortMode.Immediate,
                            BlendState.AlphaBlend,
                            null,
                            null,
                            null,
                            null,
                            camera.get_transformation(this.GraphicsDevice));

-----------------------------


that should be it :D


NOTE:
Some things like the mouse position from Mouse.GetState() is not relative to the camera, so you have to add some logic like


-----------------------------
mouseLoc = new Vector2(curMouse.X, curMouse.Y) + (camera.Pos - new Vector2(ScreenWidth / 2, ScreenHeight / 2));
-----------------------------


to get the mouse position relative to the camera.

Sunday, March 27, 2011

Optimizing your Game Code: Using Pools

Using pools is a standard technique in game programming. If you ever played a Real-Time Strategy game (RTS) like Starcraft, Halo Wars, Age of Empires, etc.. then you have experienced an "object pool".

In Starcraft, you construct a base, manage an economy, and train military units to tear down the other opponent until either all their buildings are gone, or until they leave. Each unit you train has a designated "food usage", meaning that you may create a unit until you run out of "supply", or your food count is lower than the required food usage. To manage this, you create supply buildings (or in zerg's case, Overlords) to increase your supply. However, you may only have a maximum of 200 food. This is called an object pool.

In Starcraft, you may use a maximum of 200 food. When a unit dies, it no longer uses that food.

You can think of the object pool as an array. You have this array of 10 circles as such:

Circle[] circles = new Circle[10];

Now, say you want to use 3 spots in the array to create 3 circles, so you would type:

for(int x  = 0; x < 3; x++)
{
     circles[x] = new Circle(3.4f); // 3.4f would be the "radius" in this case
}

Now say you wanted more than three, you would simply designate which "empty circle" you want to use to contruct a new one.

circle[6] = new circle(4.2f);

But what if you want to "destroy" one of these circles? Well, when using pools, you don't actually "destroy" an object. You simply just change its properties to make it what you call empty.

circle[3].radius = 0;

Or you can create a boolean variable "IsActive" to let the program know if it is active or not.

circle[3].IsActive = false;

When you have a property like this, you can make a constantly running function that runs through all the objects (circles, in this case), check if it is active, if not, do not use (in video game design, you can tell the engine not to render the "circles" that are inactive)

void CheckCircles()
{
     for(int x = 0; x < circles.length; x++
     {
          if(circles[x].IsActive)
               circles[x].Draw(); //If the circle IS active, then the engine will draw it on the screen
     }
}

The reason why "pooling" is standard practice is because it is an efficient way to handle multiple objects. Why would you want your game to constantly create hundreds, even thousands of objects, and then just get rid of the memory? Why not just re-use those objects? If you have any questions about pooling, please post in the comments.

Sunday, March 6, 2011

Automatically increment revision with each build in Microsoft Visual Studio 2005+

This works in MVS 2005, 2008, 2010, so far what i've tested.

In your project, go into the AssemblyInfo.cs of the project you want to edit, located under:
PROJECT NAME -> Properties -> Assemblyinfo.cs

and change the line:
[assembly: AssemblyVersion("1.0.0.0")] 
 to  
[assembly: AssemblyVersion("1.0.*")]

This will give you a more accurate version number, based on the amount of changes and the amount of builds.

In my earlier post, you can see some made up number i used for my project build in the top left. This is the result after changing the assembly info: