iTunes University

I am going to try to do the “iPad and iPhone App Development (Fall 2011)” course from Stanford. I think it might be useful to learn the basic of iOS, up to now I mostly learned as I want. Let’s see how it goes :)

Also the new iTunes University iPad app is not bad.

Unity resources subfolders

You can use resources folder in unity to load assets from scripts (unity script references).

You can create resources folder anywhere in your project, but you can also create subfolder in your resources folder allowing you to keep a cleaner folder structure.

For example we have the following subfolder structure:

We can use the following code to load our level data text file:

TextAsset levelData = (TextAsset) Resources.Load("LevelData/Level1") as TextAsset;

Using the gizmo feature in Unity

From the Unity script reference for gizmos:

  • Gizmos are used to give visual debugging or setup aids in the scene view.

In our current game for example, the heroes movement are limited to a 2d grid that need to be placed in the scene.  Using gizmos we can visualize our grid in the scene and make sure it’s aligned correctly with the world.


Click the picture to see a video of this in use

Continue reading to see some of the code

FancyBox + JQuery

Well I learned how to use FancyBox in wordpress, that also required me to do a crash course in JQuery. Kind of not what I was expecting to do today, but at least I learned something :) I will try to do a post latter today that show all our 2011 gamejams games and maybe a quick tutorial of what I learned.

Playing Shadow complex

I started playing Shadow Complex again yesterday night, I forgot how easy it was to get into. Maybe I will be able to finish it today :)

Test source code highlighting

Testing a plugin to display source code better in a post

Some C# code:

	HeroBaseScript _Hero = null;
	public HeroBaseScript Hero
	{
		get
		{
			return _Hero;
		}
		set
		{
			//TODO: if 	_Hero != null do something?
			_Hero = value;
		}
	}

You can collapse the code:

public class HeroGridCell
{
	public int[] Index = {0,0};
	public Vector3 WorldPosition = Vector3.zero;

	HeroBaseScript _Hero = null;
	public HeroBaseScript Hero
	{
		get
		{
			return _Hero;
		}
		set
		{
			//TODO: if 	_Hero != null do something?
			_Hero = value;
		}
	}

	public static HeroGridCell[,] NewInitHeroGrid(int horizontalCount, int verticalCount, Vector3 topLeftWorldPosition, Vector3 bottomRightWorldPosition, GameObject heroGridGameObject)
	{
		//Allocate the memory
		HeroGridCell[,] HeroGrid = new HeroGridCell[horizontalCount, verticalCount];
		for(int i = 0; i < horizontalCount; i++)
		{
			for(int j = 0; j < verticalCount; j++)
			{
				HeroGrid[i,j] = new HeroGridCell();
			}
		}

		//Fill the array with initial values
		Vector3 horizontalDelta = (bottomRightWorldPosition - topLeftWorldPosition) / (float)horizontalCount;
		horizontalDelta.z = 0.0f;

		Vector3 verticalDelta = (bottomRightWorldPosition - topLeftWorldPosition) / (float)verticalCount;
		verticalDelta.x = 0.0f;

		Vector3 topLeftCenterPosition = topLeftWorldPosition + (horizontalDelta / 2.0f) + (verticalDelta / 2.0f);

		for(int i = 0; i < horizontalCount; i++)
		{
			for(int j = 0; j < verticalCount; j++)
			{
				HeroGridCell gridCell = HeroGrid[i,j];
				gridCell.Index[0] = i;
				gridCell.Index[1] = j;
				gridCell.WorldPosition = topLeftCenterPosition + ((float)i * horizontalDelta) + ((float)j * verticalDelta);
			}
		}

		return HeroGrid;
	}
}