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.

Newcomers DBPro Corner / I have three questions

Author
Message
DCP
18
Years of Service
User Offline
Joined: 16th Jun 2006
Location:
Posted: 22nd Jun 2006 00:13
1. How do I make acceration for a car?

2. How do I make the car able to turn only if the car is moving?

3. How do I make a splitscreen game?

Thanks a lot!
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 22nd Jun 2006 00:35
1. Have a variable for the car which is acceleration. If the control to speed up is being pressed then every cycle through your loop add the acceleration to the car's velocity. (Until the car's max velocity is reached)

2. Check if the velocity of the car is greater than zero at the same time you check for the left and right controls.

3. DBP, you can use two cameras. DBC, I'm not certain.
MSon
20
Years of Service
User Offline
Joined: 13th Jul 2004
Location: Earth, (I Think).
Posted: 24th Jun 2006 15:53
Try using Newtons car phisics, (Works for me)
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 24th Jun 2006 18:18
1: Have a variable for the acceleration and add it onto the velocity every loop (like Dream and Deatn said), and multiply the velocity every loop by a number slightly smaller than one so it has some sort of limit to it's speed.

2: Change the angle of the car by dividing the speed by the turn rate, i.e. a#=wrapvalue(a#+(speed#/2)) When you divide 0 by anything is stays at zero.

3: You can use two cameras in DBPro, and in DBC (this gets slow) every loop move the camera between the two positions that it should be at and copy the image from the screen and paste it on either side of the screen.

Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 24th Jun 2006 18:27 Edited at: 24th Jun 2006 18:29
I have something for number 2:

distance# = 2 * radius * pi * angle#/360.0
<=>
angle#/360.0 = distance# / (2 * radius * pi)
<=>
angle# = 360.0 * distance# / (2 * radius * pi)
<=>
angle# = 180.0 * distance# / (pi * radius)

So to calculate the angle when turning to the right:
TheCarsAngle# = TheCarsAngle# + (180.0*speed#/(pi*radius)
And to the left:
TheCarsAngle# = TheCarsAngle# - (180.0*speed#/(pi*radius)

(I hope I didn't calculate something wrong...)
note: pi = 3.1415926543 (and so on) and radius is the distance to the center. The bigger it is, the bigger it's turns.
note 2: This is NOT slipping.

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.

Login to post a reply

Server time is: 2024-11-27 15:34:50
Your offset time is: 2024-11-27 15:34:50