I didn’t post last week because my wife is supposed to be having a baby and things have been hectic. Unfortunately, she is lazy and won’t make the little guy come out so I can meet him. This post is going to be a quick one.

I’ve been working on three things lately:

  • My PHP CMS built on CodeIgniter
  • Whirlygig WP7
  • Android App on MonoDroid for my day job

This is a quick post so I’m only going to talk about Whirlygig right now. Last night I finished almost all of the little details that needed to be done so I can resubmit it. This includes both the mandatory fixes that I needed to implement to pass and a new feature: Dpad-style controls. The biggest playtest complaint about Whirlygig has been the tilt-controls. Mostly because it’s hard to get the hang of tilting and touching the screen to shoot at the same time.

After implementing DPad controls I still personally prefer tilt controls. Dpad works okay but it seems like if your finger stays in contact with the screen for too long it stops detecting it. The controls are way more responsive if you tap on the Dpad instead of sliding your thumb around. I’m not sure if this is a hardware thing or my implementation.

Here’s the code that handles the multi-touch Dpad controls. Please DO NOT take this as a “how to do it” tutorial. I’m pretty sure that this is poorly written. I’m going to do a little bit more research on multitouch controls before submitting.

Let me know if you have suggestions on how to make it suck less!

TouchCollection touchCollection = TouchPanel.GetState();
bool firingAreaPressed = false;

foreach (TouchLocation tl in touchCollection)
{
	if (tl.State == TouchLocationState.Pressed || tl.State == TouchLocationState.Moved)
	{
		float normalizedX = 0;
		float normalizedY = 0;

		if (tl.Position.Y > (480 - DPadSize) && tl.Position.Y < 480)
		{
			// right dPad
			if (tl.Position.X > (800 - DPadSize) && tl.Position.X < 800)
			{
				if (!firingAreaPressed)
				{
					firingAreaPressed = true;

					normalizedX = (((tl.Position.X - (800 - DPadSize)) / DPadSize) * 2f) - 1f;
					normalizedY = (((tl.Position.Y - (480 - DPadSize)) / DPadSize) * 2f) - 1f;

					// set heli face direction
					if (normalizedX >= 0 && Visual.CurrentChainName == "FacingLeft")
					{
						Flip();
					}

					if (normalizedX < 0 && Visual.CurrentChainName == "FacingRight")
					{
						Flip();
					}

					// set fire angle
					mFireAngle = (float)MathFunctions.RegulateAngle(Math.Atan2(-normalizedY, normalizedX));
				}
			}

			// left dPad
			if (tl.Position.X < DPadSize && tl.Position.X > 0)
			{
				normalizedX = ((tl.Position.X / DPadSize) * 2f) - 1f;
				normalizedY = (((tl.Position.Y - (480 - DPadSize)) / DPadSize) * 2f) - 1f;

				XVelocity = normalizedX * (AccelerationRate / 4);
				YVelocity = normalizedY * -(AccelerationRate / 4);
				rotation = (float)(mAccelReading.X * MaxTilt);
			}
		}
	}
}

if (!firingAreaPressed)
{
	StopFiring();
}
else
{
	FireCurrentWeapon();
}