}
public void repaint() {
int numberOfCards = player.getNumberOfCards();
Graphics gRender = null;
switch(player.getPos()) {
case DOWN:
int maxCardX = screenWX / WIDTH;
int width = (numberOfCards < maxCardX)?(numberOfCards + 1) * WIDTH
:maxCardX * WIDTH;
rendered = Image.createImage(width, HEIGHT * 3);
gRender = rendered.getGraphics();
//Fill background with black color.
gRender.fillRect(0, 0, rendered.getWidth(), rendered.getHeight());
int card = 0;
int end = numberOfCards - 1;
int spacer = 0;
int atual = player.getAtualCardP();
//counting starts in 0
if (player.getNumberOfCards() >= maxCardX) {
if ((atual >= maxCardX - 4)
&& (atual < numberOfCards - 3)) {
card = atual - (maxCardX - 4);
} else if (atual >= numberOfCards - 3) {
card = numberOfCards - maxCardX;
if (atual == numberOfCards - 1) {
spacer = -1;
}
}
end = card + maxCardX - 1;
}
//Draw cards
for(; card <= end; card++, spacer++) {
Image render = player.getCard(card).getGraphic().getRender();
int posy = (card == atual)?0:HEIGHT;
gRender.drawRegion(render, 0, 0, render.getWidth(),
render.getHeight(), Sprite.TRANS_NONE,
spacer * WIDTH, posy,
Graphics.TOP|Graphics.LEFT);
}
break;
case UP: {
int width2 = (numberOfCards < 15)?(numberOfCards + 1) * WIDTH
:15 * WIDTH;
rendered = Image.createImage(width2, HEIGHT*2);
gRender = rendered.getGraphics();
//Fill background with black color.
gRender.fillRect(0, 0, rendered.getWidth(), rendered.getHeight());
int max = (numberOfCards < 15)?numberOfCards:14;
//Draw player
for(int n = 0; n < max; n++) {
Image render = ((showFace)
?player.getCard(n).getGraphic()
:BACK).getRender();
gRender.drawRegion(render, 0, 0, render.getWidth(),
render.getHeight(), Sprite.TRANS_NONE,
n*WIDTH, 0, Graphics.TOP|Graphics.LEFT);
}
}
break;
case LEFT:
case RIGHT:
int capacity = (screenWY - 136) / 15;
int height = (numberOfCards < capacity)?(numberOfCards + 1) * WIDTH
: (capacity - 1) * WIDTH;
rendered = Image.createImage(HEIGHT * 2, height);
gRender = rendered.getGraphics();
//Fill background with black color.
gRender.fillRect(0, 0, rendered.getWidth(), rendered.getHeight());
int max = (numberOfCards < capacity - 2)?numberOfCards:capacity - 2;
for(int n = 0; n < max; n++) {
Image render = ((showFace)
?player.getCard(n).getGraphic()
:BACK).getRender();
gRender.drawRegion(render, 0, 0, render.getWidth(),
render.getHeight(),
(player.getPos() == LEFT)
?Sprite.TRANS_ROT270
:Sprite.TRANS_ROT90,
0, n*WIDTH, Graphics.TOP|Graphics.LEFT);