LoveTime: making of #1

Very soon our first game will be submitted to the appstore, but this time I want to talk about small side-project.

One day, when I read habrahabr, I saw there an interesting post about a gift to author’s wife. It was a simple game in which you see two photos and select the one that was taken earlier.

I decided to do the same for my wife. That’s what I had:

  • Free graphics and sounds from kenney.nl;
  • Some free music;
  • Zillion photos of me and my wife;
  • My wife love cats.

To begin with, I decided to choose about 100 photos from all that I had.

Step 1

Every photo should have EXIF (to be able to extract creation date) and photos should be sorted by creation date.

I use simple php script to do this, because it’s easy and php have native support for reading EXIF data.

Step 2

There should be no duplicates and even more – photos should not be too similar. There are many apps to find duplicates and similar photos, but I want to make my own solution.

This solution is super simple and naive, but work well for me.

  1. Resize photo to 8px x 8px;
  2. Convert to grayscale;
  3. Compute average brightness value;
  4. If pixel brightness less than avgerage, than put black pixel instead, in other case put white pixel.

Than compute distance between images – xor two black and white images and compute white pixels count. If distance is less than 6 (experimental value), than two images is similar.

There are several false positives for such naive method, but I resolve them manually.

Step 3

Photos should be resized (max 400px per side).

  1. Use convert from imagemagick to resize;
  2. Than use exiftool to copy missing EXIF data back to resized image.

Step 4

Generate PhotoInfo.hx with one class inside:

class PhotoInfo {
    public static var infoMap:Map<String, Int> = [
        "0001.jpg" => 1341142736,
        "0002.jpg" => 1344344706,
        ...
    ];
}

Where key is the photo name and value is creation date in timestamp format.

Finally

80 photos were choosen for the game.

In next post I’ll talk about making graphics and sounds (actually not making, but picking appropriate items from free assets).

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.