No, to mam problem z kodem w DarkBasic :P
Czy ktoś wie, na podstawie podanego niżej kodu, czemu samochód nie chce jechać ani do przodu ani do tyłu?
Oto kod gry (bez funkcji menu głównego, ekranów tytułowych oraz mojego matrixa):
`Matrix
make matrix 1,10000.0,10000.0,25,25
randomize matrix 1,50
`Arrays
dim xSpeed#(4)
dim ySpeed#(4)
dim zSpeed#(4)
dim friction#(4)
dim movedist#(4)
dim targetCount(4)
`Grawitacja
dim gravity#(0) : gravity#(0)=0.1
`Ustawienia
sync on
sync rate 40
hide mouse
autocam off
`--------------
`Ladowanie gracza
`--------------
for id=1 to 1
make object cube id,1
hide limb id,0
load object "media/car.x",10+id
scale object 10+id,20,20,20
glue object to limb 10+id,id,0
make object collision box id,-4,0,-4,4,4,4,0
next id
`--------------
`Main
`--------------
main:
for id=1 to 1
read xPos#
read zPos#
yPos#=get ground height(1,xPos#,zPos#)
read yAng
position object id,xPos#,yPos#,zPos#
rotate object id,0,0,0
rotate object id+10,0,0,0
yrotate object id,yAng
read friction#(id)
read moveDist#(id)
xSpeed#(id)=0
zSpeed#(id)=0
ySpeed#(id)=0
next id
set camera view 0,0,640,480
do
`Sterowanie
if upkey()=1 then forward=1 else forward=0
if downkey()=1 then backward=1 else backward=0
if leftkey()=1 then left=1 else left=0
if rightkey()=1 then right=1 else right=0
`Sterowanie cd.
move_player(1,forward,backward,left,right)
`Kamera
chase_cam(1)
`Sluchacz
position listener camera position x(),camera position y(),camera position z()
rotate listener camera angle x(),camera angle y(),camera angle z()
gosub update_collision
sync
loop
`Kolizje
update_collision:
for id=1 to 1
xPos#=object position x(id)
yPos#=object position y(id)
zPos#=object position z(id)
collision=object collision(id,0)
if collision>0
xPos#=xPos#-(get object collision x()/2)
zPos#=zPos#-(get object collision z()/2)
endif
Position object id,xPos#,yPos#,zPos#
next id
return
`---------
`Kamera
`---------
function chase_cam(id)
yAng#=wrapvalue(object angle y(id)+180)
xPos#=object position x(id)
yPos#=object position y(id)
zPos#=object position z(id)
camDist=15
camHeight=3
xCamPos#=newxvalue(xPos#,yAng#,camDist)
zCamPos#=newZvalue(zPos#,yAng#,camDist)
if xCamPos#>499 then xCamPos#=499
if zCamPos#>499 then zCamPos#=499
if xCamPos#
if zCamPos#
yCamPos#=get ground height(1,xCamPos#,zCamPos#)+camHeight
if yCamPos#
xCamPos#=curvevalue(xCamPos#,camera position x(),4)
yCamPos#=curvevalue(yCamPos#,camera position y(),4)
zCamPos#=curvevalue(zCamPos#,camera position z(),4)
position camera xCamPos#,yCamPos#,zCamPos#
point camera xPos#,yPos#+camHeight,zPos#
endfunction
`-------------------------
`Sterowanie
`-------------------------
function move_player(id,forward, backward, left, right)
xPos#=object position x(id)
yPos#=object position y(id)
zPos#=object position z(id)
yAng#=object angle y(id)
`Do przodu
if forward=1
xSpeed#(id)=xSpeed#(id)+newxvalue(0,yAng#,moveDist#(id))
zSpeed#(id)=zSpeed#(id)+newzvalue(0,yAng#,moveDist#(id))
endif
`Do tylu
if backward=1
xSpeed#(id)=xSpeed#(id)+newxvalue(0,yAng#,moveDist#(id)*-1)
zSpeed#(id)=zSpeed#(id)+newzvalue(0,yAng#,moveDist#(id)*-1)
endif
`W lewo
if left=1
yrotate object id,wrapvalue(yAng#-4)
endif
`W prawo
if right=1
yrotate object id,wrapvalue(yAng#+4)
endif
`--------------------------------------------------
`Fizyka itp.
`--------------------------------------------------
xSpeed#(id)=xSpeed#(id)*friction#(id)
zSpeed#(id)=zSpeed#(id)*friction#(id)
`Dodaj grawitacje
ySpeed#(id)=ySpeed#(id)+gravity#(0)
xPos#=xPos#+xSpeed#(id)
zPos#=zPos#+zSpeed#(id)
yPos#=yPos#-ySpeed#(id)
`Kolizje
if xPos#>495 then xPos#=495
if zPos#>495 then zPos#=495
if xPos#
if zPos#
if yPos#
ySpeed#(id)=ySpeed#(id)+(yPos#-get ground height(1,xPos#,zPos#))
yPos#=get ground height(1,xPos#,zPos#)
`------------------------------
`Przyklej samochód do ziemi
`------------------------------
distVal#=1.2
ang#=yAng# : frontX#=newxvalue(xPos#,ang#,distVal#) : frontZ#=newzvalue(zPos#,ang#,distVal#)
ang#=yAng#+180 : backX#=newxvalue(xPos#,ang#,distVal#) : backZ#=newzvalue(zPos#,ang#,distVal#)
ang#=yAng#+90 : leftX#=newxvalue(xPos#,ang#,distVal#) : leftZ#=newzvalue(zPos#,ang#,distVal#)
ang#=yAng#-90 : rightX#=newxvalue(xPos#,ang#,distVal#) : rightZ#=newzvalue(zPos#,ang#,distVal#)
frontHeight#=get ground height(1,frontX#,frontZ#)
backHeight#=get ground height(1,backX#,backZ#)
leftHeight#=get ground height(1,leftX#,leftZ#)
rightHeight#=get ground height(1,rightX#,rightZ#)
xAng#=curveangle((backHeight#-frontHeight#)*30,object angle x(id+10),5)
zAng#=curveangle((leftHeight#-rightHeight#)*30,object angle z(id+10),5)
rotate object id+10,xAng#,0,zAng#
`-----------------
`Samochód zjezdzajacy z górek
`-----------------
xMoveDist#=(backHeight#-frontHeight#)/30
zMoveDist#=(leftHeight#-rightHeight#)/30
xSpeed#(id)=xSpeed#(id)+newxvalue(0,yAng#,xMoveDist#)
zSpeed#(id)=zSpeed#(id)+newzvalue(0,yAng#,xMoveDist#)
xSpeed#(id)=xSpeed#(id)+newxvalue(0,yAng#-90,zMoveDist#)
zSpeed#(id)=zSpeed#(id)+newzvalue(0,yAng#-90,zMoveDist#)
endif
`Odswiez pozycje samochodu
position object id,xPos#,yPos#,zPos#
position sound id+10,xPos#,yPos#,zPos#
endfunction