varistor
Junior Newbie
Java games rock!
|
 |
«
Posted
2003-05-13 08:19:09 » |
|
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
|
|
|
|
|
erikd
|
 |
«
Reply #1 - Posted
2003-05-13 10:05:17 » |
|
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
|
|
|
|
Herkules
|
 |
«
Reply #2 - Posted
2003-05-13 11:39:54 » |
|
XML is really not suitable for these things.
I've seen worse. If the bandwidth is there or maybe XML got compressed - why not? Simplifies protocol development a lot....
|
|
|
|
Games published by our own members! Check 'em out!
|
|
erikd
|
 |
«
Reply #3 - Posted
2003-05-13 13:49:45 » |
|
If the bandwidth is there or maybe XML got compressed - why not? 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.
|
|
|
|
Herkules
|
 |
«
Reply #4 - Posted
2003-05-13 14:01:58 » |
|
If you have to complicate things like that to do something simple like sending coords of 2 race cars, why would you use XML?
Setup: name, dampers, tires, fuel load,.... Operative: lap times, standings, everybodies damage, obstacles,.... Can be much more than 2 coords. 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.
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.
|
|
|
|
erikd
|
 |
«
Reply #5 - Posted
2003-05-13 14:13:56 » |
|
But I wouldn't categorily exclude XML as a medium for games. I would.  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.
|
|
|
|
Herkules
|
 |
«
Reply #6 - Posted
2003-05-13 14:27:05 » |
|
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.
|
|
|
|
Herkules
|
 |
«
Reply #7 - Posted
2003-05-13 14:34:15 » |
|
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).
|
|
|
|
Abuse
|
 |
«
Reply #8 - Posted
2003-05-13 14:55:24 » |
|
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). can u post a link to the applet?
|
Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! 
|
|
|
varistor
Junior Newbie
Java games rock!
|
 |
«
Reply #9 - Posted
2003-05-13 17:54:46 » |
|
Hey guys, ty very much for replies. erikd
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?)
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 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).
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
|
|
|
|
|
Games published by our own members! Check 'em out!
|
|
erikd
|
 |
«
Reply #10 - Posted
2003-05-13 19:16:06 » |
|
this link could be useful for the drawing stuff: http://java.sun.com/docs/books/tutorial/extra/fullscreen/index.htmlThis 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.
|
|
|
|
erikd
|
 |
«
Reply #11 - Posted
2003-05-13 19:28:53 » |
|
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.
|
|
|
|
SpongeBob
Junior Member  
Who lives in a pinnapple under the sea
|
 |
«
Reply #12 - Posted
2003-05-13 19:37:34 » |
|
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
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/ 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 !!
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.....
|
|
|
|
|
SpongeBob
Junior Member  
Who lives in a pinnapple under the sea
|
 |
«
Reply #13 - Posted
2003-05-13 19:51:32 » |
|
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: http:// YaBB.cgi?board=newbies;action=display;num=1045778456;start=6
|
|
|
|
|
|
|
Abuse
|
 |
«
Reply #15 - Posted
2003-05-13 22:46:43 » |
|
hehe, I found that very same car physics applet when I was working on my 4k racing game applet  I didn't bother having a further look.... cos the handling exibited from the applet was crap  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.
|
Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! 
|
|
|
gizfcb
Junior Newbie
Java games rock!
|
 |
«
Reply #16 - Posted
2003-05-13 23:33:29 » |
|
can somebdoy tell me how to turn the car. I mean when I rotate my image it has to move in that direction.
|
|
|
|
|
|
|
gizfcb
Junior Newbie
Java games rock!
|
 |
«
Reply #18 - Posted
2003-05-14 06:00:39 » |
|
thx, no I am the same guy  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.
|
|
|
|
|
Abuse
|
 |
«
Reply #19 - Posted
2003-05-14 12:03:07 » |
|
yeah, a race game is certainly not the best starting point  Perhaps you should choose a game that doesn't have complex collision detection/resolution and complex physics  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

- 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

- 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
|
Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! 
|
|
|
gizfcb
Junior Newbie
Java games rock!
|
 |
«
Reply #20 - Posted
2003-05-14 12:35:15 » |
|
the problem is we had to choose a game and we can't change it anymore.
so we'll try to do what we can to have a game.
I have to make the applet and I hope at least to succeed to move the car in the applet. With your help I could start but I guess I am missing something. If my velocity is 1 the car stays always on the same point and when I rotate my car is jumping and not driving.
I have a Car with attributes x, y, dx, dy, vel and angle.
in the applet I change the velocity when I move up: car.setVel(1); but when I rotate then my car is jumping so I guess I am wrong again. Math is not really my best part.
|
|
|
|
|
blahblahblahh
|
 |
«
Reply #21 - Posted
2003-05-14 12:42:06 » |
|
I guess I am missing something. If my velocity is 1 the car stays always on the same point and when I rotate my car is jumping and not driving.
I have a Car with attributes x, y, dx, dy, vel and angle.
in the applet I change the velocity when I move up: car.setVel(1); but when I rotate then my car is jumping so I guess I am wrong again. Math is not really my best part. Remember that a "rotation" has to be take place about a point...by default, J2D rotates about the origin (0,0). If you haven't moved the origin (using graphics.translate(x,y)), then it'll be the top-left corner of your GUI. You probably want to rotate about the centre of the car when turning the car (for a more impressive effect, you could rotate about a point between the front-two wheels, making it look like the car "swings" around each corner - try it and see!). There is an alternative version of the rotate method that lets you specify the x and y of the point to rotate about.
|
malloc will be first against the wall when the revolution comes...
|
|
|
gizfcb
Junior Newbie
Java games rock!
|
 |
«
Reply #22 - Posted
2003-05-14 13:08:15 » |
|
the rotation is in the middle of my car. When I steer left or right without anything else the angle and the position of the car are correct but it is when I use dx and dy that the car jumps when I rotate the car.
|
|
|
|
|
Abuse
|
 |
«
Reply #23 - Posted
2003-05-14 14:04:32 » |
|
ok, how about a SpaceShip racing game  does it realy have to involve cars? 
|
Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! 
|
|
|
gizfcb
Junior Newbie
Java games rock!
|
 |
«
Reply #24 - Posted
2003-05-14 14:25:19 » |
|
maybe we could try a race with something else but what is the difference then?
|
|
|
|
|
Abuse
|
 |
«
Reply #25 - Posted
2003-05-14 14:33:36 » |
|
modelling car physics is NOT easy  Modelling any non-trivial real object is always hard. Modelling things that don't exist is much ezier, cos you can make up the handling characteristics as you go along 
|
Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! 
|
|
|
DarkwingGT
Senior Newbie 
Java games rock!
|
 |
«
Reply #26 - Posted
2003-05-14 19:16:50 » |
|
For the XML stuff I can whole heartedly recommend JDOM. It's worked like a charm for me.
I'm with Abuse on this one. With real life you have stuff like friction, wind resistance (a.k.a. wind friction), center's of gravity, the track altering the physics as we all know grass behaves differently than dirt which is different than pavement, etc. The list goes on and on.
Although unless you handed in a design doc specifically stating you'll be implementing all that, I'd just assume fixed car weight, fixed road friction, make all terrain pavement, have no weather and a bunch of other simplifications. At that point you can make your racing game almost like that space game. Only problem is that it'll feel floaty and very unrealistic. But hey, it's your interpretation, right? Who says it's got to be Gran Turismo on the first go?
|
|
|
|
|
DarkwingGT
Senior Newbie 
Java games rock!
|
 |
«
Reply #27 - Posted
2003-05-14 19:19:07 » |
|
P.S. I'd cheat on the map vs. avatar collision if I were you. First, I'd have the course be on infinite pavement and the track be simple bounding lines drawn on the pavement. That way you can just have the car "correct" it's course if it gets to the track edge. Cheating yes, but since this doesn't sound like this needs to be super advanced I'm go that way. You can always add features later.
|
|
|
|
|
lilspikey
Senior Newbie 
Computers Stole My Social Skills
|
 |
«
Reply #28 - Posted
2003-05-15 12:45:42 » |
|
If you want a _really_ simple physics engine for a racing game, I wrote a game a while ago. 2d overhead graphics, and the "cars" handle like hovercraft. It is also networked, but the code is a bit shonky (ie won't work over anything but a LAN). http://website.lineone.net/~john.montgomery/RacingGame/Got some notes on how it works too. You are more than welcome to look at the source, but I wouldn't recomend copying it, as it's a bit hacked. cheers, John
|
|
|
|
varistor
Junior Newbie
Java games rock!
|
 |
«
Reply #29 - Posted
2003-05-19 11:00:49 » |
|
wow, didn't expect so much replies  Anyway thx for tips. Meanwhile we have been able to make an applet that lets a car move over a certain field. The problem is now the collisions. How should we let the car folow a a circuit. Is there something like pixel recognition, pixelgrabber ? eg. the car should drive normal on tarmac ( grey) and should slow down or stop on gras, mud ... what do you guys suggest ? grz, varistor
|
|
|
|
|
|