Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (552)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Card games  (Read 3947 times)
0 Members and 1 Guest are viewing this topic.
Offline Javec

Senior Newbie





« Posted 2007-11-21 18:05:59 »

Hello everyone,

I am proficient in Java, but I am new in game development, and I would like some guidance please Smiley

I would like to develop a Java card game, but after identifying the obvious classes:

Card
Hand
Deck
Player(Abstract) extended by Human, Computer
Table

I am stuck Sad

Do you think Hand should be part of the Player class (Vector for example)?
Do you think Player should be objects inside Table?

Can you recommends any resources with examples so I can understand how to start? I know that I must make objects communicate to simulate the game, but what is the "proper" way or pattern used?

I read that you can use pattern such as MVC or observer observable to have the same game be played from console window, GUI, remote client etc.. I like this idea, but I don't have the experience to implement it Sad

Also, I read about the Facade pattern were you sum up all the objects into a single class so it becomes like a framework. What methods should a proper Facade support in a card game? game.start() game.bet()?

I would like to start coding a simple game with only console input/output and then worry about graphics etc, and use good design practises so I dont need to keep stating from scratch all the time if I add/remove to it.

Thanks for your time, and any help is very appreciated Smiley
Offline broumbroum

Junior Member





« Reply #1 - Posted 2007-11-21 23:08:47 »

I can't give you any complete resources articles about making a game, but as for my own experience, I'm able to give you some guidelines to follow up.
  • first, a MVC interface is roughly recommended vs. a console command line input interface, whatever is your knowledge about UI.
    MVC is roughly based on setting up a PREVIEW of how will your game look like, as exactly as you can, what you see is what you get (maybe a WYSIWYG builder like Matisse can help you at this step).
  • afterwards your MVC is completed, launch your first MVC build in shell or IDE builder and try focusing your user actions on the essential features, e.g. a non-exhausitve list of Action's :
              - start game
              - quit game
              - help dialog
              - scores and highscores
              - multiplayer interface, pop-ups, pause/resume, window look & feel, etc.
  • consequently but not the least, the background algorithm can be now implemented in such Swing Timer's or Thread looping. MachinePlayer is confronted to the HumanPlayer and vice-versa as well as other combinaisons like RemotePlayer against MachinePlayer etc.. Threading knowledge is the most valuable beyond all of the graphics facilities and inputs.
That'd be all and complete for a game. Smiley
It's not my personal view, but a logical structure that you can find in many High-School curses and Java Books. Grin

::::... :..... :::::: ;;;:::™ b23:production 2006 GNU/GPL @ http://b23prodtm.webhop.info
on sf.net: /projects/sf3jswing
Java (1.6u10 plz) Web Start pool
dev' VODcast[/ur
Offline stef569

Junior Member





« Reply #2 - Posted 2007-11-22 18:01:16 »

some other things:
choose if you will use active or passive drawing. Awt or Swing.
Also note that when you use mvc you have to use events/listeners to let other objects know that something should be done.
This is an example http://www.ibm.com/developerworks/java/library/j-tetris/ that uses mvc.
Don't put everything inside one class, It's even better to put related classes into another package.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Javec

Senior Newbie





« Reply #3 - Posted 2007-11-22 18:13:06 »

Thanks for the info, the article is oh help.

Also, can someone check out my design and say if it ok? Do I need to make more classes? less? Hand can be an arraylist in player of type Card for example?

I really need a java "card games" tutorial/article please.

I feel I am  lost :/
Offline Jackal von ÖRF

Junior Member





« Reply #4 - Posted 2007-11-22 21:31:13 »

Do I need to make more classes? less?
It's impossible to answer to such a question. Just go ahead with one design an change it when you need to.

It's not important that how many or few classes there are. Most important is that the code is easy to maintain - then you can always mold the architecture to suit new requirements. Writing code using the TDD style helps in keeping software "soft".

Offline SimonH
« Reply #5 - Posted 2007-11-23 00:34:15 »

Do I need to make more classes? less?
Less - If you don't know why you need a class then don't have one. As a rule; simpler==better.
A lot depends on what game you're writing; Beggar-my-neighbour is very different from Poker.
As an exercise, imagine that the pack is represented by the numbers 0-51 (where 0-12 is hearts, 13-25 clubs &c) so a poker hand would simply be an array of 5 numbers. See if you can work with that, if not, decide why not. What extra information would you need and why?

People make games and games make people
Offline Javec

Senior Newbie





« Reply #6 - Posted 2007-11-24 17:06:37 »

I designed my game, but I came to a point were I don't know how to make the classes work together.

I got

Card
Deck (52 Card)
User (extends Player)
Computer (extends Player)
Table

and a Game class which will be the main loop. However, I am not sure how to implement betting

Table.bet(player.bet(10)); could mean deduct 10 from the player object and add to the pot instance variable of table.

Is this "proper"? or a bad design?

Offline SimonH
« Reply #7 - Posted 2007-11-24 17:33:42 »

http://www.javaworld.com/javaworld/jw-08-1996/jw-08-cards.html


People make games and games make people
Offline malberts

Junior Member





« Reply #8 - Posted 2007-11-24 17:35:03 »

Betting can be done like this:
The Player class contains an int to store the betting info. The Player.bet() method can subtract the amount from the Player's pool and add it to the tables pot like Table.addToPot(Player.bet()).
The betting sequence will go like this:
Game gets to betting section
Loop through all the players and get their betting amount.
Add that amount to the total pot

And when the round is over you check to see who won and add the pot to his cash pool.

In space no-one can hear you System.out.println()
Offline Javec

Senior Newbie





« Reply #9 - Posted 2007-11-25 20:55:08 »


Helpfull, but source code not available to reference when reading Sad
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CopyableCougar4 (23 views)
2014-08-22 19:31:30

atombrot (34 views)
2014-08-19 09:29:53

Tekkerue (30 views)
2014-08-16 06:45:27

Tekkerue (28 views)
2014-08-16 06:22:17

Tekkerue (18 views)
2014-08-16 06:20:21

Tekkerue (27 views)
2014-08-16 06:12:11

Rayexar (65 views)
2014-08-11 02:49:23

BurntPizza (41 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (41 views)
2014-08-06 19:49:38
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!