Monday, January 17, 2011

Obligatory 2011 Update and other such things.

This blog entry will be in THREE parts.

Part I:
The details are still being fleshed out on this "Project" as we figure out our limitations, but I will announce it anyway - after I
Part II:
Introduce myself to you and narrate on what this "Project" is. Which will lead to
Part III:
A quick review of the iPhone4's video capabilities, the Sony Bloggie Touch MHS-TS20, and the Flip UltraHD.

PART I: BrokenKings House!
Broken Kings, Inc. ambitiously started Broken Kings House or BKH for short, this year! It revolves around a relatively straight forward business plan. Make games with the household which consists of the following people:

Stephen as financier and lead programmer,
Lopi as lead designer and programmer,
Josiah as lead artist and audio engineer,
Jenna as artist and lead QA,
and then there's me.

I'm not really sure what my job is called, but I'm guessing it's queen of awesome.

Two weeks in so far and we've finished Skwerl, and just about done Smoothie Operator. Woohoo!

PART II-A: Yours Truly.
Hello, readers of this here blog. My name is Bernadette. I will be reporting on BrokenKings news and other related (or not so related) things here from now on, as well as force Stephen to post more useful iPhoneDev tutorials and relevant business tidbits for you readers. :)

PART II-B: What is BrokenKings House?
BKH is a pretty strange mix of quirkiness, passion, friendship, fun, and work. I say work because it is still a job for all of us, but very unlike any old job out there. It might be presumptuous to say but I think in essence, BKH is that idea which spawns the game industry dream. That awesome "HoMahgawd games are so awesome and fun and great! I wanna make games!" notion that working in the big corporate game industry for a marginal amount of time eats at, until it fizzles and dies. Where's the fun? Where's the creativity? Where's the resonant feeling of playing games with friends in the making of one?

BKH is coming together to find ideas, and working together to create something out of those ideas. That's it. We plan on making a game a weekend and so far, we've concocted some seemingly random ideas which came together into little creations. We videotape the process for posterity (and perhaps the lulz) and maybe we'll look back and laugh at how hard it's been for us and see just how much we've all grown later. We've never worked as a team before this, but it amazes me how far we could push together as a team! Later, I will post about each member of the team for your reading pleasure. ;)

PART III: Filming with iPhone4, Sony Bloggie Touch MHS-TS20, and the Flip UltraHD
We started filming on iPhone4s.
That worked well enough, but we've had problems with the accelerometer, or so I think. The quality is pretty amazing for a cellphone camera when it works like it should, but it's quite a pain when it imports in weird aspect ratios and randomly decides to record in portrait. I'm still learning how to put these videos together, so problems like these are extremely annoying and time consuming. Also according to the team, it's pretty unwieldy with it being too wide and too thin.

We moved on to the Flip UltraHD.
Despite the plasticky feel and painful rate with which it drained 2 AA batteries, it was awesome! The video quality was great, it's comfortably held vertically and records in landscape mode, it did what we needed it to do. Until it decided it didn't want to work for a little while. It would not turn off, would not show up as a device when connected to my MBP, and I had to remove the batteries to shut it down. There were 11 clips in it, but I could only see and play back the 57-second 11th video because it would freeze if I tried to access any other ones. Doing a mass delete without looking at any of the other clips fixed it, but what a waste of perfectly good footage! I figured it was a memory issue. It had no room to think about turning off when it was too full. We decided we needed something with 1. more memory, and 2. rechargeable batteries.

So we went back to the store gunning for a Flip minoHD.
They didn't have one in-stock, and the sales rep suggested Sony Bloggie Touch MHS-TS20 to us.
We got it because it had more memory and an internal rechargeable battery, shoots in perfectly good 720p/60fps, responds better to low light, felt solid to the touch... But I will make another trip to the store tomorrow to exchange it because despite all those good things, whoever designed it forgot that their target market consists of would-be vloggers, likely to post their videos on YouTube. I say this because the camera's tripod mount is at the bottom nearest the red record button. PORTRAIT MODE! Filming in portrait mode means your content only occupies one third of the video box, one narrow stip of footage sandwiched between two, black, rectangular masses. Yay for encouraging failure to utilize the 16:9 aspect ratio of most widescreen video hosting sites! The funny thing though, is it even has a self-timer, to use so that you can be in the pictures and movies, but why did they put the tripod mount for use in portrait mode???
/end rant.

Friday, October 8, 2010

Making Complex Animations with Cocos2D

Cocos2D for iPhone is an excellent game engine for 2D game development on the iPhone platform. One of the strengths of the device is it's many built in actions and node types, as well as it's scheduling system, which allow one to create complex visual effects - be they animations or otherwise. In this post, I will talk about some techniques I have discovered for creating animations and effects in Cocos2D. A companion youtube video was also created as I used some of these techniques to create a first pass on an animation for a real iPhone game in development, currently code named "Furious Tactical". I was working on converting this flash animation into code.


  • Scheduler

  • Color Layer

  • Actions

The Scheduler

In any Cocos2D node that is currently added to a scene, you may schedule and unschedule events. For my animation, I created a separate attack overlay layer that holds the animation, and sits above the game layer. As such, I could schedule and unschedule events right into the layer to control it.

Looking at the flash animation, you can see that there are several steps that must be followed:
1) Attacking unit slides in
2) Attacking unit name appears above it
3) Defending unit slides in
4) Defending unit name appears above it
5) Units able to attack pull back
6) Units able to attack charge at enemy unit
7) An animation/effect plays in front of attack unit
8) Screen shakes and flashes
9) Dead units fly off the screen
10) Surviving units grow and fade out

If I were to rough this out in my layer, I might have code that looks something like this:

-(id) init
if((self = [super init]))
[self schedule:@selector(slideInAttackingUnit:)];
//Store any parameters, create objects, etc.

-(void) slideInAttackingUnit:(ccTime) elapsedTime
[self unschedule:@selector(slideInAttackingUnit:)];

//Do slide code

[self schedule:@selector(attackingUnitNameAppears:) interval:0.5f];


When Cocos2D schedules an event on a node, it will call that event whenever the interval passes. (If no interval is supplied, it will instead call that event every frame). In the case of this animation, we only want each event to happen once, so we unschedule the current method as soon as it is entered and then schedule the following one.

I'm sure that the scheduler is familiar to most Cocos2D developers so I'll move on to the next section.

Color Layer

If you pay close attention to the flash animation, you will see that there is actually a very short white flash when the units collide. You will also notice that there is a bit of a blueish overlay when it first starts running. Both of these can easily be accomplished using a CCColorLayer.

Placing a Color Layer is incredibly simple; you simply initialise it with the colour you want it to be, and add it to your scene, as below:

CCColorLayer *backgroundLayer = [[CCColorLayer alloc] initWithColor:ccc4(128, 128, 255, 100)];
[self addChild:backgroundLayer];
[backgroundLayer release];

I typically use alloc/init instead of the convenience methods where available, just to have a little more control over memory. It's a stylistic choice and except in very tight memory situations, not entirely necessary. By setting the alpha to something less than a full GLByte of 255, it can function is a nice barrier between your current layer and what's behind.

For the white flash, using a ColorLayer in conjunction with the scheduler is quite effective. Consider the following:

-(void) addFlash
flashLayer = [[CCColorLayer alloc] initWithColor:ccc4(255, 255, 255, 255)]; //flashLayer is an instance variable
[self addChild:flashLayer];
[flashChild release];

[self schedule:@selector(removeFlash:) interval:0.05f];

-(void) removeFlash:(ccTime) elapsedTime
[self unschedule:@selector(removeFlash:)];

[self removeChild:flashLayer];
flashLayer = nil; //will be removed from memory - we don't want dangling pointers!

This simply adds and removes a white color layer very quickly to simulate a flash. Simple!


Cocos2D comes with a variety of actions. Ignoring animations, the ones I find myself using most are CCMoveTo/By, CCScaleTo/By, CCRotateTo/By, and CCFadeIn/Out.

The difference in the transform actions, for example CCMoveTo/By, is absolute versus relative. CCMoveTo moves an object to an absolute position; CCMoveBy to a relative position. For those who don't know what that means, the names help make sense of it, but here's a quick example: Imagine that you have an object at position 200, 200. If You were to apply CCMoveTo(100, 100) to it, it would move to 100, 100. Whereas, if you were to apply CCMoveBy(100, 100) to it, it would move to 300, 300.

It is often useful to sequence many actions together to save code; for example, in order to give the unit portriats a bit of a jump back, I use the following code:

leftSprite.position = ccp(-leftSprite.contentSize.width / 2,
leftSprite.contentSize.height / 2);

CCDelayTime *delay = [CCDelayTime actionWithDuration:leftDelay];
CCMoveTo *move1 = [CCMoveTo actionWithDuration:0.23f position:ccp(leftSprite.contentSize.width / 2, leftSprite.contentSize.height / 2)];
CCMoveTo *move2 = [CCMoveTo actionWithDuration:0.02f position:ccp(leftSprite.contentSize.width / 2 - 5, leftSprite.contentSize.height / 2)];
[leftSprite runAction:[CCSequence actions:delay, move1, move2, nil]];

(leftDelay is a value I use to control which of the sprites appears first).

Take note of two things; first, the CCDelayTime at the beginning. This is useful if you want to add a delay to your animation. Next, check out the CCSequence; this allows you to string a bunch of actions together, and they will then happen one after another. CCDelayTime is pretty much only useful when used in conjunction with CCSequence, as it literally does nothing. When you have listed all of your objects, you must ad nil (the sentinel) so that the action knows to expect no more. If you don't do so, you will get the warning, "Missing sentinel in function call".

Tuesday, September 14, 2010

A love of strategy

I love strategy games. If there is one genre of games that my enjoyment of has not diminished at all despite the fact that I play much less games than I used to, that genre is strategy. (The other is Legend of Zelda. That counts as a genre, right?)

My favorite type of strategy games are Tactical games. This is partially born from the fact that I loved RPG's when younger and Tactical RPGs were perfect, combining my love of strategy with my favorite genre. I remember spending hours playing Shining Force and Shining Force 2 - to this day, their formula, despite being very simple, is still my ideal format for how a tactical RPG should be done.

Each tactical game I play inspires me to make one. There are always changes I would make - for example, as "realistic" as it is, I hate character death in Fire Emblem, it's the one factor that ruins the game for me. While I appreciate how carefully it requires you to plan and play, one mistake can cause a healer or mage to be vulnerable in a way you missed - and they often die in one hit, resulting in me resetting game even if I didn't lose.

So when I received the opportunity to make a tactical game for the iPhone, in collaboration with Big Stack Studios with Bella Machina being brought on for the art side of things, I jumped. And, bringing with me the lessons brought forward from Castle Conflict, I designed what I think will be an ideal battle experience for the iPhone.

Due to the way the project is structured, the first release will not feature any campaign - just a bunch of Skirmish Maps (think Red Alert) so that we can test the viability of the game in the market. But it has been designed for the iPhone - to be picked up and played while waiting for the bus, etc. So the gameplay has been streamlined, the interactions made simpler, so that you can have a fast and furious battle in a short period of time. For example, like in Castle Conflict, there are no health bars - in Castle Defense games, I found that they caused the game to result in big messes in the middle with very little tension because they were so slow, and given the short time frame we expect Furious to be played in, we want it to emphasize fast combat.

We're going to be keeping fans updated through forums, youtube, blog posts and facebook as the game develops, so stay tuned for all the details as we work on this bad boy.

In the meantime, Apple has had our update in hand since September 3rd and so I'm hoping will be approving it any day - so keep your eyes peeled for that :)

Sunday, August 29, 2010

Castle Conflict, a bumpy road

This current release of Castle Conflict has been something of a frustrating one.

To be quite frank, when we released Castle Conflict for the first time last year, it was as if something magical happened. We came up with a game idea based off of a game that we had both played before in the past. In a week, we polished it off - like it was nothing - despite the fact that I had never developed anything for the iPhone prior to that point. It just, worked. And it seems that the world knew it - it was featured by Apple and made nearly $20k before sales petered out to about $5 a day, tops.

It took us six months to release an update. It was a surprisingly long time, due to friction in the interim and the idea that we could make another 1-week game in between while our brains sifted through ideas on what to do with Castle Conflict next. That 1-week game took 3 months to make and, to date, has earned us approximately $200. Josiah got a full time job, making it difficult for us to find a period of time to develop the app. But at the end of November, we found the time, and at the beginning of December we submitted something that was closer to our vision of what Castle Conflict could be - the game with campaign mode.

Sales bumped up to about $20 a day, and when Christmas hit, they bumped up to near $50 a day. We still couldn't quit our day jobs (although technically, I had). We had agreed to take some time off from the project before the next update. I spent December doing client work so that I had some money in the bank.

January rolled around and we went for the second most requested feature of Castle Conflict, multiplayer, with a planned second campaign to be released right after. Multiplayer took a long time to develop, and came mostly on my end. It is a largely unused feature in the game compared to campaign and we could have released a campaign map or two in the time it took me to make it, had we known how little use it would get. People still complain that they can never find people online to play with them, despite the fact that it is local-only multiplayer, meaning you can only challenge people via bluetooth or on the same wifi network as you.

As soon as the dust had cleared and that update was submitted, we geared it up a notch, making our Egypt campaign. This was expected to take a week, due to the fact that we had our campaign code all written in November, but it ended up taking two. During these two weeks, I literally got up at 8 or 9 every day and worked from then until I went to bed at 11 or 12. The addition of new units and new unit skins basically broke the game and I learned more about memory fixing it than I ever expected to know. Since then, however, I have been much smarter with understanding memory on the iPhone and how it works.

Simultaneously to this very stressful, yet creatively charged two week period, I was putting the full financial force of Broken Kings behind the project, believing that with the new campaigns and multiplayer, the game was poised to take off the way it had when featured by Apple the year before. That we had found a game that could be a sustainable business and could continue to develop for in the future. A week or two a month could yield a new update every month, our fan base would grow, the game would allow us to develop games full time.

I spent over $7k on an advertising campaign. By this point, this was almost all that was left in the Broken Kings bank account. But so sure were we of the game that we did it anyways.

February 22nd, our ad campaign went live, on all the large websites for iPhone games and large websites for iPhone apps we could find and afford. We had paid for ads from a well known artist, knowing that Josiah's pixel-art style wouldn't draw in as many customers and that we didn't know advertising that well, so having a pro help us out couldn't help.

It boosted our sales by about $15 a day the day it went live. We can't even be sure how much of that was the ad campaign because our sales tended to fluctuate within at $20 range on a per-day basis. A few days later, Apple featured us, but only in the "What We're Playing" section. This free publicity boosted our sales by $30 a day. We never cracked the top 200. We were emotionally, physically, creatively, and financially exhausted when I was approached by Free App A Day and given the chance to put Castle Conflict up for a discounted price. I agreed, and this worked - we made about $3000 in the next two months after the app went free. This went to paying 2009's taxes.

Agreeing to take a break from the project for a while, Josiah continued working and got involved in some musical projects. I started taking on consulting work, working on various projects including an iPad port of a game by a local company (The funds from that also went to taxes), an iPhone app that has yet to be released and I have yet to be paid for, then some consulting for a UK-based company that took up the end of April, all of May, and first few weeks of June. It put money in the bank, but I had made a commitment to a game studio in town that I would make a game for them this summer, for money and a small percentage. So as soon as the UK app was finished, I has to immediately put time into this new project (which is still ongoing).

Josiah and I did plan and start the new update in April, however, with the intention of working on it on a weekly basis. That didn't last through the UK app, due to the client having a very intense deadline that we worked like mad to reach. Various other dramas and events in my personal life made it difficult for me to want to work on code after work hours. But the original plan (which has since been reshaped) was that the game I was working on locally would be complete July 31st. I even paid my roommate (who made Shiftmaze last year) to help me out that month. For a variety of reasons, the app has not yet been released and is still in development, partially due to my own over-ambition, partially due to some differences in the way that the company I am working for operates versus the way I operate on Castle Conflict. Josiah is only available full time for two days every other week, due to commitments both to his full-time job and his band. So we've never quite found the magical, creatively-charged week or two week period that we had in the previous updates. A lot of the work, we don't even do at the same time. I work when he's at work and he works on weekends.

Yet pressure continued to mount, with reviews coming in every day from fans wanting the update, which escalated eventually to fans demanding an update, so we have been putting this update together every chance we get. But it has been nearly 4 months that we have been working on it on and off now, when before we were able to work on it for two weeks and be good. And we've ended up cutting out a fair amount of what we planned in order to get this update out faster - our original plan involved having about 50 new levels and 23 new unit types this update, but we've cut it down to a typical campaign of 20 levels and 10 new unit types, simply to get it out on time, and because we're finding it hard to find the time we'd need to put in in order to pull off a lot of the wizardry we were hoping to pull off.

Yet, despite all this work in the past year, Castle Conflict has only made about another $9K. Of that $9K, $8K went towards advertising and about $2K went towards paying Josiah. In short, despite the bulk of the game having been created since Apple featured us hardcore last year, we haven't been able to capitalise on the promise of our initial launch. As much as we both would love this game to make us enough money that we could put more time into it, would love to release a new update on a monthly or bi-monthly basis, the need to eat makes this tricky.

I have a decent amount of money in the bank account, enough for me to live for a few months, although that lessens if I try to pay an artist full time. Nonetheless, after this release and the release of the game I'm making for the local company, I will be looking into a plan for how to develop better in the future. Because I truly believe that communication with our audience, and a stream of new content, can lead to a successful iPhone app business. I have ideas I've talked with a few people that we want to get out there in the app store, and I'd love to bring the audience along, be able to bring these ideas to fruition faster and be more open with the audience. The past few months, I have failed on this front due to the stress related to money and client work - whereas, earlier this year I was able to put a lot into it. (Look at the Multiplayer update of Castle Conflict - it added the "next update" preview feature and the survey, and I was constantly posting youtube videos about the current progress of the app). I'd like to get back there.

This update, we still believe will be good, if not everything we hoped it to be. But I'm going to look at it as a launching point. Besides, we already have ideas for the next update.

Thursday, July 8, 2010

Quiet does not mean dead

So, the original CC plans of having the next update done by the end of the May never quite went to fruition. Back to back projects had lead to my having very little development time free for the project. The project I am on now is scheduled to end July 31st, and it is another game I am being paid to make for a company in my town of Calgary. The games current name is Furious Tactics and it basically takes my love of tactical games and lessons I've learned from Castle Conflict (both design wise and code wise) and merges the two into what will be one amazing tactical game. I am working with the talented Sean Dunkley on art; he may be better known to anyone who has played Sally's Spa, although he has worked on many other projects (check out his webpage to see some of what he has done). So if you are missing out on CC battles, watch out for Furious Tactics (working name) which should be out soon!

I have no projects scheduled in August as of yet and am in a financial situation where I should actually be able to keep it that way. So while it is a bit delayed from what I would have liked, as soon as the client work is done and I'm not concerned with deadlines on other projects, CC is my first priority. Josiah and I have already spoken and are planning to be able to get the game done as quickly as possible come August.

After that, my roommate, Lopi, and I have been talking about spending some time working on a couple app ideas he and I have been batting around for some time. My goal, building a company, is to be able to work on client projects less and games/apps released under my own company more often. Financial realities don't always allow this to be the case, and I love the act of doing the work, for clients or for myself, so I'm not unhappy doing client work. But in terms of going where I want to go in life, I'm hoping to be able to take projects like Castle Conflict and build on them more often :)

Saturday, May 22, 2010

Castle Conflict Update

Unfortunately, the current Castle Conflict update its taking longer than expected. There is one reason for this: Castle Conflict does not make us enough money to live off of. For this reason, we are unable to make it priority over things that actually make us money.

The original intent had been to work on it all this month and release it at the end. And we're still aiming for that deadline, but it may be more difficult to reach. Most of the art assets have already been created, but almost none of the code for the new campaign has been implemented. This is because I, the programmer, have been doing client work, and the current client work has taken up almost literally all of my available time. Things there have just wound down, so after a day or two to recover, the update will be making forward progress again.

The new update will feature a 3rd campaign, in what we dub the "Endless Forest".

Wednesday, April 14, 2010

The value of experiences

I don't like "distractions" or "time killers".

We all get one life, of variable length. I'm going to ignore religion, rebirth, and all those other theories and say that the only thing that is universally accepted by all humans is that we are born, and eventually we die, and what happens after that is mysterious.

The thing is that we are born into this amazing, wonderful world. I don't have to believe in some higher deity to realise that the world out there is full of wonder and miraculous things. In the natural world alone, there is so much to be experienced, and mankind has been quite prolific in their own right.

I find the concept of free time hard to understand, and the same of boredom. There are so many things to do in life that are so fulfilling, that I can't understand being bored and looking for something to do to kill time. When I'm not working, there are a ton of other things I like to do - learn guitar, go for bike rides, cook, spend time with my household. And when I actually "relax", even that is as a break from all the other things I want to do, and there are so many wonderful books, so much wonderful music, and even a good movie or tv show here or there.

In short, there are so many wonderful things to do in life that most days I don't even get to do everything I want. Or even close. And I'm constantly getting ideas for new things I would like to add to my busy schedule. Like, boy, I would love to make such and such game. I would love to read such and such book. I would love to bike to such and such location. I would love to learn how to play such and such instrument. I get ideas for things to do faster than I can do them.

So to me, any hold on my attention is precious. There are so many amazing things that I could be doing, why would I do something mediocre, just to kill time? I'd rather be expanding time!

I like to think that I bring this philosophy into my creative output. I never want to make something that just keeps you occupied. I never want to make something that doesn't challenge. I view everything I work on as competing with all of the amazing things that people could be doing instead, and I don't want to disappoint.

Yet strangely, these types of experiences, these "just floating by" experiences are more numerous than they've ever been. Facebook and Twitter makes it easier for us to believe that all of our friends are interested in all the mundane aspects of our lives. TV not only forces us to make do with "whatever is on", but it attempts to brainwash us into wanting more and more of these mundane experiences. The iPhone app store is awash with people making an app with the first idea that came into their head and pumping it out as quickly as possible, in the hopes that something serendipitous will happen and they will get rich.

Everybody has a voice, but most people don't seem to have anything interesting to say.

Society, especially the whole "Western" society, has reached a point where less and less time is dedicated to staying alive. We have this amazing world to experience, where we can create things that really challenge people, make them think, and have lasting impacts. We have the time to do and experience the world like we never have before in history. But we seem to have this force called "boredom" imposing on our life, that drives us to seek the easiest source of minor entertainment.

Every moment someone spends inside of a game I make is a moment that they could have been doing something else with their life. I want to make sure that it is worth the tradeoff.