java race game

Hey peepz,

I would like to develop a simple race game. Just 2 cars that can race against eachother. It’s also should be an multiplayer game (login and stuff) + xml integration for client server communication ( car positions ). I’m realy a newbie in this. My question is : could anyone discribe how to begin on this ? plz, I realy would appreciate it.

thx in advance,

Varistor

Just a hint, drop your xml idea for client-server communication. XML is really not suitable for these things.
What’s your background? (ie are you a newbie in games programming or in java?)

Erik

[quote]XML is really not suitable for these things.
[/quote]
I’ve seen worse. If the bandwidth is there or maybe XML got compressed - why not? Simplifies protocol development a lot…

[quote]If the bandwidth is there or maybe XML got compressed - why not?
[/quote]
If you have to complicate things like that to do something simple like sending coords of 2 race cars, why would you use XML?
Furthermore, the standard XML implementation in java2 generates shitloads of garbage and is not exactly the fastest around which means you’ll have to upper your minimum requirements. Personally I’d go for a simpler, lower level solution for this.

Setup: name, dampers, tires, fuel load,…

Operative: lap times, standings, everybodies damage, obstacles,…

Can be much more than 2 coords.

Ahh, a network message here and there won’t kill you.
But agreed, I’d go for a lower level (which will be not simpler!) solution as well.

But I wouldn’t categorily exclude XML as a medium for games.

[quote]But I wouldn’t categorily exclude XML as a medium for games.
[/quote]
I would. :slight_smile:
Well seriously, for action games that is.
XML is many things you don’t need in a game. XML is meant to be flexible and convenient but it’s also heavy and slow by nature. Maybe in some games this is not a problem but XML is not the only way to write structured data.

Ok. So we still need a hint for varistor.

I suggest sending ByteBuffers via NIO as a basis.
Very simple, max. fast. That’s what I actually do.

I found some nice source for a simple drive-car-around applet. Single source file :slight_smile:

varistor, if you give me you email address, I’ll send it to you (to much to post here).

[quote]I found some nice source for a simple drive-car-around applet. Single source file :slight_smile:

varistor, if you give me you email address, I’ll send it to you (to much to post here).
[/quote]
can u post a link to the applet?

Hey guys, ty very much for replies.

erikd

well, I guess your right about the XML stuff, but the problem is that I have to implement it because its a project for school and they specifically asked to use it somewhere, perhaps any suggestions where I should use XML in this context or should’nt I use it at all. To be honoust , I’m a newbie in games programming and java. Well let’s say I have enough basic java and programming skills in general.

Herkules

[quote] Ok. So we still need a hint for varistor.

I suggest sending ByteBuffers via NIO as a basis.
Very simple, max. fast. That’s what I actually do.
I found some nice source for a simple drive-car-around applet. Single source file

varistor, if you give me you email address, I’ll send it to you (to much to post here).
[/quote]
hmm NIO ? does it bites ??? :-[
I would really appreciate it if you could sent me that source. I’ll send you a PM and thx in advance !!

best regards

this link could be useful for the drawing stuff:

http://java.sun.com/docs/books/tutorial/extra/fullscreen/index.html

This tutorial and examples show how to use fullscreen exclusive mode, which is nice and easy to get you started. You won’t be able to use it in an applet though, but you’ll get better performance.
The ‘MultiBufferTest’ in the examples section got me started with the main rendering loop.

If you have to use XML, I’d recommend looking here:

http://www.jclark.com/xml/

XP/XT is the fastest XML-parser/XSL-engine around. You probably won’t need XSL though, so especially take a look at XP (the parser).
XP/XT saved my day a while ago in a project where my app using crimson/xalan (which were standard in the java2 1.4 skd) was so utterly, terribly slow it wasn’t even funny. My app was spending >90% of the time garbage collecting for example which is quite embarassing. Garbage collecting is one thing you must prevent from happening too much in (especially) a game. After converting to XP/XT (after having tried xerces and saxon too), things suddenly got like a 1000 times faster.

You could use XML for all your variables at startup instead of using text files or hard coded values. And since your only parsing XML check out XPP (XML Pull Parser) at http://www.extreme.indiana.edu/xgws/xsoap/xpp/

To keep your project simple stick with ServerSocket and Socket. That should suffice. I gave some example code some time back…let me go look…

YaBB search works wonders. Anyhow, the link below has example code for a simple server and client. It was written to test the speed of Java socket implementation. As you can see from my results (on a local loopback) it was not very impressive. But it may work for what you need:


YaBB.cgi?board=newbies;action=display;num=1045778456;start=6

Hm, the source file is on my desktop, … let me see… google google google … ah, there it was:

http://www.cs.uni-magdeburg.de/~sodeike/java/CarPhysics/CarPhysics.html

hehe, I found that very same car physics applet when I was working on my 4k racing game applet :smiley:

I didn’t bother having a further look… cos the handling exibited from the applet was crap ::slight_smile:

I’m revisiting the area again actually - doing a rewrite of the 4k applet. So in a few days time, I might be able to give abit more info on a decent way of dealing with car physics.

can somebdoy tell me how to turn the car. I mean when I rotate my image it has to move in that direction.

is it just co-incidence that these same questions are being asked in the Sun java game programing forum…

http://forum.java.sun.com/thread.jsp?forum=406&thread=398673&tstart=0&trange=15

hmm, same username, I think not :wink:

thx,

no I am the same guy :wink:

Varistor and I have to make agame for java at school. We had to make a game with a swing applet and it has to be mutliplayer.

We did choose a race game and I think now that was not the best choice.

But thank you very much. The biggest problem was the handling of the car. I’m gonna give it a try on your way.

I would never think to this methode. It’s our first game.

yeah, a race game is certainly not the best starting point :o

Perhaps you should choose a game that doesn’t have complex collision detection/resolution and complex physics :smiley:

add to that networking… you’ve made yourself quite a tough challenge.

Why don’t you do something involving Space & SpaceShips.

It simplifies a great many things :-

[] there is no need for avatar<->map collision detection (unlike a racing game, where you’ve got a track)
[
] Weapons can be modelled as point particles, ships can be modelled as Circles, a classic case for pythagoras.
[] Physics in space is oh so much simpler :smiley:
[
] for Collision resolution between players, you can simply use Ball physics. (there are plenty of sources on the net, where you can get info on how to do this)
[] the artistic demands for a space shooter are considerably less :smiley:
[
] if you find yourself short of things to do, there are lots of simple ways to expand it.

  1. Floating scenery/debris
  2. Gravity
  3. Computer players
    etc etc