Problem displaying cards in a card game around in a circle!!

C

***C.Steamer***

Basically I am designing a graphical card game and I want to display the
cards around the display area in a circled form, just like you would at a
real card table. Now I have a render function render(Graphics g) and somehow
I want to be able to translate the graphics context to the points around the
circle. Trick is that I would also like to be able to deal the cards
according to the number of players and space them out equally around the
circle. Say 2 players I want to deal at bottom of screen and at
top(basically 180 degrees) and if there is say 6 players I want to deal the
cards at every say 60 degrees; So I have figured that I need to translate
the graphics context around this circle to draw each card but I don't know
how to do that. I have figured the point around the circle must represent
the center point of the card to make it look symmetrical, but I don't know
how to get the Graphics.translate() function to stop at these places so I
can draw my card. Any help would be great.

Basically I have this for code
public void render(Graphics g)
{
for(int i=0;i<playerController.getPlayerCount();i++)
{
Player player = playerController.getPlayer(i);
CardGraphic cardGraphic = new
CardGraphic(player.getLastCardPlayed());
// her i need to go g.translate(someLocation)
cardGraphic.render(g);

}

Thanks Alot
 
A

Andrew Thompson

Basically I am designing a graphical ..

....card game and I want to display the
cards around the display area in a circled form, just like you would at a
real card table. Now I have a render function render(Graphics g) and somehow
I want to be able to translate the graphics context to the points around the
circle.
....

Maybe..
Basically I have this for code

This is more commonly referred to as a 'snippet' and
does not exaplin things like..
public void render(Graphics g)
{
for(int i=0;i<playerController.getPlayerCount();i++)
{
Player player = playerController.getPlayer(i);
CardGraphic cardGraphic = new
CardGraphic(player.getLastCardPlayed());

...what are the abilities and form of the CardGraphic class, I do
not know since you did not say, and I have lost my crystal ball.

For tips on examples, see..
// her i need to go g.translate(someLocation)

What calculations did you do?

In any case, here are 2 self-contained rendering examples,
one Swing, the other AWT.
<http://www.physci.org/launcher.jsp?class=/codes/AnimateBalls/JAnimateFrame>
<http://www.physci.org/launcher.jsp?class=/codes/AnimateBalls/AnimateFrame>

Note that the AWT version renders in the method 'paint()',
and the Swing version in 'paintComponent()'.

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.lensescapes.com/ Images that escape the mundane
 
S

Sudsy

***C.Steamer*** said:
Basically I am designing a graphical card game and I want to display the
cards around the display area in a circled form, just like you would at a
real card table. <snip>

Maybe it's just the propeller-head in me but I'd go for a circular
layout manager. Perhaps you could start here:
<http://java.sun.com/developer/technicalArticles/Interviews/LayoutMgr/>

As an aside, even Sun gets it wrong sometimes. If you pull up the
article you'll find that it includes an applet which doesn't get
initialized. Check out the NoClassDefFoundError in your Java
console. Darn package statements! :)
 
A

Andrew Thompson

As an aside, even Sun gets it wrong sometimes. ..
*

..If you pull up the
article you'll find that it includes an applet ..

* When it comes to Applets, I have yet to see Sun get it right.

They did not use their own HTMConverter on that one (which
is probably a good thing), it is in an HTML document with
47 structural errors, and as you mention..
..which doesn't get initialized.

...just to top it off.

They should have offered the source as a self-contained
application, put a screenshot, and been done with it.

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.lensescapes.com/ Images that escape the mundane
 
S

Sudsy

Andrew Thompson wrote:
..just to top it off.

They should have offered the source as a self-contained
application, put a screenshot, and been done with it.

That's I technique I use in some of my articles. But then maintenance
on a website as vast a Sun's has to be a real bear anyway...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top