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 / Does anyone know if they can code a racing game with drifting ?

Author
Message
JNice013
21
Years of Service
User Offline
Joined: 10th Jan 2004
Location:
Posted: 23rd Jan 2004 02:31
For those of you that don't know what drifting is it's when you accelerate into a corner and induce sliding and break traction of the tires with the ground and slide your car sideways through a corner and then towards the straight you straighten the car back out with counter steering.

I am creating a 2D racing game and I wanted to know would I be able to turn the car and if it turns to much it begins sliding and harder to turn the other way. So far I am trying to code a drag racing game and if I could add drifting that would be great. If someone knows how I could do that could you help me out or work together with me to create that.

The game has a storyline similar to initial D with rivals and teams and if it has both drag and drift it ould be alot better than just dragging. Alot of cars are already done about 30. The members at the Manga Cars forum have work together with me and posted alot of cars that I could use.

http://www.smoothedge.net/mc/forum/

"The Infamous J Nice"
Travis
21
Years of Service
User Offline
Joined: 9th Nov 2003
Location: West Aust.
Posted: 23rd Jan 2004 03:53
yeah its possible u just needa think about it
Don Malone
22
Years of Service
User Offline
Joined: 27th Apr 2003
Location: Birmingham, Alabama
Posted: 23rd Jan 2004 05:43
That's Travis the helpful everybody.
Let's hear it for Travis.

It is possible (heck for some, even easy) to code the behavior in a 2D Game. What you have to address is traction of the vehicle, and then work out a point where you break traction. That is easy enough. The hard part is working on balance of the car.

You will most likely want to track a variable for wheel spin and using traction, speed and acceleration figure out a band where wheel spin actually moves the car forward and above that range have the car slip right more than usual. In the Dirt Track Racing games which do drift very well, to high a wheel speed does not grip the track enough to allow any forward bite (or acceleration). Find the range where you want forward bite should allow you to figure out how you want to handle drift.

I know that there is no code or examples to work with but instead a discussion of the effect. I think you are a better programmer than I so you can code something that you can tweak and decide the formula that suits your needs.

Good luck.

Wasting CPU Cycles since the 286 was a hot machine.
Travis
21
Years of Service
User Offline
Joined: 9th Nov 2003
Location: West Aust.
Posted: 23rd Jan 2004 08:23
well i thought hey i could explain how to do this, but i couldnt get it out properly so i just left it

ud need to have the front and back wheels as seperate points then u can say if ur going into a slide move the back one out a bit and by using the angle between the two points plus the angle that ur turning to rotate the car object or somthing and the amout u slide is determined by the speed ur going and how much uv turned scince the last loop

there is that more helpful?
JNice013
21
Years of Service
User Offline
Joined: 10th Jan 2004
Location:
Posted: 30th Jan 2004 02:03
It would be in 2D not in 3D so I don't think I would need to have 4 seperate wheel points but rather 2 points for front and back. The front would turn first and when the front turns to a certain point the back begins to slide. Note that It would also be from a semi top down angle. Also the more the accel is being pressed the more the car will slide. I don't know how to exactly put that into a formula.

"The Infamous J Nice"
Travis
21
Years of Service
User Offline
Joined: 9th Nov 2003
Location: West Aust.
Posted: 30th Jan 2004 10:28
i have no idea how to put it into a formula ...it would be pretty difficult to work out maybe some one would give it a go...id liek to see what ppl come up with
bibz1st
22
Years of Service
User Offline
Joined: 2nd Jan 2003
Location:
Posted: 31st Jan 2004 13:22
this is what I have come up with,it is not accurate and is also not in 2d but I'm sure it could be used somehow.
you will need an image of your own, I used one with straight lines on to get a better idea of how my "car" was drifting.
I wanted to take this further by using the front wheels as the basis of direction, this is ok whilst actually moving but when the "car" is stationary and you turn the wheels, they turn a full 360 degrees, how can I stop them turning more than say 60 in both directions?
rob
Travis
21
Years of Service
User Offline
Joined: 9th Nov 2003
Location: West Aust.
Posted: 1st Feb 2004 14:59 Edited at: 1st Feb 2004 15:05
just say somthing like: if wheel_angle = 61 then wheel_angle = 60 and the same for -61 and -60


[EDIT]
just ran it...
that is awsome...now im putting down everything and making a cool race game just so i can play with that code id like to see what else u do on it
bibz1st
22
Years of Service
User Offline
Joined: 2nd Jan 2003
Location:
Posted: 7th Feb 2004 18:33
tried that but it just angles the front wheels relative to the "world" rather than the car body, if you see what I mean.
hope you can take it further, I am by no means an experienced programmer and am glad when something I have struggled over is appreciated.
bibz1st
22
Years of Service
User Offline
Joined: 2nd Jan 2003
Location:
Posted: 29th Feb 2004 15:25
been playing around
[/code]
set display mode 800,600,16
hide mouse
autocam off
sync rate 60
sync on
disable escapekey

make object box 1,5,3,15
position object 1,1000,1.5,0

load image "t2.bmp",1
make matrix 1,2000,2000,50,50
prepare matrix texture 1,1,1,1

position camera 900,90,1000
do
point camera x#,y#,z#
x#=object position x(1):z#=object position z(1):y#=object position y(1)

if speed#>0.0 then yang# = WrapValue(yang#+MousemoveX()*(speed#*0.08))
dir#=curveangle(yang#,dir#,speed#*4)

x#=newxvalue(x#,dir#,speed#):z#=newzvalue(z#,dir#,speed#)

if mouseclick()=1 and speed#<4.0 then inc speed#,0.05

if speed#>0.0
if mouseclick()=0 then dec speed#,0.005
if mouseclick()=2 then dec speed#,0.05
if speed#<0.0 then speed#=0.0
endif

position object 1,x#,y#,z#
yrotate object 1,curveangle(yang#,yang#,2)

if scancode()=1 then gosub endprog
sync

loop

endprog:
for x=1 to 100
if object exist(x) then delete object x
if sound exist(x) then delete sound x
if matrix exist(x) then delete matrix x
next x
end
return
[code]

Login to post a reply

Server time is: 2025-06-02 09:45:08
Your offset time is: 2025-06-02 09:45:08