Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
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  
  Java - Multiplayer card game  (Read 2139 times)
0 Members and 1 Guest are viewing this topic.
Offline chairfight

Junior Newbie





« Posted 2011-08-19 12:58:49 »

Hey folks,
I'm in the midst of building a card game modeled after a popular card game called "Dominion"
(http://en.wikipedia.org/wiki/Dominion_(card_game)).

I've been programming in Java for quite some time now but my job has never required me to produce any sort of GUI nor have I ever produced an application is multiplayer (I'm an integration's specialist). Note: This game is intended to be used by 2 to 8 people (in total I mean, across 1-4 games). I don't plan on distributing it or experiencing a large amount of load for the multiplayer component. The game is just going to be distributed to a few close friends who live away.

I have already laid the foundation for this game. I have modeled players, cards, card actions, win states, turn orders, etc.

I'm not overly concerned about the multiplayer concept of the game right now. I would like to know the best way to approach the GUI. I've been exploring Java Applets and I think I have an understanding of how to implement the game using an applet. From what I've read applets can be pretty slow and it's very limiting to the size of the images I can use.

Last night I started trying to figure out how user interaction was going to work. ie: How do I detect that the user has moused over a particular card (basically, inside one of many rectangles on the screen), and I was thinking to myself "There has to be a better way".

So, in your opinion j-g, what's the best way to approach this? Keeping in mind:The game will eventually be multiplayer.




Offline namrog84

JGO Ninja


Medals: 46
Projects: 4


Keep programming!


« Reply #1 - Posted 2011-08-19 13:22:04 »

For what you will be doing, I personally think a java applet will more more then fine.  They can have a few hiccups but for a card like game, it really wont be a problem whatsoever.

I personally enjoy applets first. Utilizing either java2d, pulpcore, or slick2d.(among many other great ones)

for cards, you have several choices.  You could use a swing like interface and just use a jButton of some kind with custom icons.  You could construct your own button class.
http://download.oracle.com/javase/tutorial/uiswing/TOC.html


Although you have "cards", do you need to interact with them the same way youd interact with a card game like solitaire? (i.e. drag/drop, show hidden, move stacks, dbl click) or do you just have a few choices each turn?

"Experience is what you get when you did not get what you wanted"
Offline counterp

Senior Member


Medals: 11



« Reply #2 - Posted 2011-08-19 13:35:59 »

you can also make fullscreen applets if that's what you meant by limited image sizes?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline chairfight

Junior Newbie





« Reply #3 - Posted 2011-08-19 13:42:13 »

There are basically three places a card can live.

+ A card can be in a supply
+ Cards that can be bought: will require a mouseover to show additional details about the card, upon clicking on the card you are presented with the option to buy (add to your deck) or cancel. (Viewable to all players)
+Note: These cards are always in a fixed position, determined when the game is init()

+A card can be in your hand
+Again, these cards can be moused over to display additional text about the card, clicking the card gives you the option of playing it or canceling the request. (Viewable only to the player who owns the card)
+Some cards allow you to draw additional cards to your hand from your deck. This is commonly exploited to allow you to draw potentially dozens of cards to your hand.

+A card can be in play
These cards may only be moused over for additional details. No additional actions can be taken on these cards.
Offline chairfight

Junior Newbie





« Reply #4 - Posted 2011-08-19 13:43:53 »

you can also make fullscreen applets if that's what you meant by limited image sizes?

I was talking about the amount of space they take up (in kb), not actual pixels on the screen. There's twenty or so cards in the base set of dominion but expansions can add up to a hundred or more.
Offline counterp

Senior Member


Medals: 11



« Reply #5 - Posted 2011-08-19 13:45:43 »

How would an applet limit that? :\
Offline chairfight

Junior Newbie





« Reply #6 - Posted 2011-08-19 13:46:53 »

you can also make fullscreen applets if that's what you meant by limited image sizes?

I was talking about the amount of space they take up (in kb), not actual pixels on the screen. There's twenty or so cards in the base set of dominion but expansions can add up to a hundred or more.

Is this not something I should be worried about?
Offline chairfight

Junior Newbie





« Reply #7 - Posted 2011-08-19 13:48:15 »

How would an applet limit that? :\

Sorry, I'm new to this. I assumed loading a lot of images would bog down the works?
Offline counterp

Senior Member


Medals: 11



« Reply #8 - Posted 2011-08-19 13:48:45 »

Depends on how big the cards are, and if memory does become an issue (I don't think it will) you can load images on demand and THEN keep them in memory.

Well, how big are the cards?
Offline namrog84

JGO Ninja


Medals: 46
Projects: 4


Keep programming!


« Reply #9 - Posted 2011-08-19 13:55:51 »

Just using a single image, you could theoretically have 100,000+ of that image on the screen at once.(As in another post on JGO, they had a competition and plenty of people achieved that)

Even if you had a couple hundred unique images/cards at 10-100kb, you could still probably have in the thousands. But all depends on what quantity you are talking about and what type of system specs you are designing for.

In my experience simply showing images are never ever an issue.   They start to hurt more when you start doing things with alpha, rotated aliasing, blending or real time manipulation/generation/modification of images in large quantities.(quantities being hundreds, if not thousands++ of a half dozen type of manipulation per image)


"Experience is what you get when you did not get what you wanted"
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline counterp

Senior Member


Medals: 11



« Reply #10 - Posted 2011-08-19 13:59:50 »

You can get a rough estimate of how much memory you use if you take the image and multiply a pixel's size by the image's size and by the total amount of images.

So if you're using high quality images with alpha like:

1  
BufferedImage image = new BufferedImage(500, 500, BufferedImage.TYPE_INT_ARGB)


and you have 100 of those you can do

500 x 500 x 4 x 100 = 100000000 bytes

that's around 95 megabytes which is pretty manageable, and chances are you won't even need alpha.
Offline chairfight

Junior Newbie





« Reply #11 - Posted 2011-08-19 14:01:39 »

Just using a single image, you could theoretically have 100,000+ of that image on the screen at once.(As in another post on JGO, they had a competition and plenty of people achieved that)

Even if you had a couple hundred unique images/cards at 10-100kb, you could still probably have in the thousands. But all depends on what quantity you are talking about and what type of system specs you are designing for.

In my experience simply showing images are never ever an issue.   They start to hurt more when you start doing things with alpha, rotated aliasing, blending or real time manipulation/generation/modification of images in large quantities.(quantities being hundreds, if not thousands++ of a half dozen type of manipulation per image)

Okay, this eases my concern. There's nothing crazy happening with these cards other than sliding around the screen when you purchase or play a card.

At most there will be 20 unique images of cards on the screen at once. With potentially multiple copies being drawn at once. The cards themselves are around 50kb each.
Offline ra4king

JGO Kernel


Medals: 347
Projects: 3
Exp: 5 years


I'm the King!


« Reply #12 - Posted 2011-08-20 04:36:46 »

To answer your original question, you would have a MouseListener and just loop through all your rects and call card.contains(point). Good luck!

Offline Addictman

Senior Member


Medals: 3
Projects: 1


Java games rock!


« Reply #13 - Posted 2011-08-20 07:47:23 »

Please let me know if you finish this game. I am in the same situation as yourself, - I own Dominion + Expansions, but get to play it too rarely with my friends because some of them live far away.

Good luck!
Offline chairfight

Junior Newbie





« Reply #14 - Posted 2011-08-20 12:23:31 »

Thanks for the help guys, and addictman. I shall do exactly that.
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.

Pippogeek (38 views)
2014-09-24 16:13:29

Pippogeek (29 views)
2014-09-24 16:12:22

Pippogeek (18 views)
2014-09-24 16:12:06

Grunnt (42 views)
2014-09-23 14:38:19

radar3301 (24 views)
2014-09-21 23:33:17

BurntPizza (61 views)
2014-09-21 02:42:18

BurntPizza (31 views)
2014-09-21 01:30:30

moogie (36 views)
2014-09-21 00:26:15

UprightPath (49 views)
2014-09-20 20:14:06

BurntPizza (53 views)
2014-09-19 03:14:18
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!