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.

The 20 Line Challenge / Code to control proper Car physics

Author
Message
The ARRAYinator
18
Years of Service
User Offline
Joined: 13th Aug 2005
Location:
Posted: 7th Oct 2005 02:44
Here is some code for proper Car physics please leave feedback!


sync on:sync rate 30:traction#=0.95:radius#=100.5:pi#=3.141:do:xpos#=object position x(2):zpos#=object position z(2):ypos#=object position y(2):yAng#=object angle y(2):if upkey()=1 and speed#<15 then inc speed#,0.53:if downkey()=1 then speed#=speed#*0.85: speed#=speed#*traction#:xpos#=newxvalue(xpos#,yAng#,speed#):zpos#=newzvalue(zpos#,yAng#,speed#)
if leftkey()=1:yrotate object 2,wrapvalue(yAng#-(180*speed#/(pi#*radius#))):endif:if rightkey()=1:yrotate object 2,wrapvalue(yAng#+(180*speed#/(pi#*radius#))):endif
if speed#<0.5 then speed#=0.0
id=2
yAng#=wrapvalue(object angle y(id)+180)
camDist=12
camHeight=9
xCamPos#=newxvalue(xPos#,yAng#,camDist)
zCamPos#=newzvalue(zPos#,yAng#,camDist)
yCamPos#=get ground height(1,xCamPos#,zCamPos#)+camHeight
if yCamPos#<yPos#+camHeight then yCamPos#=yPos#+camHeight
xCamPos#=curvevalue(xCamPos#,camera position x(),4)
yCamPos#=curvevalue(yCamPos#,camera position y(),4)
zCamPos#=curvevalue(zCamPos#,camera position z(),4)
position object 2,xpos#,3.75,zpos#
position camera xCamPos#,yCamPos#,zCamPos#:point camera xPos#,yPos#+camHeight,zPos#
sync
loop
Deep Thought 42
18
Years of Service
User Offline
Joined: 31st Jul 2005
Location: New Jersey, USA
Posted: 9th Oct 2005 05:29
This should be in the code snippets board if it isn't a game.

"There are no stupid questions, just a lot of inquisitive idiots."
The Nerd
19
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 10th Oct 2005 15:12
Quote: " This should be in the code snippets board if it isn't a game."


No We're do you get that idea from?

PanzerGameshere
Free Particle Engine For dbpro :
here
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 10th Oct 2005 19:33
Here's the code I made a year ago.

http://www.thegamecreators.com/?m=codebase_view_code&i=d4b2b9d895e0b18d55532909bbef15c0

Immunity and Annihalation makes Immunihalation...

Login to post a reply

Server time is: 2024-02-21 10:55:41
Your offset time is: 2024-02-21 10:55:41