Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Forum Contest: Create a simple Android dice game

EDIT: This contest has ended! Congratulations to Chai Phonbopit for the winning entry! Our next contest on creating a Tic-Tac-Toe app for iOS is up!

Hello everyone!

It's time for a new Treehouse Forum contest! Check out this video Amit helped me record to learn more:

After you've watched the video, please read the details below carefully. We're looking forward to your entries!

Game Rules:
The dice game is called "Pig" and is a simple two-player game. The rules and more information about the game can be found here on its Wikipedia page, but the simple rules are as follows:

Each turn, a player repeatedly rolls a die until either a 1 is rolled or the player decides to "hold":

  • If the player rolls a 1, they score nothing and it becomes the next player's turn.
  • If the player rolls any other number, it is added to their turn total and the player's turn continues.
  • If a player chooses to "hold", their turn total is added to their score, and it becomes the next player's turn.

The first player to score 100 or more points wins.

How to Enter:
Create your app as either a native app or a hybrid app (web technologies wrapped in a native shell). The app must be installable on Android devices, i.e. regular web apps are not permitted. Then post a link as an answer to this post. It can be a link to downloadable project files, a GitHub repo, an APK, or a link on Google Play. Be creative with the design and user experience!

Due Date:
All entries must be submitted by March 16th at 11:45pm ET. Here's a timezone chart so you can see what time that is for your locale.

Prize:
The entries will be judged by Treehouse teachers based on both design and code. One winner will receive a free month of Treehouse Pro (formerly called "Gold") on us! We'll announce the winner on March 17th and reveal the next contest.

30 Answers

This looks like a pretty awesome contest! I'll be sure to give it a go:)

Calvin Maighan
Calvin Maighan
12,061 Points

Man I haven't learned android development yet, bummer. Good luck to however participates :)

Same. Maybe later. :)

Ben Jakuben
Ben Jakuben
Treehouse Teacher

You have plenty of time to take the [Build a Simple Android App](teamtreehouse.com/library/build-a-simple-android-app) course and give it a go! :) This contest was intended to be doable for anyone who has finished that first course. There isn't anything too difficult about it.

William Dahl
William Dahl
7,829 Points

Looks good - challenge Accepted!

I managed to build a simple version after doing "Build a Simple Android App".

Now to get creative! :)

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Excellent - can't wait to see it! I fully intend to play all contest entries with my five year old son. :-)

Challenge Accepted Ben and Amit. (By the way I'm 12 so don't expect much)

Ben Jakuben
Ben Jakuben
Treehouse Teacher

That's no excuse! We expect even more of you! :smiley_cat: But seriously, that's so awesome that you're starting early learning how to program and make apps. :)

String reply = "Thanks";

larsfredrik
larsfredrik
2,943 Points

So good to see someone else that's young and learning! I'm thirteen, and been here for months.

Crisoforo Gaspar Hernández
Crisoforo Gaspar Hernández
18,302 Points

Challenge Accepted :D . I already start with this awesome challenge, so i expect finish as son as possible.

I just started. Do we have to follow the traditional rules? Or, can we add more dice? It seems like the game would take forever, lol!

For a challenge, later I'd like to implement Two-Dice Pig's rules. :D

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Haha - it doesn't take too long. I've played quite a few games. What's fun is that one player can have a pretty commanding lead evaporate pretty quickly with one good string of die rolls. :game_die:

I'd love to see a two dice version after the contest, though, so let us know if you do! :)

Steve Bedard
Steve Bedard
14,335 Points

Here's my participation, hope you enjoy! My app uses sound so make sure your crank up the volume ! (https://drive.google.com/file/d/0B2xlu23GjnfvcTBISXNMTG1sOUk/edit?usp=sharing)

here's the link to my github repo if you want to see my code.

https://github.com/absoluteheero/Pig

There's seem to have a problem with my repo, for some reason i don't know my two java files doesn't show up, I'm using Android Studio and i want to delete the github repo and re-upload it, how do i do that?

Steve Bedard
Steve Bedard
14,335 Points

You can download my version 1.2. I've corrected some bugs about players creation and some problem with score re-initialization when starting a new game.

https://play.google.com/store/apps/details?id=com.sbdesign.pig

I have a question; When is the roll complete? when a player clicks on the hold button or we have to randomly stop the rolling once the player pushes the roll button?

Please reply, Thanks!

Ben Jakuben
Ben Jakuben
Treehouse Teacher

That's up to you! In my implementation I did the "roll" (random number generation) when the player clicks the "roll" button. The die is immediately updated. But adding some roll animation or some kind of indicator is a great bonus. See Grant Hosticka's solution above. :)

Steve Bedard
Steve Bedard
14,335 Points

My 5 year old son just love my game....are we allowed to put it on play store?

Grant Hosticka
Grant Hosticka
4,172 Points

I did, nice job by the way I am impressed with the graphics!

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Definitely! As always, we encourage you to put everything you can on Google Play. :) Submit via the link to it on Google Play if you want!

Joey Barter
Joey Barter
1,261 Points

Hi Ben, your Android teachings got me too inspired after the first two stages! I jumped straight in, and wrote a two die version...oops! I'm enjoying your videos and the challenge, thanks!

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Save that one as something like Pig Squared, and hopefully it'll be easy for you to revert to a one die version. :smiley: :game_die:

Steve Bedard
Steve Bedard
14,335 Points

Since I'm a perfectionnist, I found an annoying bug in my app that you may not have noticed but when you decide to play another game, the first dice roll of the first player is not accurate, it has kept in memory my last TEMP_ROLL, can i re-submit ?

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Absolutely! Just add a comment with your new version below your original entry above. :)

Can I use other app name when I upload to Google Play? or accept only name "Pig", Thanks.

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Totally up to you! "Pig" isn't the greatest name, is it?

I uploaded my Eclipse project on GitHub, should I email it to you guys, if so what email and other info should include in it to ensure I'm entered into the contest, or post the link of the GitHub Repository here?

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Add your link here so that other students can check it out, too. Everyone seems to really like checking out each other's work, especially when source is available like you'll be doing.

Roberto Elero Junior
Roberto Elero Junior
1,173 Points

Hi, guys. Here is my entry (apk): https://github.com/robertoej/pig/blob/master/bin/Pig.apk You can find the code at: https://github.com/robertoej/pig

I'm using the accelerometer events to roll the dice, however, you can use a button as well.

Obs: the app requires internet permission because I implemented a menu option for the instructions website (wikipedia).

I've used and adapted some resources from the internet. Here are the sources: http://www.facebooklaw.in/wp-content/uploads/2013/10/pig.jpg http://pixabay.com/p-35637/?no_redirect http://www.vogella.com/tutorials/AndroidSensor/article.html http://soundbible.com/1221-Pig-Oink.html http://www.sounddogs.com/previews/59/mp3/608035_SOUNDDOGS__di.mp3 http://soundbible.com/478-Cheering-3.html

Good luck everyone!

Steve Bedard
Steve Bedard
14,335 Points

I can see i've inspired SOME...:)

Crisoforo Gaspar Hernández
Crisoforo Gaspar Hernández
18,302 Points

Well I am going to leave my repo link: https://github.com/mitogh/dice-game the code of the project and some issues about them is there.

The APK File is available in this link: https://github.com/mitogh/dice-game/raw/master/bin/Dice%20Game.apk

Steve Bedard
Steve Bedard
14,335 Points

Real nice... Have you tested it on tablet? The roll and hold buttons are cutted in half on my nexus 7

Crisoforo Gaspar Hernández
Crisoforo Gaspar Hernández
18,302 Points

Thank you for the feedback I already fix it, the new version is available at the same address.

Crisoforo Gaspar Hernández
Crisoforo Gaspar Hernández
18,302 Points

Yes I tested in a tablet but I will check that thanks. ;)

Maisha Oneal
Maisha Oneal
2,351 Points

Hey guys, here's my entry. Just finished the first project course a few days ago so please bear with me :). App worked fine on my emulator, but forced closed on one of my older phones (Samsung Fascinate). Worked fine on one of my newer devices (Galaxy IV). APK: http://jmp.sh/ZeHFLEd Code: http://jmp.sh/J9djafC

Good Luck Everyone!

William Dahl
William Dahl
7,829 Points

Hi folks, some great entries here - good work!

I have uploaded my entry onto GitHub: https://github.com/Will-D/DiceGreed

The APK is located here: https://github.com/Will-D/DiceGreed/blob/master/bin/DiceGreed.apk

For anybody interested in learning about Git - I followed this introductory course by Tommy Morgan: http://teamtreehouse.com/library/git-basics Very informative!

My entry here: Pig.apk I just upload to Google Play waiting for approved.

here my version on google play : PigDice

Joey Barter
Joey Barter
1,261 Points

Hi Peeps, I have uploaded my beginner's attempt, here; https://drive.google.com/folderview?id=0B2Cx2bEwR0vyTl9hM0M5MWtrUzA&usp=sharing The app may be sad, but I had fun :P Unfortunately, the die is text based, but there's shake/button for rolling, and sound.

Joey Barter
Joey Barter
1,261 Points

Oh, I did the following; Android Tools -> Export Unsigned Android Application

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Hi Joey, I'm unable to install the app, too! I'm afraid I won't have a chance to include it now, but if you reply with a link to your code or a working APK then I'd still love to take a look, and I'm sure the others would like to see it, too.

Please visit my github account if the above link doesnt download the apk correctly.

Please visit my github account (https://github.com/sanat51289/Pig/blob/master/bin) and download the apk from bin folder if the above link doesn't download the apk file correctly. Thanks!

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Hey everyone!

Thanks so much for participating in this contest! :clap::fist::game_die::pig:

I was so impressed with all the entries. It was hard to choose a winner! The winner just squeaked by the deadline by posting that the app would be available on Google Play after the midnight deadline. Congratulations, Chai Phonbopit on winning this week's contest! Chai's app is available on Google Play, so everyone should check it out and rate it well. :)

Chai's app won because it was a really solid app with a nice, simple design and no apparent bugs. It has great sound effects, shake to roll, player name customization, and nice rolling animations. Many of your other entries had similar features and great designs. Everyone should be sure to check them all out for inspiration.

Stay tuned for another Android Forum Contest in the future, and also check back later today for this week's iOS contest, which will be announced shortly. :smile:

Happy coding!

Steve Bedard
Steve Bedard
14,335 Points

Congrat to Chai !

Hey Ben, you know what would be cool ? I would like to participate in a project lead by you on GitHub and let Treehouse member participate in the project. And each month or week there would be a contest for an iteration part of the project and members would make points for every iteration (it would be like a coding season). And the final result we could have a full app created by the community ! think about that and let us know ! Talk to your boss about it ! that would be cool....

Thank you so much.

Congratulations phonbopit!!!