One Game A Month – April Postmortem: Health Katas

I’ve entered into the One Game a Month party. It’s like Ludum Dare, a challenge to make, and most importantly FINISH, a game in a set amount of time based on a theme. What makes #1GAM unique is you have an entire month and it spans an entire year. They have a thriving Twitter and Google+ group.

I’ve entered strictly for learning purposes and to see if I can actually finish something. Game development is surprisingly very different from application development, and it’s nice to feel really stupid again.

Synopsis

I fell back to my roots and attempted to build a mobile application that used “gamification”. Basically, you make the application fun through adding gaming elements to it. I’m good at building applications so figured if I fell back to my roots and adding just a little bit of game dev to it, I’d be able to create a lot more in the same period.

I changed my lifestyle last year in March of 2012 through adding fitness and changing my diet. A year later, I feel better and look better. I wondered how I could help others reach the same goals. While people tell you it’s 50% diet, 50% exercise, I felt for me 80% of the challenge was diet. I know nothing about cooking beyond what I’ve taught myself. My mom and grand mom taught me some stuff, but for whatever reason as I kid I just never really cared to better myself at it.

So, I made a list of all the smaller things I did that had longer term impact. I realize Type A Personality techniques of making huge changes with hardcore willpower are not the most effective way at changing people’s behavior. I’ve also read the statistics on how many actually keep weight off after they’ve lost it, and the time people devote to food preparation vs. exercise. For Americans, it’s pretty dire. I took that list I wrote, and selected the ones that were the low hanging fruit, and hopefully easy attainable without requiring a Doctor’s note to attempt.

If you look at most nutrition advice, at least online or in books, it’s usually huge lifestyle changes. That’s asking a lot of people, and the #’s prove it doesn’t lead to longterm positive lifestyle changes. What DOES work is small habits that lead to longer term change. If you change a bunch of them, they collectively, slowly, lead to a more healthier, and more importantly, a self-empowered, individual. I started to make the application I wish I originally had: simple tips I could try everyday that didn’t totally shock my way of life, and that I could actually accomplish, and feel good about.

Goals

Give people simple healthy diet changes to try. From making people healthier, feel better, or empowering them to learn on their own. Giving someone 1 thing to try every day, even multiple times if they wished, to practice at being more healthy without having to focus 100% of their life on doing so. My hope was it’d be the least invasive thing in their life, thus hopefully maximizing the success rate. Kata’s are simple exercises you do in martial arts to practice and get better. I wanted something like that in a diet context vs. “OMG CHANGE YOUR LIFE!”

Additionally, they’d have both motivation in the form of videos and citations that show the positives of even minor diet changes as well as a world wide achievements bored to see how many others had already accomplished each kata (or simple exercise  to also help with motivation.

Actual Results

I didn’t finish.

That said, all of the original katas are in the app, and you can try them, and have a record of your accomplishments. So it’s technically an early alpha, heh.

I ran out of time for motivations, and the achievements board was slowed because it was the first time I used Corona’s Cloud API.

The main problem with the data entered currently is that 3 important things are missing. I wanted to ensure all health recommendations I had were based on science that had at least 1 scientific study/citation. A lot of these studies are extremely wordy. Most people just want to know either WHY something is healthy or how it’s POTENTIALLY healthy. The later is horrible in terms of how we humans operate, but it’s also a good tool to get people to do what you want them to do. Anyway, collecting + summarizing all of that information is a ton of work. I’m constantly reading nutrition books and articles and taking notes, just not finished yet.

The other issue is turning those successes into congratulatory notes. When you complete a kata, you get a success message. For example, although I assumed users didn’t do drugs nor smoke, even just stopping smoking for example has a swath of awesome things that happen to your body. It’s important you not only reward people for accomplishing the simple exercise, this builds self-confidence in them, but also you teach them WHY. Once someone knows the why and has self-confidence, change is afoot. Writing those is tough… even tweet size ones.

Finally, the questions are sometimes backwards; I need to add a boolean to the VO’s to say if yes leads to completing or starting the kata… or just make all the questions have “yes” lead to starting the kata. If you use the app now, just say yes to everything.

What Went Wrong

The main problems were:

  • not enough free time
  • still learning nutritional science
  • Corona’s lack of basic GUI components and redraw invalidation
  • not enough documentation on Corona Cloud + having to learn a new API
  • Responsive Design
  • explaining to people how no longer eating their favorite unhealthy things is fun… in a mobile application… yeah.

Free Time

As usual, work both in client projects as well as outside took a lot of time. My main current client has a huge feature release coming up that we’ve all be tag teaming. This requires a lot of consistent communication as well as on-site visits which means I’m travelling a lot. I also travelled back to Georgia to sell my house. I’m uncompromising in my workout schedule and picking up my kids from school which is 2 hours minimum a day. Also, it took me about 5 days to recover from March #1GAM burnout. Finally, my company released the FlowMVC framework based on the DeftJS framework that all works atop Sencha, and that took a lot of time to ensure we got the alpha out as well.

Nutrition Knowledge

I’m not classically trained in nutrition, so am learning the same way I learned how to program: read online articles, read books, and asking questions of those who appear to be experts. Suffice to say it’s just as hard as programming to get to the real truth; it’s all masked in subjectivity and utter untruths. Making definitive statements is VERY hard to back up with science. America in particular has a ton of science around how to cure sickness, but very little on how to keep us not-sick via good nutrition. Frustrating. You have tread carefully when utilizing Qualitative science from qualified individuals. Bottom line there are a few facts, and a few of studies that reach conclusions but aren’t facts.

Sadly, a lot online is useless. At least with programming you can use sites like Stackoverflow.com and communities that reference certain blogs/articles to find the good stuff. For nutrition, there are a few sites like that, but they don’t always cite their sources, nor differentiate between “the facts” and “the guesses based on the following studies which may/may not have contradictory studies”.

I wanted the app to have solid science, and getting solid science as a n00b is hard.

Corona’s App State

While Corona has made great strides on the widget front, their gaming focus, both as a company and in the runtime features are clearly biased. Even the Corona cloud library they posted on Github uses “name spacing”, a pseudo copy of how Python handles classes and packages. This, instead of using the proper class/module packages they introduced about a year ago. I reckon they did this to cater to game devs who freak out if you do 2 dots to get a “module” whereas for application developers, it’s just expected if you’re from a traditional OOP background and you get the time to actually think about class structure that often doesn’t change as much as it does in gaming.

This seems like a digression but it’s not; the simple fact they’re game focused makes even simple things application developers expect to be non-existent. For example, I DARE you to center a multiline block of text on the screen with arbitrary widths… and then put a different block of text in it. Works no problem in Flash/Flex and HTML(!). Corona doesn’t recalculate/remeasure, and your registration point is off, and using simple x and width values to center the text suddenly fail. If you just create another text field, no problem, but even game developers know you object pool where possible.

Layout in this case is made worse as they abstract away device specific text fields. While it’s nice to use native device (iOS/Android) text fields that do render well, they don’t always render like you think on the simulator, namely the native options with backgrounds/borders disabled. Haveing to compile to view on the device is just awful. It defeats the whole purpose of Lua being an instantaneous code reload solution. If I wanted to recompile and redeploy to the device, I’d use native XCode and Objective C.

These basic needs make building higher level abstractions that are actually efficient harder. As components scale in size and complexity, especially data driven ones, you need some form of invalidation routine. Invalidation is a huge topic I’ve written about before, but suffice to say it prevents common race conditions, is an efficient redraw mechanism for runtimes like Corona that share both code execution and redraw on the same thread (see elastic race track articles discussing this), and solve order of operation errors for developers using components that require multiple properties to be set to work.

I’m in the process of building one on top of their enterFrame, but it’s like a flash back to 2001 in Flash MX; i.e. it’s a lot of work for 1 person to complete. A company like Corona should have the resources to handle this. Either they don’t have the people working for them that know these problems, or they’re focused on other things. I think it’s the latter; game specific features like their 2.5 graphics and cloud initiatives whilst open sourcing the components are signs. That’s fine, but oy vey… pain…

Another annoying thing is some widgets/components don’t work with groups. I get why, but this makes layout a royal journey into frustration and workarounds, and just generally nasty looking code.

I will say the widgets they DO have are great overall and open sourcing them was a dope move. The API consistency, while I get challenging, needs to be improved in both the libraries they distribute and in their internal SDK.

Responsive Design (lack thereof)

Because of the above crunch, I didn’t get a very responsive design. This lead to some devices not scaling properly… which sucked. For games, you can just scale up or down; Corona does this automatically. For applications, however, you basically do a “responsive design“. While most web sites prefer to use media queries and funky font measurements to accomplish this, using things like Sencha, Flex, or even Corona, and you can simply have each component size itself and it’s children. As the application grows, this works out well because they’ll fill whatever space you tell them too.

The kicker here is “if the design supports it”. For example a toolbar can scale infinitely horizontally, but tends to stay 60 pixels high. On most smartphones, this is fine, but on tablets, especially the high rez ones, it gets a bit too small to work. At that point you fall back to another nav. I didn’t even get that far… as soon as I went from a Nexus One to a Droid X, my app couldn’t even handle the extra 24 pixels.

I put a 640×960 mask on stage and called it a day.

Corona Cloud

Corona Cloud is awesome. The documentation is ok. The example code is awesome, although completely ignores Corona’s package structure and they’ve foregone using metatable vs. closure based classes for the same reason a lot of JavaScript libraries do the “large object on global window” to avoid the closure vs. Object.prototype debates. Anyway, nothing major here, just hard to learn a new API in such a short time frame with all the other challenges going on, thus compounding it.

Making Health Fun

For me, I was sick and tired of being sick and tired. Once I make my mind up, there’s no changing my mind. I have discipline with certain things I set my mind to. I get that to make broader changes to the world, you need to be more pragmatic about what you expect out of the general populace. I took the approach of “simple with positive messaging as instant reward and global awareness through achievements of other users”. The “simple” was simple, the Corona cloud achievements isn’t something I need but totally get how others need that motivation.

The “positive messaging” though is rough. When you look at the back of a “Matt’s Organic Orange Juice” container for example, they’ll go off about Vitamin D, and how it’s greatest thing for you evarrr. It clearly was written by a talented marketing copy writer and put through a few revisions. Trying to do that, for every single kata, was rough. As you can see, I can write a lot, but saying a lot with few words is HARD. Fun, but hard.

What Went Right

Finding a fitting design and icons I needed on GraphicRiver was uber easy. Getting the design to work in Corona, my component issues non-withstanding, also easy.

Setting up the MVC structure, also easy. I hadn’t messed with my port of Robotlegs for Corona for almost 2 years(!) since those kind of frameworks are more used for applications and less so games, so took the opportunity to bring it up to speed.

Coming up with simple things that are healthy for people to try was actually pretty easy as well. I just charted my own path and remembered all the hard things I did, and modified the order based on difficulty and organized into levels of lifestyle impact. The app was responsive on the device, and I only had minor masking problems with the Corona widgets. Once I got some good low level components, building the GUI’s was pretty quick and easy.

Key Takeaways

I think like my Februrary entry, I’d like to come back to this, finish it, and polish it. Even in application development, you can get into “the grind”, the last, brutal 10%. It’s easier to power through if you believe in the final product.

It’s also clear I shouldn’t do anything more GUI heavy without a Corona component framework ready before I start. Oh goody, another side project! *face palm*

I need to organize my notes about nutrition more. Most of it is for me related to fitness vs. just pragmatic well being. That and I forget what research/study/book told me what, and whether it was a “study” vs. a “paper” vs. a “theory” vs. a “scientific fact”… which greatly affects the other research/beliefs it’s related to. Like programming.

Finally, I need more time with Corona Cloud. It’s really cool, just haven’t had enough time to play to learn it more.

Conclusions

May: Go back to the 2D side scroller. From my February entry, it’s clear I liked making Box2D levels, and need more practice in making them, even if I don’t finish.

Once again, I’m burnt, and need a few days to recover. This time, though, I knew it was coming and planned for it: notes for May dev all ready, concepts documented from awhile ago when I’m ready to nail down an idea, and tons of alcohol and XBox games while I recover.

The source code is up on Github and you can install on your Android device here (although I’d wait until the version says “beta” hah).

7 Responses

  1. What a fantastic writeup! Health Katas is a super cool idea. Keep up the amazing work, and thanks for joining #1GAM – I’m proud that you have joined us.
    – Christer

    • Thanks a lot, Christer! I’m not sure why I thought gamification would be easier than gaming, hah!

  2. You got me thinking about the 60px height toolbar. On Android I wrote a Util class with a method dpToPx(dpValue) which takes a value in device independent pixels (akin to CSS px) and multiplies by device density. In Corona can you grab the device’s density (e.g. iPhone 4+ is 2, Nexus One was 1.5, new Androids are also ~2). This way you can either set the height to Util.dpToPx(60), or build that support into the component. The idea is it renders the same physical size on all devices making it thumb-friendly. If you can’t grab density of course this is moot!

    • Hah, Richard, sup dude, long time! Naw, this goes way beyond just density to pixels per inch, I mean an actual real responsive design where you can get a completely different navigation bar designed for larger screens/resolutions. I completely spaced on not only that for tablets, but also on just the basics of a good “setSize(desiredWidth, desiredHeight)” function. Little things that just kill end results/deadlines and user experience.

      Regarding density, I think you could do what you’re suggesting via combining display.pixelWidth and pixelHeight… will have to try tonight, good idea!

      • Ah I see, so this is more the “bucket types” (e.g. small or large screens). I’m just tweaking some layouts for my “sw480dp” bucket right now, that’s screens with at least a smallest width of 480 device independent pixels, there’s a lot of work involved to get apps looking crisp. Sounds like display.pixelWidth combined with actualContentWidth may get some way there in this case. Enjoyed the post anyway.

  3. As someone who likes to build UI components, I wish I could clone myself and work on all of these platforms.

  4. Ted

    For the science side I hear you – lots of ifs/buts/maybe to be found in even the most basic statement – largely I guess because scientists are a cautious breed and it is not in their toolset to offer opinions even on a 90% cert. Maybe rather than look at studies check the big orgs publicity material – maybe there is some leaflet from the American Heart Assoc that says apples and fish are good etc. Which may not satisfy your hunger to understand it all but would prob be adequate refs for a mobile app. FWIW from my reading/understanding on nutrition and lifestyle one thing I concluded is that it is just as important to cf your own family as it is to do anything else – you share a lot of genes with them and they will often have developed habits that make their lives better, maybe not from science study but from trial/error and experience which can sometimes be more useful.