Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (480)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (546)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  java race game  (Read 5330 times)
0 Members and 1 Guest are viewing this topic.
Offline varistor

Junior Newbie




Java games rock!


« Posted 2003-05-13 06: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
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #1 - Posted 2003-05-13 08: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

Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #2 - Posted 2003-05-13 09:39:54 »

Quote
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....

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #3 - Posted 2003-05-13 11:49:45 »

Quote
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.

Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #4 - Posted 2003-05-13 12:01:58 »

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?


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

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

Can be much more than 2 coords.

Quote

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.

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #5 - Posted 2003-05-13 12:13:56 »

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

I would.  Smiley
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.

Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #6 - Posted 2003-05-13 12: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.

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #7 - Posted 2003-05-13 12:34:15 »

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

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

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline Abuse

JGO Knight


Medals: 12


falling into the abyss of reality


« Reply #8 - Posted 2003-05-13 12:55:24 »

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

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! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline varistor

Junior Newbie




Java games rock!


« Reply #9 - Posted 2003-05-13 15:54:46 »

Hey guys, ty very much for replies.

erikd
Quote


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
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).



hmm NIO ? does it bites Huh Embarrassed
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!
Legends of Yore - The Casual Retro Roguelike
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #10 - Posted 2003-05-13 17:16:06 »

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.

Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #11 - Posted 2003-05-13 17: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.

Offline SpongeBob

Junior Member




Who lives in a pinnapple under the sea


« Reply #12 - Posted 2003-05-13 17:37:34 »

Quote

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/

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 !!


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.....
Offline SpongeBob

Junior Member




Who lives in a pinnapple under the sea


« Reply #13 - Posted 2003-05-13 17: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
Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #14 - Posted 2003-05-13 20:24:53 »

Quote


can u post a link to the applet?


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

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline Abuse

JGO Knight


Medals: 12


falling into the abyss of reality


« Reply #15 - Posted 2003-05-13 20:46:43 »

Quote


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 Cheesy

I didn't bother having a further look.... cos the handling exibited from the applet was crap  Roll Eyes

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! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline gizfcb

Junior Newbie




Java games rock!


« Reply #16 - Posted 2003-05-13 21: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.
Offline Abuse

JGO Knight


Medals: 12


falling into the abyss of reality


« Reply #17 - Posted 2003-05-13 23:22:00 »

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

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline gizfcb

Junior Newbie




Java games rock!


« Reply #18 - Posted 2003-05-14 04:00:39 »

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.
Offline Abuse

JGO Knight


Medals: 12


falling into the abyss of reality


« Reply #19 - Posted 2003-05-14 10:03:07 »

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

Perhaps you should choose a game that doesn't have complex collision detection/resolution and complex physics Cheesy

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 Cheesy
  • 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 Cheesy
  • 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! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline gizfcb

Junior Newbie




Java games rock!


« Reply #20 - Posted 2003-05-14 10: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.
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #21 - Posted 2003-05-14 10:42:06 »

Quote
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...
Offline gizfcb

Junior Newbie




Java games rock!


« Reply #22 - Posted 2003-05-14 11: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.
Offline Abuse

JGO Knight


Medals: 12


falling into the abyss of reality


« Reply #23 - Posted 2003-05-14 12:04:32 »

ok, how about a SpaceShip racing game Cheesy

does it realy have to involve cars? Roll Eyes

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline gizfcb

Junior Newbie




Java games rock!


« Reply #24 - Posted 2003-05-14 12:25:19 »

maybe we could try a race with something else but what is the difference then?
Offline Abuse

JGO Knight


Medals: 12


falling into the abyss of reality


« Reply #25 - Posted 2003-05-14 12:33:36 »

modelling car physics is NOT easy  Roll Eyes

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 Cheesy

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline DarkwingGT

Senior Newbie




Java games rock!


« Reply #26 - Posted 2003-05-14 17: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?
Offline DarkwingGT

Senior Newbie




Java games rock!


« Reply #27 - Posted 2003-05-14 17: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.
Offline lilspikey

Senior Newbie




Computers Stole My Social Skills


« Reply #28 - Posted 2003-05-15 10: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

Offline varistor

Junior Newbie




Java games rock!


« Reply #29 - Posted 2003-05-19 09:00:49 »

wow, didn't expect so much replies  Shocked
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
Pages: [1] 2
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

atombrot (23 views)
2014-08-19 09:29:53

Tekkerue (22 views)
2014-08-16 06:45:27

Tekkerue (21 views)
2014-08-16 06:22:17

Tekkerue (12 views)
2014-08-16 06:20:21

Tekkerue (19 views)
2014-08-16 06:12:11

Rayexar (57 views)
2014-08-11 02:49:23

BurntPizza (37 views)
2014-08-09 21:09:32

BurntPizza (29 views)
2014-08-08 02:01:56

Norakomi (36 views)
2014-08-06 19:49:38

BurntPizza (66 views)
2014-08-03 02:57:17
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!