From refactor to library

June 30th, 2009

Or how to refactor the code from your last game to build up your reusable libs.

First and foremost, thanks to the people at FGL chat that brainstormed a jolly good topic to write about. This post also helps me to rethink my strategy about an issue I have with our core libs that I’ll hopfully address in the future as soon as I make sense.

Basic question is how do I handle the code I used in the previous game to reuse it… I’ll give several examples of how our core classes appeared or changed hoping that you find something useful for your own code and games.

In the beggining there was music

When we wrote Tech Wars, I had to write a music manager that would know when to change tracks. There are three tracks in Tech Wars, all with the same beats per minute, two share the melody but with different instruments and one has a slight variation of the melody. Each track served a part of the game, such has menus, level, and post-level.

Our current music manager has code from Tech Wars. That code evolved from a game specific class to a generic sound manager class and then to two separate classes: sound manager and music manager. These shifts occured as the next games needed or between projects.

core

What started with Tech Wars is now what we call the core, which is simply a bunch of abstract, cross-project oriented organization of directories and classes that goes from one project to another. It is not something you do, it is something you keep doing, building and evolving. That sound manager class was a bad case of refactoring, but a good start since we had no reusable AS code.

Generalization

To create your libs you should make each class abstract from the game code. This maybe trickier than it sounds. For instance, we have a Scene Manager. What it does is quite simple:

  • ensures that one and only one scene is running
  • ensures that one and only one dialog is running
  • ensures that when a scene is started the current scene and current dialog are closed
  • ensures that when a dialog is started the current dialog is closed

And this has to work in every game. To be sure that it works in every game I made sure that a scene or a dialog is always a movie clip that is linked in the fla library and that I can pass up to five arguments to it. I also made sure that the Scene Manager is a singleton.

Get yourself organized

To be sure that your code is generic, organize it! Create a structure outside your game logic, as an example, when I start a project I copy the core directory from the previous project to the root of the current project and I create a separate directory “game” where all the game specific classes go.

It’s that simple.

Refactoring

Refactoring plays a big role in all of this. Now that the core classes are a few and that most of the nasty work is done, the process of refactoring tunes it and adds to it.

Again… an example. Some hours ago I was using a static method MathKit.AngleBetweenPoints(p1, p2) which is pretty obvious, but for some reason the code did not produce the results I predicted, so I wrote a bit of code to ensure the output I was looking for.

The issue was that MathKit.AngleBetweenPoints(p1,p2) returns an angle in radians and I wanted degrees. I already have two static methods in the MathKit class to convert radians in degrees and vice-versa, so in the next refactoring session I’ll rename MathKit.AngleBetweenPoints to MathKit.RadiansBetweenPoints and create a new DegreesBetweenPoints.

The refactoring will eliminate generic code from game specific code, it will reuse static methods we already have in the MathKit class, make the method already there more intuitive and create an additional method for other uses.

Managers = Singletons

Managers are classes that take care of a specific aspect of your game. Scenes, music, sound and so on. You should be sure that your managers are singletons and that you can access them everywhere. To be sure of it, all our managers are loaded by the Application Manager which is what all our document classes extend. Neat trick and quite useful.

Tools = Static

All our tools are static methods. We don’t want our tools to be instantiated. We don’t want our tools to hold data. We want our tools to do something specific and produce an output.

At the end of the day

Like I said, when we start a new game I copy the core directory of the latest game to the new one. Usually I take a look a t it or look for //TODO remarks for something I want to review. While the code base was growing this was very useful, right now it’s a matter of tunning some details since most work is done while refactoring.

I do have a damn project to go though… writing the graphic handling classes… but I still have a load of doubts to sort first.

Oooops… big one… Vlad out! :)

Thoughts on user interaction

June 29th, 2009

hardcore-gamerDoesn’t matter how many games you’ve made or how many tests you’ll perform, you’ll always have a lot of doubts when it comes to how to put the interaction in your game feedback loop.

User interaction grows on me in a weird way. Experience should make it easier, but as time goes by I tend to put more and more variables to the design stage. I want the player experience to be flawless.

Flawless interaction

In my humble opinion for the interaction to be flawless, the following requirements must be met:

1. Minimal interaction

The player’s effort to get something done must be minimal, except if that effort is part of the game’s mechanic.

2. Perfect feedback

The player’s effort to get something done must have its counterpart in the game that must perform the player’s order but also inform the player that the order was received correctly. If the player’s order is not accepted by the core rules of the game design, the player must be undoubtedly informed that it was not possible to perform the action and why.

3. Seamless integration

Both interaction and feedback must be integrated in a way that is natural to the game. For instance, if you have a very simple mechanic and the player action is not allowed, you shouldn’t pause the game and give the player a huge chunk of text explaining why that is happening. A simple sound and some red markings on screen should make it obvious for the player.

Our rules

With all of the above in mind, I look at our current project and decided on the following…

1. Mouse Hover

Every time the player moves the mouse on top of some meaningful element (usually a game token) the game will always produce feedback about the element. The feedback will always be presented in the same screen space. Information formatting will be as similar as possible to all elements, respecting the smaller differences between each element type.

2. Mouse Click

GUI buttons were created to remove unnecessary effort. As an example, given a large playarea where you’d need to find a game token, click it and choose a task by another click would involveĀ the player searching for the game token in the map, clicking it, analysing a set of options and clicking one. We created GUI buttons where the player simply has to click the option he wants.

From the feedback point of view, the button will only be available if all conditions are met to perform the action of the given button. More, if the player hovers the button, information will be given in the determined info space to why the player cannot perform that action.

The only elements that involve two clicks are elements that interact with other elements. In this case, we opted to make the first mouse click select the element and make the element information fixed and then the second click on the element to interact with will create a contextual decision.

Conclusions

What is described above is already implemented in our current project. I predict some tuning of some issues regarding user interaction with the game but the results make the game feel ridiculously simple to play. My biggest question is if this feeling is only ours or if the players will feel the same.

See you all soon,
Vlad

Sponsorship, licensing and publishing

June 27th, 2009

Like I commented on Freelance Flash Games blog, I disagree with the current definition of sponsorship. I disagree not because I’m some kind of linguistics freak (English is not even my first language) but because I feel that the discussion of the terminology, together with experience and knowledge brought from outside flash game space can bring new ideas and new formulas to both developers and portals.

Sponsorship

Sponsorship is a deal where the sponsor entity gets itself associated with a sponsored entity in return for some commercial value that it would not have if there was no association. Translated to our reality: sponsorship is a deal where a portal gets associated with a game in return for traffic generated by that game.

In other sponsorable property it is possible to have several sponsors. Think about F1 cars or TV shows. As you may know, a sponsorship in flash games is exclusive.

Licensing

A license is a permission. Licenses are issued by city halls, governments, software publishers and so on. Every time you buy a game you are being granted a license, same applies to a movie. All content on each TV channel is licensed to be aired by that channel. When you drive a car, you have a license to drive and a license issued so that the car can use the pavement in your country.

Same applies to flash games. When a developer sells a non-exclusive site-locked license he is not being sponsored. He is granting the portal a permission to use his game. What about primary licenses… well… a primary license is somewhere between the sponsorship model and a true licensing model. What separates a 100% licensing model from what we have now is the primary licenses. On the other hand this licenses are what makes traffic go up and down, so until something special happens, I think it’s a good thing for everyone that it still exists.

One interesting aspect about licensing is that it is widely accepted that site-locking a non-exclusive license is done to protect the interests of the primary license holder. As I see it, it is protecting the interest of the developer because the non-exclusive site-locked license could exist and the viral version be used for commercial and brand awareness of the developer. If every single developer worked his own brand awareness by not selling a primary license, making the viral version his own and then selling only site-locked licenses we would have a full licensing model, which we can only speculate if it would work or not.

Publishing

From AAA console games to casual download games, there are a lot of games where a publisher finances the game. This is the foundation of the publishing model: a publisher accepts a project from a developer, funds it, markets it and distributes it. The commercial catch is that the publisher controls everything except the production. For all that matters, the property of the end product belongs to the publisher.

Apart from some portals internal development, there’s no real publishing space in the flash market. I don’t think that it is doable though. Publishing usually involves financing the whole project. I’m a firm believer that most sponsorship deals don’t cover the development expenses if most developers took their time to see the costs they had. So it is possible to get the same performance by sponsoring with an amount of money that isn’t quite the same as if the same portal was publishing the same game.

Hope this helps to sort some ideas out. Stay tuned on Freelance Flash Games blog… I know he has something to say about this too. :)

Signing out…
Vlad

Learn to fly

June 25th, 2009

My name is Vlad and I’m a Learn to Fly addict… That’s what I’ll say in some years while getting up from a dusty chair looking in the eyes of other Learn to Fly addicts. I could write about this game, simply because I love it, but I want to say something about the developer.

The game got to the top place of the highest rated games on Kongregate. Some users asked how it was possible that something so simple would be in that spot. The author answered:

To all those commenting about “How this game got first”, I must say that I agree there are many better, more complex and complete game than this one. However, I think Learn to Fly got it’s ranking simply because fewer people must be giving low ratings. It is probably a game that has a larger target audience when compared to Sonnny for example. Sonny is a great game, very well built, but let’s say someone who hates the genre tries it… he might rate 1/5 just because he doesn’t like RPGs. I honestly believe other games would deserve to be ahead of mine, however I won’t be the one to complain about it ! Have a nice day people !

Is this a class act or what? I don’t know light_bringer777… I have no opinion other than really liking this particular game. But I think that there’s great personality and character in these words that he addressed to players.

What can I say? Congratulations for a successful game and kudos for being honest about yourself and others.

Selling non-exclusives

June 23rd, 2009

It has been the reason for many personal messages in forum and emails. It has been the “so sorry to bother you” private chat topic: non-exclusive licenses. Many developers want to sell it, others have portals interested in it, but have no idea of the price tag to put up or the money offered is acceptable.

Non-Exclusives 101

To accept non-exclusive licenses you cannot sell an exclusive one. So no sponsorship deals if you want license based deals going. You can have (and you should have) a primary license for maximum revenue.

Non-exclusive licenses must be site-locked to protect the primary licensee investment. The money you get for a primary license can be a good starting point for deciding prize tags for FGL Shop, but should not be used as a rule of thumb for every single deal.

Factors that influence the cost of a non-exclusive

Traffic… the hidden beast

A portal will buy the developer a non-exclusive license for several reasons but the first impact of having a non-exclusive site-locked game is that it won’t drive traffic to the portal’s competition that has the primary license. It’s not difficult to imagine that this means money.

In a way, a non-exclusive license makes the game exclusive to an already loyal portal user. This also explains why there’s a no link obligation in many requests for non-exclusive licenses. No links means no distractions. Traffic is the core product of most flash game portals and we must understand that.

Price wise, it’s pretty easy: the bigger the portal, the bigger the traffic, the bigger the need to make that traffic stick, therefor the higher the price and unlike what many developers say, portals are aware of that and are willing to put up a fair price.

Game Quality and Visibility

This should be pretty obvious. A better, deeper, more entertaining game will produce more hits to the portal that is licensing the game, therefor this should be reflected on the price. Sometimes this happens simply because the primary license offer reflects it.

This is even more obvious with well known IPs. If a game does well, players will recognize it later on and you’ll notice a snowball effect on some portals, made by players that have appreciated your work before.

Requests

APIs, logos, no links and so on. A lot can be asked for a non-exclusive license and these things take time. Not really a big issue, but you have to be prepared for it to make it worth.

Create your own custom buttons for your site for instance. These should have code that would read some “global” boolean if links are allowed or not. You can create your own API manager, preloader stuff and so on, anything that can make your code easy to adapt.

But there’s another side to it… each of these things add value to the portal and some even remove value from you. No links policy is a good example: traffic sticks to the portal and you don’t get a visit from your beloved players, thus not raising your own brand awareness.

So lowering your cost to answer these requests is by default best way to get a little something more from it.

How to calculate it?

Don’t… it’s my honest advice. Like I said above, the price of the primary can give you a basic idea to work with, but that needs to be adjusted to each portal’s size and requests.

On the other hand, or you have a known daily cost and daily goal and it’s matter of pure math to know if it’s a good deal for your or not, or you’ll be thinking time and time again if you are selling to low or not.

Don’t be radical

I guess the most difficult part of this is to learn to evaluate the game and the market porperly. On one hand, if you sell licenses to low, you’ll be damaging every developer’s business. On the other hand if you think too high of your game you’ll be damaging your own business.

While common sense says that you should bring the price as high as possible, sometimes it’s better to accept a low offer to increase your business in the long run or negotiate a high offer to position you, your brand or IPs or simply your business standing… just don’t be radical.

Vlad, logging out…