Ok, I was messing with chafari's code, trying to eliminate the spheres entirely and hopefully add jumping off ramps and rolling the vehicle.
Here's what I got:
remstart
this is a re-engineering of a code snippet by chafari
see: http://forum.thegamecreators.com/?m=forum_view&t=101199&b=6
The principle uses three dummy objects based on the location of a vehicle
These objects were originally snapped to the ground, and the vehicle
was rotated based on the height of these dummy spheres. I am hoping to
eliminate the objects and only use test points, as well as allow the test
points to "bounce", allowing for the car to jump, and not be stuck to the
ground
remend
`Make ground texture
create bitmap 1,50,50:for i= 1 to 1550:ink rgb(230,95,55),0:line rnd(60),i,i,rnd(130)
next i:blur bitmap 1,6:get image 1,10,10,50,50:delete bitmap 1
make matrix 1,10000,10000,25,25
prepare matrix texture 1,1,1,1
randomize matrix 1,350.0
update matrix 1
CarID = 1
make object box CarID, 40,20,50
a# = 0 `Angle of car
x# = 5000 `Location X
Z# = 5000 `Location Z
bm1# = 0 `Movement of ball 1
bm2# = 0 `...2 ie, a (-) value indicates movement downward
bm3# = 0 `...3
by1# = get ground height(1,newxvalue(object position x(CarID),a# + 0, 35), newzvalue(object position z(CarID),a# + 0, 35))
by2# = get ground height(1,newxvalue(object position x(CarID),a# + 90, 35), newzvalue(object position z(CarID),a# + 90, 35))
by3# = get ground height(1,newxvalue(object position x(CarID),a# + 270, 35), newzvalue(object position z(CarID),a# + 270, 35))
remstart B1
_____
|this |
| is |
|the |
|_car_|
B3 B2 remend
speed# = 2
sync on:sync rate 60
do
Gosub _User_IN
Gosub _Physics
Gosub _Camera
Sync
Loop
_User_In:
if leftkey() = 1 then dec A#, 0.5
if rightkey() = 1 then inc A#, 0.5
if upkey() = 1 then move object carID, 10
Return
_Physics:
x# = object position x(CarID)
z# = object position z(carID)
Rotate object CarID,0,a#,0
old1# = by1#
old2# = by2#
old3# = by3#
by1# = get ground height(1,newxvalue(object position x(CarID),a# + 0, 35), newzvalue(object position z(CarID),a# + 0, 35))
by2# = get ground height(1,newxvalue(object position x(CarID),a# + 90, 35), newzvalue(object position z(CarID),a# + 90, 35))
by3# = get ground height(1,newxvalue(object position x(CarID),a# + 270, 35), newzvalue(object position z(CarID),a# + 270, 35))
y# = get ground height(1,X#,Z#)
Position object CarID, x#,y#,z#
point object carID,newxvalue(object position x(CarID),a# + 0, 35), by1#, newzvalue(object position z(CarID),a# + 0, 35)
roll object left CarID,y#-by3#
roll object right CarID,y#-by2#
move object up carID, 10
Return
_Camera:
remstart
Position camera object position x(carID), object position y(carID), object position z(carID)
set camera to object orientation carID
pitch camera down 40
move camera -120
remend
cx#=newxvalue(x#,wrapvalue(a#+180),300)
cz#=newzvalue(z#,wrapvalue(a#+180),300)
cy#=get ground height(1,cx#,cz#)+100.0
position camera cx#,cy#+200,cz#
`enfoca la cámara al objeto
point camera x#,y#,z#
Return
However, I don't know why it insists on rolling down hill. It's a nice bug, but I need to slow it down. Well, it's a work in progress...
Updated:
remstart
this is a re-engineering of a code snippet by chafari
see: http://forum.thegamecreators.com/?m=forum_view&t=101199&b=6
The priciple uses three dummy objects based on the location of a vehichle
These objects were origionally snapped to the ground, and the vehichle
was rotated based on the height of these dummy spheres. I am hoping to
eliminate the objects and only use test points, as well as allow the test
points to "bounce", allowing for the car to jump, and not be stuck to the
ground
remend
`Make ground texture
create bitmap 1,50,50:for i= 1 to 1550:ink rgb(230,95,55),0:line rnd(60),i,i,rnd(130)
next i:blur bitmap 1,6:get image 1,10,10,50,50:delete bitmap 1
make matrix 1,10000,10000,25,25
prepare matrix texture 1,1,1,1
randomize matrix 1,350.0
update matrix 1
CarID = 1
make object box CarID, 40,20,50
a# = 0 `Angle of car
x# = 5000 `Location X
Z# = 5000 `Location Z
bm1# = 0 `Movement of ball 1
bm2# = 0 `...2 ie, a (-) value indicates movement downward
bm3# = 0 `...3
by1# = get ground height(1,newxvalue(object position x(CarID),a# + 0, 35), newzvalue(object position z(CarID),a# + 0, 35))
by2# = get ground height(1,newxvalue(object position x(CarID),a# + 90, 35), newzvalue(object position z(CarID),a# + 90, 35))
by3# = get ground height(1,newxvalue(object position x(CarID),a# + 270, 35), newzvalue(object position z(CarID),a# + 270, 35))
remstart B1
_____
|this |
| is |
|the |
|_car_|
B3 B2 remend
speed# = 2
grav1# = 0
grav2# = 0
grav3# = 0
gravAcc# = 0.25
sync on:sync rate 60
do
GOSub _UserIn
Gosub _Physics
Gosub _Camera
Sync
Loop
_UserIn:
if leftkey() = 1 then dec A#, 1.3
if rightkey() = 1 then inc A#, 1.3
if upkey() = 1 and speed# < 10 then inc speed#, 0.3
if downkey() = 1 and speed# > -4 then dec speed#, 0.3
if upkey() = 0 and downkey() = 0
if speed# > 0 then dec speed#, 0.1
if speed# < 0 then inc speed#, 0.1
EndIF
Return
_Physics:
Rotate object CarID,0,a#,0
old1# = by1#
old2# = by2#
old3# = by3#
by1# = get ground height(1,newxvalue(object position x(CarID),a# + 0, 35), newzvalue(object position z(CarID),a# + 0, 35))
by2# = get ground height(1,newxvalue(object position x(CarID),a# + 90, 35), newzvalue(object position z(CarID),a# + 90, 35))
by3# = get ground height(1,newxvalue(object position x(CarID),a# + 270, 35), newzvalue(object position z(CarID),a# + 270, 35))
if by1# < old1# - grav1# then by1# = old1# - grav1#: inc grav1#, GravAcc#
if by2# < old1# - grav2# then by2# = old1# - grav2#: inc grav2#, GravAcc#
if by3# < old1# - grav3# then by3# = old1# - grav3#: inc grav3#, GravAcc#
y# = ( by1# + by2# + by3#) / 3
Position object CarID, x#,y#,z#
`MOVEMENT MUST GO HERE!!!!!! -don't ask me why...
pitch# = y# - by1#
move object carID, speed# + (pitch# * 0.46)
point object carID,newxvalue(object position x(CarID),a# + 0, 35), by1#, newzvalue(object position z(CarID),a# + 0, 35)
roll object left CarID,y#-by3#
roll object right CarID,y#-by2#
x# = object position x(CarID)
z# = object position z(carID)
move object up carID, 10
Return
_Camera:
remstart
Position camera object position x(carID), object position y(carID), object position z(carID)
set camera to object orientation carID
pitch camera down 40
move camera -120
remend
cx#=newxvalue(x#,wrapvalue(a#+180),300)
cz#=newzvalue(z#,wrapvalue(a#+180),300)
cy#=get ground height(1,cx#,cz#)+100.0
position camera cx#,cy#+200,cz#
`enfoca la cámara al objeto
point camera x#,y#,z#
Return
Now the falling down hill is on purpose, and adjustable. See line 103. You can actually get air, but you can't tell from this view
Plus, now it has a realistic gass pedal w/ upkey
"There will always be evil, for, without evil, the good shall lose their virtue."