breber / cardgames

Repository for continuation of CS309 Project
https://play.google.com/store/apps/details?id=com.worthwhilegames.cardgames
3 stars 1 forks source link

Rework Gameboard to rely less on hardcoded values #12

Closed breber closed 12 years ago

breber commented 12 years ago

So I started working on getting the gameboard to work on any screen without having to come up with arbitrary constants that may or may not work on other devices. What prompted my to do this is the fact I don't have my Nook with me, so I could come up with the value @anelson6 asked for. So I kind of did a major reworking of the GameboardActivity and the gameboard.xml.

Essentially what I do is I iterate through all the cards in each player's hand, and add the cards to the layout. I dynamically scale them based on the screen height. I think each card is set to be 1/4 of the screen height. This seems to work pretty well. I started up the gameboard on my phone and though small, it seems to show up more or less correct.

There is one issue that I am running into. For player 2 and 4, the layout starts out not completely up next to the edges, and as the number of cards decreases, it moves closer to the edge. One thing I think I am doing differently from the original code is I am rotating the whole bounding LinearLayout (pseudocode for what it looks like below), instead of just the TextView. This allows us to use the same code to add cards for all 4 players:

<LinearLayout rotate=270>
  <TextView id=player2Name />
  <LinearLayout id=player2Hand />
</LinearLayout>