Slick Forums

Discuss the Slick 2D Library
It is currently Sat May 25, 2013 3:33 pm

All times are UTC




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Sat Apr 04, 2009 8:01 am 
Offline

Joined: Tue Mar 31, 2009 11:48 pm
Posts: 5
Earlier this week I asked how this could be accomplished but since then I have figured it out on my own reading various tutorials and would like to share what I learned with others.

I chose the basic slick game tutorial found on the wiki written by Spiegel to make multiplayer capable with JGN.

My goal was to understand how to use JGN and Slick together to create a multiplayer environment. I hope this is helpful to anyone else planning to use JGN with Slick but have no clue how.

I figured out how to get this to work but I am in no way an expert on JGN or Slick and would therefore appreciate any comments on improving my implementation.

My entire Eclipse project is provided which contains necessary source code, jar files, and image files to get the game running.
The necessary jar files are located in "NetworkedSlickBasicGame/lib/" and the image files are located in "NetworkedSlickBasicGame/data/".

To start the game first run "SlickBasicGameServer" and then after it loads run "SlickBasicGameClient" for each player.
One issue I didn't get around to fixing is that when a client exits, the corresponding sprites on the other client's displays do not get removed from the game.

You have full rights to this code, use it however you wish.

Hope this helps!

Here is an updated link:
http://rapidshare.com/files/224898008/N ... e.zip.html

And another:
http://www.mediafire.com/download.php?wnmmuoznywy


Last edited by kingiggy on Thu Apr 23, 2009 6:11 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 04, 2009 2:33 pm 
Offline

Joined: Wed Sep 17, 2008 1:06 am
Posts: 96
I can't get this to run. Starting a server, I get this:

Code:
SlickBasicGameServer [Java Application]   
   SlickBasicGameServer at localhost:1078   
      Thread [main] (Suspended (exception BindException))   
         Net.translateException(Exception, boolean) line: not available   
         Net.translateException(Exception) line: not available   
         ServerSocketAdaptor.bind(SocketAddress, int) line: not available   
         ServerSocketAdaptor.bind(SocketAddress) line: not available   
         TCPMessageServer.bindServer(SocketAddress) line: 71   
         TCPMessageServer(NIOMessageServer).<init>(SocketAddress, int) line: 69   
         TCPMessageServer.<init>(SocketAddress, int) line: 60   
         TCPMessageServer.<init>(SocketAddress) line: 55   
         JGNServer.<init>(SocketAddress, SocketAddress) line: 102   
         SlickBasicGameServer.<init>() line: 36   
         SlickBasicGameServer.main(String[]) line: 15   
      Thread [Thread-0] (Suspended (exception BindException))   
         Sys.loadLibrary(String) line: 95   
         Sys.<clinit>() line: 101   
         Display.<clinit>() line: 128   
         AppGameContainer$1.run() line: 42   
         AccessController.doPrivileged(PrivilegedAction<T>) line: not available [native method]   
         AppGameContainer.<clinit>() line: 39   
         SlickBasicGame.run() line: 114   
         SlickBasicGameServer$1(Thread).run() line: not available   
   C:\Program Files\Java\jre1.6.0_05\bin\javaw.exe (2009-04-04 10:27:13 AM)   


Did I just do something wrong?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 05, 2009 4:29 am 
Offline

Joined: Tue Mar 31, 2009 11:48 pm
Posts: 5
I have not encountered any problem like that.

How were you trying to run this?

Make sure you terminate any other SlickBasicGameServer before trying to start another one.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 05, 2009 9:50 am 
Offline
Regular
User avatar

Joined: Thu Dec 18, 2008 6:07 pm
Posts: 238
Location: Bournemouth, UK
Normally means the port is already in use.

What port have you coded the server to use?

_________________
- Gwinnell (irc.freenode.net, irc.chatspike.net)
- Game Jolt Moderator


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 05, 2009 2:07 pm 
Offline

Joined: Tue Mar 31, 2009 11:48 pm
Posts: 5
I used port 9100 for TCP and port 9200 for UDP.

The port can be changed in SlickBasicGameServer and SlickBasicGameClient. Both classes declare a final int DEFAULTPORT variable that can be changed.

When you set the port it will use the set value for TCP and then add 100 for UDP.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 12, 2010 7:54 pm 
Offline

Joined: Tue Jan 12, 2010 7:51 pm
Posts: 3
Resurrect!

Anyone know a link where I can look at this code? The two in the OP are dead now.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2010 5:11 pm 
Offline

Joined: Thu Mar 11, 2010 5:10 pm
Posts: 9
Hi,

I want the source too...anyone have?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 15, 2010 6:24 pm 
Offline

Joined: Tue Jan 12, 2010 7:51 pm
Posts: 3
I got something working after posting. Unfortunately, I was not smart enough to keep a copy with only the basic implementation. I will work to strip a version back down to the basics and put a link up soon (I hope!). I'm sure it is not the best implementation, but it does run.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 05, 2010 3:39 pm 
Offline

Joined: Tue Jan 12, 2010 7:51 pm
Posts: 3
Finally put up the code - sorry for the delay. Let me know if you need assistance getting it set up properly if there are problems.

Files are here.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 05, 2010 4:16 pm 
Offline

Joined: Thu Mar 11, 2010 5:10 pm
Posts: 9
Thansk man.

I think that it will help too much.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group