Net Dash (WIP)

Server up at 98.210.146.214

Hey all,

The last multiplayer game (before this one) that I wrote was somewhere around 2007. Because I love multiplayer games and because I don’t want to have such a blaring weakness in my repertoire, I’ve been brushing up on my skills.

First I made a framework using Sockets that creates new threads for every connection, kills inactive users, and the like. It’s very bare bones but theoretically can have anything built on top of it.

Then I made a chat room on top of that framework. Works fine (not going to bother to share it).

Finally, I made a very simple game (about 1.5 weeks on spare time work) and decided to call it Net Dash.

Net Dash

http://img185.imageshack.us/img185/567/screenshot20100923at121.png

I’m unable to get a good screenshot at the moment, but I think that’ll give you an idea.

From the applet page:
This is a test for a multiplayer racing-type game. It’s the first multiplayer game I’ve made in many years, so I’m trying to refresh myself. It’s incredibly hacky (I was more interested in getting something done than anything else) and is only about a week in the making, but it’s still pretty fun.

Basically, you want to get to the far right side of the level before the other player(s). You can do this by moving with the arrow keys. Pressing up or down will boost you in that direction. Pressing space will boost you to the right. Your boosts only recharge while you’re standing on the ground. If you boost while near another player, you’ll knock them backwards.

Note that I implemented this in a pretty bad way. Pretty much, the server doesn’t trust the client at all. The server receives input events, decides what to do with them, and then broadcasts changes back to the clients. This works great in turn-based games or non-twitch games, but in this game (which is twitch) it definitely doesn’t work. The problem is that the latency becomes very high for every single action. In the future I will fix this.

Server?
There is no dedicated server of any kind at the moment. Tonight I will try installing it on my video-player-computer and see if that holds up to the pressure. Otherwise I’ll run one on my computer tonight for people to try out. In the mean time, you guys can host your own by navigating to:
http://www.otcsw.com/applet/NetDash/server/
Once you’ve hosted it you can play against yourself.

[EDIT]
I threw up the applet version really fast, it’s done stupidly.

  • The client constantly requests focus so you can’t click anywhere else in that window.
    I’d recommend downloading the server JAR and running it directly.

for 2/3 hours you can try 89.86.173.51 : 15678 :wink:

EDIT: heu… how do you type the “.” when typing the IP server adress ?

Ha crap I recently broke that. :slight_smile:

I’d better fix it. :smiley: While I’m at it I can make the applets clean up.

EDIT:
Okay I fixed it. I was fixing a different bug and accidentally didn’t allow periods. :slight_smile:

EDIT2:
Definitely needs some better feedback from the client when it tries to connect. Seems to be locked up for a very long period of time before it gets to your server, with no errors. I got a timeout when trying to connect to you.

that’s working, I try to launch server but it seems to only listen on IP 127.0.0.1 (work for me but dont know if someone can connect)

EDIT: may be the socketserver does not listen on all IP (only on localhost / 127.0.0.1 )?

I’ve played across the US with no problems (from California to Chicago). And around the San Francisco Bay Area a few times. It’s not there’s an easy way to force it to listen on a small range of IPs… you have to do extra work to do that.

Server up at 98.210.146.214

If you want to listen to all IPs, bind to 0.0.0.0

The applet seemed to freeze:


Java Plug-in 1.6.0_21
Using JRE version 1.6.0_21-b07 Java HotSpot(TM) Client VM
User home directory = C:\Users\neeowolf

----------------------------------------------------
c:   clear console window
f:   finalize objects on finalization queue
g:   garbage collect
h:   display this help message
l:   dump classloader list
m:   print memory usage
o:   trigger logging
q:   hide console
r:   reload policy configuration
s:   dump system and deployment properties
t:   dump thread list
v:   dump thread stack
x:   clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------

security: property package.access value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.
security: property package.access new value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.javaws
security: property package.access value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.javaws
security: property package.access new value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.javaws,com.sun.deploy
security: property package.access value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.javaws,com.sun.deploy
security: property package.access new value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.javaws,com.sun.deploy,com.sun.jnlp
security: property package.definition value null
security: property package.definition new value com.sun.javaws
security: property package.definition value com.sun.javaws
security: property package.definition new value com.sun.javaws,com.sun.deploy
security: property package.definition value com.sun.javaws,com.sun.deploy
security: property package.definition new value com.sun.javaws,com.sun.deploy,com.sun.jnlp
security: property package.access value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.javaws,com.sun.deploy,com.sun.jnlp
security: property package.access new value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.javaws,com.sun.deploy,com.sun.jnlp,org.mozilla.jss
security: property package.definition value com.sun.javaws,com.sun.deploy,com.sun.jnlp
security: property package.definition new value com.sun.javaws,com.sun.deploy,com.sun.jnlp,org.mozilla.jss
basic: Added progress listener: sun.plugin.util.GrayBoxPainter$GrayBoxProgressListener@82c01f
basic: Plugin2ClassLoader.addURL parent called for http://www.otcsw.com/applet/NetDash/server/RaceTestServer.jar
network: Cache entry not found [url: http://www.otcsw.com/applet/NetDash/server/RaceTestServer.jar, version: null]
network: Connecting http://www.otcsw.com/applet/NetDash/server/RaceTestServer.jar with proxy=DIRECT
network: Connecting http://www.otcsw.com:80/ with proxy=DIRECT
basic: Loading Java Applet ...
network: Downloading resource: http://www.otcsw.com/applet/NetDash/server/RaceTestServer.jar
    Content-Length: 57,325
    Content-Encoding: null
network: Wrote URL http://www.otcsw.com/applet/NetDash/server/RaceTestServer.jar to File C:\Users\neeowolf\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\13\4133750d-6c86f3aa-temp
network: CleanupThread used 93792 us
security: Blacklist revocation check is enabled
security: Trusted libraries list check is enabled
network: CleanupThread used 2 us
security: Accessing keys and certificate in Mozilla user profile: null
security: Loading Root CA certificates from C:\Program Files (x86)\Java\jre6\lib\security\cacerts
security: Loaded Root CA certificates from C:\Program Files (x86)\Java\jre6\lib\security\cacerts
security: Loading Deployment certificates from C:\Users\neeowolf\AppData\LocalLow\Sun\Java\Deployment\security\trusted.certs
security: Loaded Deployment certificates from C:\Users\neeowolf\AppData\LocalLow\Sun\Java\Deployment\security\trusted.certs
security: Loading certificates from Deployment session certificate store
security: Loaded certificates from Deployment session certificate store
security: Validate the certificate chain using CertPath API
security: Obtain certificate collection in Root CA certificate store
security: Obtain certificate collection in Root CA certificate store
security: Start to check whether root CA is replaced
security: The root CA hasnt been replaced
security: No timestamping info available
security: Found jurisdiction list file
security: No need to checking trusted extension for this certificate
security: The CRL support is disabled
security: The OCSP support is disabled
security: This OCSP End Entity validation is disabled
security: Checking if certificate is in Deployment denied certificate store
security: Checking if certificate is in Deployment permanent certificate store
security: Checking if certificate is in Deployment session certificate store
security: User has granted the priviledges to the code for this session only
security: Adding certificate in Deployment session certificate store
security: Added certificate in Deployment session certificate store
security: Saving certificates in Deployment session certificate store
security: Saved certificates in Deployment session certificate store
security: Loading certificates from Deployment session certificate store
security: Loaded certificates from Deployment session certificate store
security: Validate the certificate chain using CertPath API
security: Obtain certificate collection in Root CA certificate store
security: Obtain certificate collection in Root CA certificate store
security: Start to check whether root CA is replaced
security: The root CA hasnt been replaced
security: No timestamping info available
security: Found jurisdiction list file
security: No need to checking trusted extension for this certificate
security: The CRL support is disabled
security: The OCSP support is disabled
security: This OCSP End Entity validation is disabled
security: Checking if certificate is in Deployment denied certificate store
security: Checking if certificate is in Deployment permanent certificate store
security: Checking if certificate is in Deployment session certificate store
basic: Plugin2ClassLoader.getPermissions CeilingPolicy allPerms
basic: Applet loaded.
basic: Applet resized and added to parent container
basic: PERF: AppletExecutionRunnable - applet.init() BEGIN ; jvmLaunch dt 227012 us, pluginInit dt 4576556 us, TotalTime: 4803568 us
basic: Applet initialized
basic: Loading Java Applet ...
basic: Removed progress listener: sun.plugin.util.GrayBoxPainter$GrayBoxProgressListener@82c01f
basic: Applet made visible
basic: Starting applet
basic: completed perf rollup
basic: Applet started
basic: Told clients applet is started

Yeah, I think it’s the initial level data being sent over - it sends a pretty bit int array all at once. I haven’t tested this thoroughly enough at long distances to really tell why yet. And if you look at your log you can see that there is no actual crash, it’s just “locked up.” But in reality if you leave it for a while it should connect or time out. Could be that I’m running it from a very slow machine - its just a spare Mac Mini I use for watching videos.

Uh …

Connecting to 98.210.146.214 on port 15678 Couldn't connect to server. java.net.UnknownHostException: 98.210.146.214

Interesting… according to the limited logs it has seen a few people connect and doesn’t have any errors.

Oh well. I’ll look into it again later.

I got this two times:

Don’t do blocking things in that thread. Everything (including the console) froze. :slight_smile:

After I got the Success connecting, I got back to the “not connected” screen.
Also, I couldn’t type in my message here untill I killed the tab with the applet and refreshed.
Running Win xp and firefox.

Weird, I’ll look into the timeout problems too. Yeah, I think I’m connecting from the main thread, I should do that from another one… thanks for testing it so far, y’all.

You’re probably better of with this utility method:


public static Socket connect(String host, int port, int timeout) throws IOException
{
   if(SwingUtilities.isEventDispatchThread())
      throw new IllegalStateException("networking from EDT");
   Socket socket = new Socket();
   socket.connect(new InetSocketAddress(host, port), timeout);
   return socket;
}

Ah, great. That’s very helpful. Yeah come to think of it I think indeed the EDT is the one making the connection, which is definitely a silly idea.