Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java 2d game experiment guideline  RSS feed

 
mauro perei
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there, im learning java2d, and was given a smal game to develope, but im strugling with a part of the game, above i leave a screenshot of the result.

http://i.imgur.com/CTPg6od.jpg

Basically in all these cards i have to find 3 cards that match, in my case gradient blue, and in 3 matches i have 4 opportunities, and always tha i choose the right card it appears a smily face, and if a choose the wrong card appears a sad face icon. So my strugle is, for the Cards ill create a Card.class, and inside of it i have fields like color, size for example, than ill create the shape with General Path than fill the color i want, now my problem is since the card haves 2 faces how would i apply these 2 faces in the class? How would you guys in a suggest me to develop this game? Im not looking for make my code, only a way to follow my track.

Ps. sorry for my english and happy in being a part of this forum.

best regarnds
 
Campbell Ritchie
Marshal
Posts: 55717
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Do you have the card game working at the command line? You cannot put a GUI on it until you have the game working.
Please post the image with the “Img” button, since many people are reluctant to click links on websites like this.
 
Piet Souris
Rancher
Posts: 1980
67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi mauro,

apart from the question whether your card game works or not, two
simple strategies are:

1) make sure you have two Paints for your cards, one for the 'face up'
and one for the 'face down'. If you have a draw-routine in your card class,
you could give it a parameter 'boolean faceUp'.

2) use one specific card that represents a card 'face down'. The game class
(or whatever class you have that controls the game) could then decide
to draw a card, or to draw the 'face down' card.

Greetz,
Piet
 
Campbell Ritchie
Marshal
Posts: 55717
163
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe images representing faceUp and faceDown should be returned from the Card objects.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!