Skip to content

Category: Java

Greed for Android

One of the assignments I was given this summer was to implement a version of Greed (otherwise known as Farkle, according to Wikipedia). I have now published it to Google Play Store, here.

I suspect that the rules for this version of Greed was a bit simplified, since this course focuses on Android development and not game logic.

In short; get 10.000p in as few rounds as possible. If you choose to Greed, you get the chance to throw some of the dice again but risk losing the whole rounds’ score.

Screenshot_2015-07-16-08-28-01   Greed
…and here is Greed! I decided to implement Google Play Game Services as well. There are five achievements and a leaderboard for now.

Though Greed is a rather small app, a few libraries have been used to make the development a bit smoother.

  • Timber – This is a (really) small library that makes logging a bit more enjoyable, especially when combined with Pidcat. It handles tags for you and makes it easy to toggle output, so you don’t log in production.
  • Butterknife – Butterknife primarily handles view inflation, and that is why I decided to try it out. Instead of having to type “Button btnGreed = view.findViewById(R.id.btn_greed)“, you just declare a field variable and annotate it: “@Bind(R.id.btn_greed) Button btnGreed“. Beside view inflation, Butterknife also handles click events and other “boilerplate-heavy” things.
  • Otto – Otto is a simple event handler. It makes it easy to communicate between Activities and Fragments. In Greed I have used it to internally notify about unlocked achievements, since the fragment handles the dice and the activity handles Google Play Game Services.
  • Material Ripple – This was pretty much to keep the application compatible with pre-Lollipop devices. Super-easy to implement. It is used when throwing the dice, and covers the whole fragment.
  • Fresco – Fresco is Facebooks’ image library for Android. It is a rather big library, with a lot of functionality. I decided to use it since it made it very easy to play animated gifs (used in the easter egg).
  • Tourguide – Tourguide is used in the introduction tutorial in Greed. It makes it easy to implement a good looking tutorial that forces the user to learn the application, via tooltips, markers and an overlay. It might not be the best UX-strategy, but it makes it so much easier for the user compared to just reading some rules in a wall of text.
  • BaseGameUtils – This is a library used to simplify a lot of interaction with Google Play Game Services. It is made and used by Google and removes much of the boilerplate code otherwise needed to get Play Game Services up and running.

Google Play Game Services has been both easy and fun to implement. Designing and coming up with your own achievements takes some time since they need artwork and have to make sense in game. Implementing a leaderboard should be mandatory for each and every game in Play Store, as it really is a breeze to implement and gives more of an incentive to play and actually get better since you can compare yourself to your fiends.

Enough of this rant.