I made another version: XSW 0.46. It mainly corrects a few annoying bugs in the new Base Attack game mode.
But there aren’t only Windows users! You program in Java! Try to think about the others who don’t want to use Windows! A seven-year-old child succeeded in installing my game with Java Web Start. If he succeeded, many people under Windows could do it too. Professional game developers that use Java often told me that people prefer standard exe installer but if you use an .exe file, it won’t be cross-platform! What is the interest of using Java if you don’t do anything cross-platform? CaptainJester gave you a link of a tutorial about Java Web Start and if you need some help, I’m here too.
For linux and mac he has non-exe releases (but those don’t work on windows :P)
sorry for not replying earlier, I’ve had a lot of OS trouble with Vista, and finally decided to seriously try switching to Ubuntu. I had a lot of trouble to create a partition for Ubuntu, finally used gparted, but then my Vista partition died. So now I’m only on Ubuntu, and I’ve decided not to reinstall vista until I absolutely need to. So I’m having a bit of work setting up Ubuntu (first time on linux).
goussej> There is a zip version for linux and mac, I haven’t tried the mac version but I know the linux version works. It’s not as userfriendly as you will have to type javaw -jar xsw.jar to get up and running…
Thanx for the turorial links and stuff. I will take a look on it soon, I have a lot on my plate right now, so I can’t promise when I’ll have a JWS version of it. If it truly took half an hour then I could have it soon… but I suppose there are restrictions on the program that I probably dont adhere to as I’ve never even looked at what needs to be done for JWS, and when you’re new to somehing it never takes just half an hour, that’s my experience at least
Hi Aramaz,
I’m interested to know how you did the networking - specifically, how did you take latency into account? Do you add a delay between key presses and when they have an effect (it doesn’t seem like it)? Do you re-wind the world to when the lagged event first occurred and then fast-forward back?
I’d like to know because whatever method you’ve used, it looks pretty good. Also, is there something about the way that you structured the network code that you regret or that limits you or makes code changes or feature updates difficult?
Thanks,
Keith
Hi,
I messed with a few techniques, but ended up giving the clients some authority. I figured the most important thing was to have good control over your ship, and good responsiveness when firing the weapon. So the client keeps it’s position and whenever a key press or collision occurs it sends it’s current position, velocity and pressed keys (to calculate acc) to the server and to all clients that are close by (which can see the ship). So for all clients in view there is no round trip to the server, they get the state directly (which in most cases are faster than a round trip to the server).
Along with the state is a time stamp, thus all clients and the server calculate the new estimated position of the ship by forwarding by the delay. This gets a new position for the ship, the current position of the ship that is kept at the receiving end (server or other clients) is then interpolated to the actual position over a short time (while updating with velocity and acceleration). Seems to work pretty decent… Collisions between ships is something that isn’t working well atm.
Shots are spawned directly at the client, and sent to the server and all clients in view. These shots are temporary, and await authorization from the server (which checks for correct amount of ammo etc). The server acknowledges the shots (or invalidates them if the client is trying to cheat, then those shots will disappear). Shots are pretty easy because they have a determined motion, so it’s just to update them by the send delay.
As for the code, it’s a mess right now. I started out pretty good, with good encapsulating classes etc. Strived to keep a clean design to be able to reuse parts. But then I got less and less time to program, and just worked on putting features in and have taken many shortcuts. Which I’m paying for now, but I don’t have time to clean up the code. There are many things I regret in the code structure, networking should have been encapsulated better, I would have a huge task if I were to change it in some fundamental way. The messages themselves (on byte level) are spread throughout the code… I wish I’d created a way to view in clear text what the contents of messages are, it would have helped me loads in debugging. I think I will do that soon since there are some rare occurring bugs that are very hard to figure out. I actually started out using tcpip, but I had problems with that and changed to udp (which was a big task).
This is the first game I’ve written in Java sofar (first application in java bigger than the coding assignments you do in school), I’ve made many mistakes, but have learned lots. I’ve written several other games in other languages before, but nothing as ambitious as xsw.
Thanks for the detailed explanation. It’s a really interesting setup with how the players directly send their position, speed etc to the server and all nearby clients. In that way it’s like a peer-to-peer setup. That must have been difficult to setup since every client needs a connection to every other client.
The way you honour the client’s reality is great - it’s what makes the game feel solid. If the client’s ship had to wait for validation from the server then it would feel terrible.
About code messiness, that seems to be what happens to any game as it gains features.
So do you ever send the game world to clients from the server? I understand that players’ ships never get out of synch for long since the players are always sending their new positiion, but what about the rocks and things that fly around? Do they get out of synch?
Also, do you use fixed or variable time-step updates?
Thanks,
Keith
No prob.
Yep, it’s a mixture of both client-server and p2p. It was a bit of a hazzle to set up, but not too difficult.
I’ve tried different approaches, I did try sending keystrokes to the server and then let the server send back position, velocity and such. Even with trying to predict the future on the client it had many problems. Only if you were very close to the server did it work well. The way I do it now will open up more possibilities for cheaters, but I don’t worry too much about that. You can always ban people reported as cheating… and the server could validate that the ships are moving within reasonable limits.
Code messiness - yep. I like to keep it clean, but with little time, and much you want to do it’s easy to create a mess ;).
Server continuously sends data about world state to clients. at every collision the position, and velocity of objects are sent. Also it sweeps over all world objects and sends data about a few of them in every message to the client - this way positions don’t get out of sync for too long. Also the server sends ship positions as sometimes there might be problems sending data p2p.
In the server.ini file you can specify at what interval the server will send updates to the clients, currently I use 60 ms intervals…
The sent data could be optimized quite a bit I think. I have no compression right now, and I could tune several messages. A good huffman coding scheme could probably reduce the message size alot.
Cool, thanks for the description. By the way, I made a networked game a little while ago similar-ish (but 100x worse ;)) to yours:
http://www.java-gaming.org/forums/index.php?topic=18019.0
Something about it that worked out quite well is that the coding side of it turned out quite un-messy since I roll-back the world by reverting it to it’s saved state and can also send the whole world to clients without having to write any of that code in the game objects themselves - it’s all done automatically using java.lang.reflection.
One thing that would be cool to add to mine is the peer-to-peer aspect of your game, since it minimises latency between clients.
About the time-step, I understand that the sevrer sends updates 60 times a second, but do the clients all run at 60FPS (so they update by 1/60s every frame)? Or do you use a variable time-step?
Nice little game :).
Actually I don’t send 60 times a second, rather with 60 ms delay between sends: 1000/60 = 16.6 times a second.
It’s a pretty long time between sends, but since the clients do p2p whenever an important event occurs it works fine.
The clients run as fast as they can, or as fast as the settings allow them to. In the settings you can set maximum frame rate (defaults to 200 fps).
Thanks.
Ok that’s clear.
I hope you’re not bored of my questions but if you were to make another type of game, would you re-use the network code in xsw (obviously you’d re-use some, but would the same strategy fit for other games very well?) or start out all over again and do a different strategy?
Keith
No, you’re not boring me :). I think the strategy works pretty well for an action game. If I made another action game I think I’d use something similar but I’d probably rewrite most of the networking code. If it was an entirely different game type, such as a mmorg or a turn based game I’d do something different. Probably use tcp ip instead of udp .
Hi Amaraz,
Good to see there’s still progress being made to XSW! It still is one of the most promising Java games in my opinion
About the client-server/peer-to-peer aproach, there was a good paper about that recently:
http://www.pap.vs.uni-due.de/MMVE08/papers/p11.pdf
They’ve also made modifcations to quake3 to implement their idea and showed it’s possible to reduce latency compared to a pure CS (or a pure p2p) architecture that way.
Hi thijs!
Thank you for your kind words :).
Now version 0.47 is up! This fixes some bugs that caused the server to crash sometimes in Team Death Match. Also I solved a bug which which was the cause of some computers not to be able to connect.
irrisor> if you read this, you’re welcome to try to connect again to see if it solved your problem…
it’s not solved :’( - the game does not lock up any more, but it shows an error dialog (could not connect). I tried to set the port to a fixed number and forward it through the nat, but that did not help.
Bah, not good…
It’s frustrating when people cannot connect to the server :(. I posted a link on a swedish gamer’s forum, and someone there also could not connect… I need to find a solution to this.
Do you plan to provide a JNLP link? I would like to add your game on the Java™ Game Tome as soon as possible, it would help…
goussej> That would be nice! :). Life’s been very busy for me the last couple of months, I’m in the middle of switching jobs, and alot of other things has kept me busy… So it’s been awhile since I worked with xsw or visited this forum.
I would love to get some attention to xsw, and establish a steady player base, I just find I have very little time to work to get publicity… I’ll try to find some time to make it webstartable soon.