Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Greyhound Physics

Author
Message
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 13th Jul 2006 15:17
I am on the physics for my greyhound racing game, and this is hard for me to do, but I know what I want to do, and I know some ways to do it.

First to explain what the dogs should be able to do in the game, starting with a simple path, and then adding more, and more to that.

Question...1/ Run around the track which is oval whilst rotating to face the right direction each time.

Part Answer 1/ I am going to use rows of arrays which contain X/Y coordinates of an oval track. To lay these coordinates down, I am making some temporary target images/bmp on a plain. This is so that I can light up a plain to see if the dog is running towards it, and the plains also show me if I have got all of the coordinates right. I need some maths to place the plains on the track. Straight lines are easy, I just inc/dec the z depth (My track faces X/Z) Y is UP/Down not important. So I know that straight lines are easy, but placing the bends requires some sort of Pi/sin routine, and I am not good with those. So I need to place plains around the track first, and I need some sort of automated routine to do it.

Question...2/ They see/overtake each other by swapping lanes.

Part Answer 2/ My dogs will leave a collision cube behind themselves as they run, which is like a poo if you like. If the next dog hits the poo then it knows it is behind another dog. If it is travelling faster than the other dog it need to look for an alternative lane to pass the dog. That would be using the arrays again, so the arrays are in lanes half the width of a dog.

Question...3/ Rotating the dogs is half of the problem, but fishtailing them is beyond my knowledge. I don't know how to do it, but I need to do it, I want realism. Fishtailing is going round a bend so fast that the dogs back legs swing outwards.

Question...4/ Dogs can bump into each other causing a chain reaction of inertia. Don't have any ideas how to do that.

I think that I have covered the physics here that needs explaining. I have car physics code, I am trying to understand it. I hope it doesn't use the 4 wheels as part of its structure, because I just want a fast version, that can work with a rectangular box, and nothing more than that.

Thanks for any help!

Pincho.

Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 13th Jul 2006 15:35
Cube poops ehh!

That gave me an idea on how you could do this really easily.

Have the rabbit lay a scent in the same way, and have your dogs chase the scent. So because the rabbit is going round, you just need to make that go round, and the dogs just need to check where they are in the track (linear style, like how you'd check your position in a car race game) - but just having an array with the rabbit poop locations and track locations will let you chase it with the dogs, when they get past the current poop, they head towards the next.

See what I mean? - the dogs would be like Pac Man, and the rabbit the ghost after Pac grabs a power pill. The dogs would try to get to the inside lane, but with sensible limits I think you could make it work, like considering other dogs locations when pulling into the inside.

With the fishtail problem, you will need to keep a Y angle of each dog, which only covers it's direction, what I suggest is a movement direction too - so the movement direction blends to the direction it's facing so tight corners mean the dogs have a bit of drift to them.

One thing I guarantee, any example your looking at is far more complex than it needs to be, positions and speeds, that's all you have to consider with game physics. Really, if it looks authentic, then it is!, you could spend years trying to get real world physics into it, but unless you plan to give each dog different cornering properties, drift would never even affect the outcome of the race.

Animation with the drift is something that I think you might get annoyed with - because you might be limited in what sprites you can use for that - so if the dogs drift out from a corner and line up again on the inside lane, but using the same sprite angle all the time - well I reckon that might annoy you because it'd make the illusion less effective. Personally I doubt it would bother me, but I don't have the same quality standards with my artwork.

Perhaps make allowances to embellish the cornering with some dust kicking up, maybe even camera flashes from the crowd, so there's a lot going on, and the non-silky dog drift would be less noticable.

Unless of course you have enough sprite renders to make it smooth, in which case delete the last 2 paragraphs from your mind .

Aegrescit medendo
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 13th Jul 2006 17:12
Quote: "With the fishtail problem, you will need to keep a Y angle of each dog, which only covers it's direction, what I suggest is a movement direction too - so the movement direction blends to the direction it's facing so tight corners mean the dogs have a bit of drift to them."


That's what I don't get. How to keep the y angle based on the direction that the dog is facing. How do I do that?


Quote: "Unless of course you have enough sprite renders to make it smooth, in which case delete the last 2 paragraphs from your mind ."


I think it will look smooth. I am making some rotations, and the plains can also rotate a bit. I want it to look like a movie somehow.

NeX the Fairly Fast Ferret
20
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 13th Jul 2006 18:05
You could use SIN and COS to position the greyhounds... wouldn't this work better? The angling would be the sine angle +90.


Since the other one was scaring you guys so much...
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 14th Jul 2006 00:06
Ok I'll try to use Sin, once I figure out how to use it.

BLink
21
Years of Service
User Offline
Joined: 1st Jan 2004
Location: Laptop, wherever that is
Posted: 18th Jul 2006 19:38 Edited at: 18th Jul 2006 19:43
AS for the dogs bumping into eachother, I suggest giving every dog it's own "inertia" or "momentum" variable, for this example we'll use Inertia1#=100, Inertia2#=100 and Inertia3#=100, the dogs are running full speed. All of a sudden, Inertia1#=0, the dog came to a full stop. This causes a chain reaction of sorts, like you want, using collision effects, if...

Dog 2 crashes into dog 1, then Inertia1#=Inertia1#+Inertia2#/2 : Inertia2#=Inertia2#/2

Of course, you'll add in friction as well to slow down the dogs if they're stopped instead of running, so...

if Inertia1#>0 then Inertia1#=Inertia1#-1
if Inertia2#>0 then Inertia2#=Inertia2#-1
if Inertia3#>0 then Inertia3#=Inertia3#-1

But these guys aren't stopped just yet, because Dog 3 runs into them...

Inertia1#=Inertia1#+Inertia3#/3 : Inertia2#=Inertia2#+Inertia3#/3 : Inertia3#=Inertia3#/3

Of course, the number that acts as the divisor will be changed to the variable of how many dogs are being hit in the collision. You could also have it so that dog 3 hits dog 2, then dog 2 hits dog 1. Experiment with some of these and see how that turns out. It's the best way to do it that I can think of at least...

You know, like:

Inertia2#=Inertia2#+Inertia3#/2
Inertia3#=Inertia3#/2
Inertia1#=Inertia1#+Inertia2#/2
Inertia2#=Inertia2#/2

And so on. I hope that was clear enough, sometimes I just stink at conveying my ideas in small examples.

Pineapple juice, the best drink ever made.
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 18th Jul 2006 20:31
I'll try it out. Can't picture it in my head.

BLink
21
Years of Service
User Offline
Joined: 1st Jan 2004
Location: Laptop, wherever that is
Posted: 18th Jul 2006 20:36 Edited at: 18th Jul 2006 21:03
Imagine it like traincars bumping into eachother. 1 is stopped, 2 hits it, and they both go half the speed that 2 used to be going. It's basically an advanced form of that, I'll make an example if you want.

EDIT:

Try punching this into DBC, I've apparently made my first ever coding collision example.



Sorry, I didn't put in any remarks, but it ought to be pretty self explanatory after the description I gave earlier. Oh, and be sure to try running into the other blocks both when you are and when you aren't holding down the arrow keys, a skidding collision differs from a head on, continued force collision.

Pineapple juice, the best drink ever made.
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 18th Jul 2006 22:29 Edited at: 18th Jul 2006 22:32
Ok thanks I'll try it out. I have been wondering if box collision works when a greyhound rotates around a bend. Will the rectangle/box collision rotate around the bend as well? I've never used box collision yet, I always use other ways to do collision.

Edit: That works perfectly, I just need to know if it rotates properly. Dogs hit each other in the side around bends.

BLink
21
Years of Service
User Offline
Joined: 1st Jan 2004
Location: Laptop, wherever that is
Posted: 18th Jul 2006 22:48
Then I would suggest having some kind of bounce effect implemented and applied. My example is pretty one dimentional, I'll be interested to hear if you can get any 2d movement stuff working with it. Best of luck!

Pineapple juice, the best drink ever made.
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 19th Jul 2006 10:22
I am looking at rotated collision code. This code works with a cube but you can't scale the cube to make it more rectangular like a greyhound. Take a look, and look for the part where I scale the cube, I have surrounded it by `**************** these.



DVader
21
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 19th Jul 2006 20:14
Hello Pincho. Leigh is working on a quick bit of code for getting the dogs running round a circuit, he finds this sort of stuff easy I'll post it up shortly. No physics involved of course, but you can use it as a starting point.
DVader
21
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 19th Jul 2006 20:40 Edited at: 19th Jul 2006 21:55
Ok, here it is.



That works quite well for a demo. Not sure if it's what you are after but it is a good starting point.
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 19th Jul 2006 23:11 Edited at: 19th Jul 2006 23:25
Ok thanks! I'll take a look. Thanks Leigh!

Edit: That's a good start. I'll work with that, and add the physics to it if I can figure out how to add them.

This is DBC by the way, if you add anything to it. I just had to change the camera settings.

DVader
21
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 20th Jul 2006 20:36
Good, glad it's what your after. Like I said Leigh likes that sort of stuff. Leigh says the rotation is independant so you can rotate your dogs as you please as they move round the track. Yeah, we only use Pro now, but most commands cross over ok. The camera settings were an oversight, but easily fixed.
DVader
21
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 30th Jul 2006 00:09
How's it doing now? Get it to work ok? Just wondering
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 3rd Aug 2006 23:56
School holidays, I can't get on the computer often enough to do anything.

Login to post a reply

Server time is: 2025-05-25 06:22:55
Your offset time is: 2025-05-25 06:22:55