开发者

Android Development- Creating a board game

Im trying to plan out the best way to develop a sample game. I would like to create a board game that act like words with friends (not game rules). For example, I want开发者_开发知识库 the board to be a six sided board that has a set number of game tiles. When a game piece (like a checker or ball) is placed on it, i would like to have that piece "snap" to the closest location. My question is, what is the best way to do design the board? Should this be done as a background image? Or draw the board live? If so, how do i create the "snap to" and register when a piece is on the board? I also want to make sure that the board is drawn to the correct dimensions for different phones.

Thanks for any suggestions jason


This is probably a bit to broad of a question for SO. But I'll give it a go. Little bit of preface, I have not personally attempted what you are trying. So please do not take what I suggest as what you must do.

If I were you I would create a GameBoard object and a GamePiece object. Put everything to do with making and holding information for the board in the GameBoard class. Whether you draw your board in java, or start with a graphic and build from there depends on a few different things. How specialized would you like the board to look?(you'll have more control if you start with a graphic if you want to make it fancy) If you're just looking for a grid of lines and nothing fancy I'd think you'd be fine to just draw it from java. Do you ever want to use more/less than 6 rows/columns? If you want to use a different number it may be easier to do that when the time comes if you do your drawing from java rather than from a stored graphic. Your game board will also need to be able to keep track of which pieces are on it and where they are.

As for the snap-to: You'll be creating a touch listener that allows you to drag a GamePiece along under your finger. inside of the Finger_Up event in your listener you'll check the piece's current Rect against the Rect's on the GameBoard and drop into whichever slot it intersects most. Fair warning while you are creating your touch listener you're going to have to use some very nitty gritty linear algebra to take raw motion events from the touch screen and tell it where to draw the piece next.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜