Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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 8604 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:

Player(Abstract) extended by Human, Computer

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()

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 Devvie

« 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 @
on /projects/sf3jswing
Java (1.6u10 plz) Web Start pool
dev' VODcast[/ur
Offline stef569

Junior Devvie

« 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 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 Devvie

« 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

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

and a Game class which will be the main loop. However, I am not sure how to implement betting; 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 »

People make games and games make people
Offline malberts

Junior Devvie

« 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 method can subtract the amount from the Player's pool and add it to the tables pot like Table.addToPot(
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  

EgonOlsen (79 views)
2018-06-10 19:43:48

EgonOlsen (59 views)
2018-06-10 19:43:44

EgonOlsen (78 views)
2018-06-10 19:43:20

DesertCoockie (261 views)
2018-05-13 18:23:11

nelsongames (159 views)
2018-04-24 18:15:36

nelsongames (158 views)
2018-04-24 18:14:32

ivj94 (901 views)
2018-03-24 14:47:39

ivj94 (162 views)
2018-03-24 14:46:31

ivj94 (813 views)
2018-03-24 14:43:53

Solater (177 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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‑
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!