Archive for March, 2010
FREE TODAY – Battle for Vesta
by john on Mar.25, 2010, under Uncategorized
Battle for Vesta is free today thanks to FreeAppADay.com. Go grab it for cheap, and then tell your friends.
Battle for Vesta Icon
by john on Mar.22, 2010, under Uncategorized
My brother Matt came up with a new icon for Battle for Vesta. This one is so far superior to the other two that I’ve had. I think it captures the essence of the game about as well as is possible in 512×512 pixels. It clearly indicates that this is a space battle game, that you’re getting attacked, and that the game is 3d. Plus it uses one of the ships from the game as well as colors from the game. Now the game will look even better on your phone.
In other Vesta news, I’ve submitted the 2.1 update to the App Store, so it should be live in a couple of days. There are a few bug fixes and other nice little things and one big thing: a new weapon. The new weapon is a smart laser. It will seek out and try to hit the enemy ship that is currently highlighted on the radar. You charge it by collecting crystals, so you don’t have unlimited shots with it. Also, you have to unlock it by beating the game. Once you’ve unlocked it it will fire one smart laser at a time. Beat the game again on a harder difficultly level and you’ll be able to fire more smart lasers at a time, up to five. I’m quite pleased with how they fly. It is a little bit like the rockets in Robotech.
Adding Save Game to Battle for Vesta
by john on Mar.08, 2010, under iPhone
One of the most requested features for Battle for Vesta is the ability to save a game. This is an entirely reasonable request. Playing the game all the way through can take some time and it is inevitable that you’ll get interrupted by a phone call or some other distraction and find yourself wanting to pick up where you left off.
Also, over the last few updates the game has gotten a lot harder. I find myself getting shot much more frequently and making it through the last few missions is really difficult. Sometime I just want to replay the mission that I just died on rather than start over from scratch.
I started thinking that the retry functionality was the low-hanging fruit and that I should implement it first. Then after some thought it occurred to me that I could kill two birds with one stone. The simplest way to do this was to save the starting conditions at the start of each level and then add a new way of starting the game, a “retry” button. Pressing the retry button would start the game up on the same mission that was last played. So if you die or get interrupted you can always go back to the start of the last mission you were playing.
It turns out that this requires very little code, but it took me a bit of googling to find the bit of the iPhone framework that does what I need. It turns out that there is a persistent dictionary for the iPhone called NSUserDefaults that allows you to store key/value pairs. It also handles persisting them to flash so you don’t even have to worry about the filesystem. So now I have some simple code to save a game in my startLevel() function:
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
[prefs setInteger:level forKey:@"levelKey"];
[prefs setInteger:myLevels.goodRemaining forKey:@"goodRemainignKey"];
[prefs setFloat:shieldPower forKey:@"shieldKey"];
[prefs synchronize];
and some complementary code to pull that information back up when a user hits the retry button:
void retry()
{
gameOver = false;
if (isHit && deathCounter <= 0)
{
isHit = false;
uKills = 0;
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
NSInteger retryLevel = [prefs integerForKey:@"levelKey"];
NSInteger retryGoodRemaining = [prefs integerForKey:@"goodRemainignKey"];
float retryShield = [prefs floatForKey:@"shieldKey"];
if (retryLevel == nil)
{
shieldPower = 6.0f;
level = 1;
energyCollected = 0;
}
else
{
shieldPower = retryShield;
level = (int)retryLevel;
energyCollected = 0;
myLevels.goodRemaining = (int)retryGoodRemaining;
}
startLevel();
}
}
And that's about all it took to add both save and retry to Battle for Vesta. I'll be submitting this update to the App Store today, so you'll be able to use this feature soon.
I should mention that my Googling eventually led me to the the iCode blog which had a helpful walkthrough of how to use NSUserDefaults and which convinced me that it was the correct (and simplest) way to implement what I wanted. However the blog states that the synchronize message is not needed. In my experience it is needed as I tried it without it and it didn't work.