Author Topic: off-road driving game  (Read 14821 times)

Offline dmouse

  • byte
  • *
  • Posts: 17
    • View Profile
off-road driving game
« on: October 12, 2008, 02:27:49 pm »



Hi all,

I just recently finished my first game with using jpct  :)

Any feedback is greatly appreciated.

Click <a href = "http://www.JavaGamePlay.com/offroadrally/rally.html"> here </a> to play.


Thanks in advance.

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: off-road driving game
« Reply #1 on: October 12, 2008, 03:42:50 pm »
The physics in this game are very good, especially momentum and centers of gravity when the vehicles are in free-fall.  I also think the play-control is comparable to other racing games, so great job on that.  If you don't mind my asking, what method you are using to keep all four of the vehicle's wheels on the terrain and the vehicle's rotation correct as it drives over various altitudes?

Offline JavaMan

  • long
  • ***
  • Posts: 231
    • View Profile
Re: off-road driving game
« Reply #2 on: October 12, 2008, 08:06:33 pm »
Nice graphics. Very fast performance only jumped on time.
Could you tell me what shape your sky is? Is it a cube or half-sphere?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: off-road driving game
« Reply #3 on: October 12, 2008, 11:13:02 pm »
I've already spotted it on Javagaming.org. It's pretty cool albeit i suck at it. I stand no chance against the AI drivers... :'(
Do you mind if i add the game to the projects page?

Offline fireside

  • double
  • *****
  • Posts: 605
    • View Profile
Re: off-road driving game
« Reply #4 on: October 13, 2008, 04:32:51 pm »
Wow.  Great game. 
click here->Fireside 7 Games<-

Offline dmouse

  • byte
  • *
  • Posts: 17
    • View Profile
Re: off-road driving game
« Reply #5 on: October 13, 2008, 05:59:36 pm »
The physics in this game are very good, especially momentum and centers of gravity when the vehicles are in free-fall.  I also think the play-control is comparable to other racing games, so great job on that.  If you don't mind my asking, what method you are using to keep all four of the vehicle's wheels on the terrain and the vehicle's rotation correct as it drives over various altitudes?

Paulscode,

Thanks for trying it out, and for the kind words.

I am use the wheel ray-casting technique to find out where each wheel would rest, if the car is on the ground.  That is to say, that you can work out the distance from (wheel.x, H, wheel.z) to the ground model, using a straight down movement vector (0,1,0). This gives you the y position the of the wheel when touching that particular point on the ground. If you do this 4 times, once for each wheel, you can then work out the x and z rotation of the car to match those 4 height coords. I believe (but don't quote me on this :), this method is used in the jpct car example, as well as the vehicle demo that comes with the jbullet physics engine, and in other car related games. It is pretty simple, efficient, and fast. I think some other solutions involve casting a volume (such as a cylinder) for greater accuracy, but rays were good enough for me.

I hope this helps, I am usually very bad at explaining these kind of things :)

Ben.

Offline dmouse

  • byte
  • *
  • Posts: 17
    • View Profile
Re: off-road driving game
« Reply #6 on: October 13, 2008, 06:03:51 pm »
Nice graphics. Very fast performance only jumped on time.
Could you tell me what shape your sky is? Is it a cube or half-sphere?

Thanks, I prefer to use a cube for the sky, simply because I am very economical with vertex and polygon counts. IMHO with a good texture, and it is hard to notice the difference, and therefore not worth the extra (albeit rather small) computation time to render a half sphere.


Offline dmouse

  • byte
  • *
  • Posts: 17
    • View Profile
Re: off-road driving game
« Reply #7 on: October 13, 2008, 06:07:44 pm »
I've already spotted it on Javagaming.org. It's pretty cool albeit i suck at it. I stand no chance against the AI drivers... :'(
Do you mind if i add the game to the projects page?

I am curious as to whether it is actually running at a playable frame rate on your EEEpc, Egon, since I am considering buying one in the near future.

Also, your comments about difficulty, as well as some comments on JavaGaming.org, are making realize that I need to tone down the difficulty a bit during the early levels.

Feel free to add it to the projects page (i would be honored), do you need anything from me with regards to this?

Thanks,

Ben.

Offline dmouse

  • byte
  • *
  • Posts: 17
    • View Profile
Re: off-road driving game
« Reply #8 on: October 13, 2008, 06:08:30 pm »
Wow.  Great game. 

Thanks, I do appreciate it.  :)

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: off-road driving game
« Reply #9 on: October 13, 2008, 07:54:22 pm »
I am use the wheel ray-casting technique to find out where each wheel would rest, if the car is on the ground.  That is to say, that you can work out the distance from (wheel.x, H, wheel.z) to the ground model, using a straight down movement vector (0,1,0). This gives you the y position the of the wheel when touching that particular point on the ground. If you do this 4 times, once for each wheel, you can then work out the x and z rotation of the car to match those 4 height coords.
That is what I was planning to do, so it is great to see a really good working example.  One potential problem I thought of is where two caticorner wheels are higher than the other two wheels:



If no special coding were in place, a scenareo like this would result in what would appear to be two wheels falling out from under the car.  I can think of 3 ways around such a problem.  The first way would be to make sure a situation like this could never occur, by ensuring that all terrains are smooth with no sudden changes in altitude (your game seems to use this method, as I could not create such a scenareo to see what would happen).  The second way would be to use a weight distribution model for the vehicle to determine which direction the vehicle would rotate due to torque.  The third way would be to set a maximum distance that a wheel can fall in relation to the other wheels, but that could lead to some pretty unrealistic situations, such as the vehicle balancing on a single wheel.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: off-road driving game
« Reply #10 on: October 13, 2008, 08:09:14 pm »
I believe (but don't quote me on this :), this method is used in the jpct car example..
Yes, it is done that way IIRC.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: off-road driving game
« Reply #11 on: October 13, 2008, 08:10:43 pm »
I am curious as to whether it is actually running at a playable frame rate on your EEEpc, Egon, since I am considering buying one in the near future.
Hard to tell, because i can't steer (as mentioned on Javagaming.org) on the EEEPC. Judging from the intro sequence, i would say that it's a little slow with normal details but runs fine on low.

Edit: That's an EEEPC 701, i.e. first generation with a CeleronM running on 630Mhz. The 900 and 901 ones should be faster because they either run on 900Mhz or are using the Atom CPU. I did a comparision (albeit based on the hardware renderer) and the 901 was 20-50 faster than my 701.
« Last Edit: October 13, 2008, 08:12:16 pm by EgonOlsen »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: off-road driving game
« Reply #12 on: October 13, 2008, 08:36:25 pm »
Feel free to add it to the projects page (i would be honored), do you need anything from me with regards to this?
Ok, i've added it. It got second place in the list. Because i wildly inserted new projects anywhere on the list in the past, i decided to reserve the first spot for my own stuff and add each new project below that. Your game is the first one that benefits from this.

Offline JavaMan

  • long
  • ***
  • Posts: 231
    • View Profile
Re: off-road driving game
« Reply #13 on: October 14, 2008, 03:23:00 am »
Nice graphics. Very fast performance only jumped on time.
Could you tell me what shape your sky is? Is it a cube or half-sphere?

Thanks, I prefer to use a cube for the sky, simply because I am very economical with vertex and polygon counts. IMHO with a good texture, and it is hard to notice the difference, and therefore not worth the extra (albeit rather small) computation time to render a half sphere.



Ok, thanks for the suggestion!

Offline dmouse

  • byte
  • *
  • Posts: 17
    • View Profile
Re: off-road driving game
« Reply #14 on: October 14, 2008, 02:14:37 pm »
I am use the wheel ray-casting technique to find out where each wheel would rest, if the car is on the ground.  That is to say, that you can work out the distance from (wheel.x, H, wheel.z) to the ground model, using a straight down movement vector (0,1,0). This gives you the y position the of the wheel when touching that particular point on the ground. If you do this 4 times, once for each wheel, you can then work out the x and z rotation of the car to match those 4 height coords.
That is what I was planning to do, so it is great to see a really good working example.  One potential problem I thought of is where two caticorner wheels are higher than the other two wheels:



If no special coding were in place, a scenareo like this would result in what would appear to be two wheels falling out from under the car.  I can think of 3 ways around such a problem.  The first way would be to make sure a situation like this could never occur, by ensuring that all terrains are smooth with no sudden changes in altitude (your game seems to use this method, as I could not create such a scenareo to see what would happen).  The second way would be to use a weight distribution model for the vehicle to determine which direction the vehicle would rotate due to torque.  The third way would be to set a maximum distance that a wheel can fall in relation to the other wheels, but that could lead to some pretty unrealistic situations, such as the vehicle balancing on a single wheel.

I wanted to make a level that would have players jumping off of the top of a steep cliff edge, but at the same time, I needed to prevent them from driving (vertically) back up the cliff side after they landed (the snow level based in Austria). If I understand you correctly above, this may be similar to the potential problem you are mentioning. My (temporary) solution was not particulary realistic, but was quick and efficient, at least until I develop something better as I continue to work on the car handling engine. This solution may be similar to the 3rd option you mentioned above, where I do some specific basic checks to see if the wheel's Y positions do not differ too much (within some tolerable threshold). As I said, it's not incredibly realistic, but served my purposes well enough, perhaps until I further evolve the engine.

Ben.