Android board game implementation design

I am working on implementing the Android version for the Cloud 9 board game . I have never developed games, android apps (except for 1-2 hello world apps) or even GUI programs before (did a lot of CLIs) and I have some design questions.

The game is turn based so there are no real time considerations here and I was wondering what is the best thing to do. The game consists of fairly simple options of 2-3 options for each decision that the player must make, and first I want to make it "text", ie. Have a TextView with a "log" game on it and every time a human player has to make a decision, he is given 2-3 buttons with options that he can play. The game consists of several rounds and levels.

I started to implement a "core" game with no GUI at all and with AI players. Then I tried to figure out how to allow people, players, GUIs, etc. My current design idea is a class GameEventListener

that will be informed about various events in the game (round starts, round ends, a certain player does a certain action, etc.), and for the activity to do it, and thus it can draw / record what is happening on the screen, etc.

However, I'm not sure if this is the best approach and how part of Android it should be implemented (for example, I would like the player to have a "continue" button after some events, so he can see what was done before starting the game - how can I wait for the button to be pressed? If I return from the listener function, the game continues). Any suggestion on how to proceed?


source to share

2 answers

You can watch my Tetrads Drop for GUI game and some of my approaches This is a tetris clone and can play with another player over the internet. If you need help with some GUI, Ed Burnette "Hello, Android" is a good book to start with.


This is very similar to what you are developing.

There are package hierarchies

-com.aunndroid.Engine  (handling game logic) 
-com.aunndroid.View    (managing 2D Views)
-com.aunndroid.Tolk    (communication between deivces)




Since your game is turn-based, I think the design like the GameEventListener is fine. In principle, such a GUI can be implemented by responding to events. You can assign your listener to each UI component. For example button.setOnClickListener (your listener class);

For different buttons, you can create different listener classes for them, and they can also be collected in one GameEventListener. If the operation responded to events, it's not difficult, we can even use an anonymous class:

button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v){
                          //do your operations here(e.g. get input, update UI)




All Articles