Friday, March 14, 2014

My Book is on Amazon! (Game Programming)

After spending several weeks pulling together relevant blog posts, I decided to take the plunge and publish a book about Firefox OS game programming on Amazon.

You can get the book here: http://www.amazon.com/dp/B00IZUYIGO.

The title is:

Beginning Firefox OS HTML5 Game Programming

This is an Amazon Kindle book, which means it is an eBook you read on your computer, phone, tablet, or whatever. You can read it on a hardware Kindle tablet or with software available for Windows, Mac, Android, iPhone, iPad, and just about anything else (except Firefox OS and Linux).

I debated about what kind of cover to use. I'm not an artist at all (you may have noticed that all my art is clip art or circles or squares) and I wasn't sure what to do, but fortunately Amazon has thought of that and now provides a cover-making app as part of the submission process. You pick an image, color scheme, layout, type, and punch the button. This is what came out:


Well, it doesn't say Look Inside or kindle edition, that's just how they display covers. I'm sure anyone could do better, but it does convey the message of title, author, and that the book is for people who like to type a lot.

One of the things I like about Amazon is that they let you take a peek at the book. So if you click on it, you can see the table of contents and the first few chapters, all the way to part of the first chapter on Canvas!

You can even see the names of the people I thanked for help on this book:

Panagiotis Astithas
Dietrich Ayala
Richard Blechinger
@Boot2Gecko
M. Edward (Ed) Borasky
Monique Brunel
Asa Dotzler
@eliazerk
Robert Helmer
Nicolas Hoizey
Andre Jaenisch
Christer Kaitila
Ben Kelly
Andrzej Mazur
Vivien Nicolas
@nyrrrr
Ivano Palmentieri
Planet Firefox OS
Marek Raida
Eric Shepherd
Joshua Smith
Gabriele Svelto
Gabriele Vidali

One of the wonderful things about the Firefox OS community is how helpful people really are and I definitely appreciate any and all feedback for what I do. Sometimes the help is telling me I made a mistake or need to know that  Local Storage isn't recommended or just for inspiring me in some way. Again, thank you for helping me to produce a book!

When I uploaded the book to Amazon, I was surprised when it said the book was 402 pages (estimated). I knew that the word count was 49,000 words, which would usually be a 400 page book of straight text, but my book has a LOT of pictures and screenshots. So maybe pictures are 1000 words.

What's Next?

In terms of the book, I'm going to fix a few formatting errors (more about that in a minute) and then submit it to the new Amazon CreateSpace service that lets you create print-on-demand paper books that can be sold through Amazon. You can read about it here: https://www.createspace.com/. While I like eBooks for programming (so I can flip back and forth when I'm coding but keep my hands on the keyboard), there is something nice about a paperback. Who knows, maybe a book publisher would like to publish it.

I'm also thinking about putting it on Nook. I like Barnes & Noble and there might be some people there who are interested in Firefox OS.

I investigated some of the other eBook publishing services and here is what I am seeing:

Google Play

I couldn't get a lot of details without signing up, but the word on the street is that they don't have a lot of people looking for books and they might take a bigger cut. I'll pass for now.

Apple iTunes

While it might be amusing to publish on Apple when my motto is "Stay tuned, but not iTuned" I don't like that you must use a Mac to publish with them. I have a Mac Mini but it's packed away. You also have to use their special formatting tool, so more work for me.

Leanpub

A few people suggested them and I investigated and was drawn up short. To publish with them, you must use Markdown. I really don't want to spend weeks reformatting my manuscript for them. They look interesting and they publish a lot of works in progress. This might be a good place to buy. Check them out at https://leanpub.com/

There are other markets, and if you know of something great, let me know. I'm interested in finding people who are interested in Firefox OS. Part of the magic of FxOS (the official acronym) is that it is aimed at people who may not have programmed before and is reaching out to a new world-wide audience.

Speaking of which, my book is available (in English) in these countries through Amazon:

Andorra
Australia
Austria
Belgium
Brazil
Canada
France
Great Britain
Guernsey
Germany
India
Italy
Isle of Man
Japan
Jersey
Lichtenstein
Luxembourg
Monaco
Mexico
New Zealand
San Marino
Switzerland
Spain
United Kingdom
United States
Vatican City

How I Did It

Well, I just wrote a blog and pulled together some of the posts. I never intended to make a book, but as the blog grew and the content was driving to include all the things you need to make a game for Firefox OS, I felt like maybe I could do a book. I wasn't sure it would work and the formatting issues sounded like a big hassle.

Part of the problem is that Amazon Kindle has changed what they require over the years and so there's a lot of misinformation. Also, because this blog is in Google Blogger which has its own formatting issues, I just wasn't sure how to proceed.

Here is what I did and I'm pretty happy with the results. In fact, I feared worse!

Step 1 - LibreOffice

The first step was to read up a lot. Some said to convert your book to HTML others said to use Microsoft Word. Well I obviously know HTML, but I didn't want to spend hours formatting that. Microsoft Word I know how to use but don't like it. Then I decided to give LibreOffice a try and I loved it. LibreOffice (a fork of OpenOffice) is at version 4.2 right now and it is really fast and efficient and is actually a lot easier to use than Word. The problem with Word is that they have a lot of legacy to support so they can't really make sweeping changes. Furthermore, each version of Word is really different but because they want money, I can't afford to upgrade every copy on every machine. On my various machines I have Office 2003, 2010, 2013, and Office365. But I also can put LibreOffice 4.2 on every machine and upgrade them all if there is a major change. LibreOffice will save to a .DOC format that is compatible with several versions of Office. That seemed like a safe bet.

Step 2 - Lay Out the Book

I had an outline based on my blog posts. I then created a title page, copyright page, etc. (known as front matter) and for each of those pages, I ended them with a page break. Next I created page breaks for each chapter and made each chapter title a Heading 1.

Once I did that, LibreOffice has a feature that lets you create a table of contents by using all those Heading 1 chapter titles. I put that between the front matter and the first chapter and it looks good! The table of contents then becomes a set of links for each chapter. To me, a programming book must have a table of contents! You don't need an index because you can search through the eBook.

I just used default formatting for the text and that seemed to work out all right. I used bold and italic when needed, and I had heard that Amazon doesn't like bulleted lists, so every list is a numbered list and not done with automatic numbering, just by hand.

I then copied-and-pasted each blog post to a text file (to remove any hidden Blogger characters) and then copied-and-pasted the pure text into LibreOffice.

And of course, I did some editing, removed parts that were extra, and in general thought about what was there and would it be useful. Writing a blog is one thing, but writing a book is to a wider audience. 

Step 3 - The Code

One of the trickiest parts of a programming book is to format the code. Not only must you make sure that the code is mono-spaced (like a typewriter) but you don't want the code lines to break in unexpected places. One of the things I did (and it was a pain) was to format all my code so it is only 45 characters wide. I did this originally so it would fit nicely in Blogger, but it also fits nicely on Kindle, at least in the Kindle Reader software on my desktop.

LibreOffice can format text as Paragraph and also as Character styles, and I did both for the code. Kindle seemed to pick up on it. I wanted the code to be mono-spaced and bold and 45 characters and it is! This book is all about code!

Step 4 - Pictures

This book had a lot of pictures. Someone else can count them up, but almost every post has screenshots or other helpful material. In my posts I often have clipart that is just a fun decoration, but I didn't bring them over to Kindle. But I did need the screenshots!

Those I formatted as centered and aligned to the bottom, and with no wrap for text. All my pictures were .PNG and Amazon seems to like those (I think it converts them to .JPG).

Step 5 - Upload

I already had an Amazon account. I went to https://kdp.amazon.com/ and got started. They wanted information and none of it was hard to figure out what they wanted. There were choices about pricing and royalties, name, tax stuff, etc. I then made a cover and uploaded my manuscript.

A few minutes later, the book was published and I'm there.

Promote Firefox OS

One of the main reasons to do this book is to help promote Firefox OS and show people how easy it is to program. Especially games, which are a big driver of adoption for an OS. If you want to tweet or blog about my book, that would be great. I don't know how to do reviewer copies, but maybe you do. Anything that we can do to tell the world that programming games on Firefox OS is fun and easy will help. I know nothing about promoting a book or anything, I'm just a retired engineer who likes to code. And really likes Firefox OS!