944,005 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 4083
  • Java RSS
Aug 31st, 2006
0

adding an image to a java code

Expand Post »
hi all,
hope there are a lot of JAVA DEVELOPERS who can help me on this.

We have to develop a checkers game.Should develop in both .Net n JAVA. Two players sitting in two machines with two platforms.
One has to play in Java platform n other has to play from .Net platform.I hav to develop the java side.
I have already develop the checkers board.But my problem is to get a cherker pieces to the game board.Can someone send me the coding on how to do that.
Pianting the piece using the paint() method is not going to work.Because when we pass the objects through the web service no way to trace the image.

Hope somebody can help me.

My mail address are <emails are against forum rules>

please help me.

thank you.
Last edited by WolfPack; Sep 2nd, 2006 at 3:37 am. Reason: Deleted the Email addresses
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rangaSL is offline Offline
5 posts
since Aug 2006
Aug 31st, 2006
0

Re: adding an image to a java code

Quote ...
Pianting the piece using the paint() method is not going to work.Because when we pass the objects through the web service no way to trace the image.
And that's where you go wrong.
1) you could actually send the image data (but don't).
2) you should not send the image data, instead only sending moves (and maybe board positions) and take the image from the local machine you're running on (from a jarfile, cached when first needed, is a good way).
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Sep 1st, 2006
0

Re: adding an image to a java code

You need a way to connect the games in real time; painting the image is really the last of your concerns!

As jwenting said, you only need to pass player moves across the network; either as a stream of events or a sequence of moves that the client side program(s) can interpret into the present position of each piece.

You can use a port listening/telnet type system to connect the two games, or have them connect to a data resource on the internet and use it like a pipe.

The methods you use will influence the way users start a game, and the overall latency; I'd suggest using an online/text database that represents the actions of a single game rather than connecting clients directly (it doesn't require IP trading) and storing/sending the whole sequence of moves rather than a stream of moves (it's quite important that all data sent between users arrives at the other end in a game like checkers).

The actual means of sending the data over the Internet is maybe too flexible, you could connect to an FTP server to read/write the file, connect to a port on your server and send it a message to write/return the contents of the file, write a CGI script that the applications can execute... hmm, can't think of another raw method.

Java maybe (probably) has an interface that simplifies this kind of thing. Look in the java.net package or google something like... "java client transaction", "java server transaction", "java port transaction", "java client communication", or even "send data between two java applications on two different machines"

EDIT: infact, the search "java network communication" gives much better results!

Hope that helps, I really doubt anyone will post code, its too specific a request.
Last edited by MattEvans; Sep 1st, 2006 at 2:12 am.
Moderator
Featured Poster
Reputation Points: 522
Solved Threads: 64
Veteran Poster
MattEvans is offline Offline
1,091 posts
since Jul 2006
Sep 1st, 2006
0

Re: adding an image to a java code

Click to Expand / Collapse  Quote originally posted by jwenting ...
And that's where you go wrong.
1) you could actually send the image data (but don't).
2) you should not send the image data, instead only sending moves (and maybe board positions) and take the image from the local machine you're running on (from a jarfile, cached when first needed, is a good way).

thank you very much for your help. i'll try dat way
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rangaSL is offline Offline
5 posts
since Aug 2006
Sep 5th, 2006
0

Re: adding an image to a java code

You can connect the two clients by using Socket and ServerSocket classes. Your ServerSocket would listen for incoming events. Basically, the only thing each client has to listen for a "playerMoved" event. Update the opponent's position on your side. Each client should handle the logic of the game. So if player A moves a checker which jumps over a player B's checker, the only data you send from A to B is that the piece had moved. Player B's program should see that his checker was jumped and should run the appropriate action. No need for A to tell B that there was a jump.

The only data that really needs to be sent is anything that isn't predictable, such as player controls or random events.

And as Jwenting said, don't share image data.
Reputation Points: 92
Solved Threads: 51
Practically a Posting Shark
Phaelax is offline Offline
856 posts
since Mar 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: char = string???
Next Thread in Java Forum Timeline: String Splitter





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC