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 Professional Discussion / moving from x,y,z to newx,newy,newz problem

Author
Message
fubarpk
Retired Moderator
20
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 15th Jun 2005 00:14
I want to be able to move automatically to new starting position and this is the code I have but it dont work properly. Sometimes it moves off the map and sometimes it works I know the placeplayer routine works correctly.

rem the map is a random matrix 1000 * 1000
newx#=x#:newz#=z#
gosub placePlayer:show object player1
rem place player creates x# y# and z# at new coords
rem This is where I want the camera and player to end up
ang#=object angle y(player1)
repeat
if newx#>x# then newx#=newxvalue(newx#,ang#,-1)
if newx#<x# then newx#=newxvalue(newx#,ang#,1)
if newz#>z# then newz#=newxvalue(newz#,ang#,-1)
if newz#<z# then newz#=newxvalue(newz#,ang#,1)
y#=get ground height(mymatrix,newx#,newz#)
position object player1,newx#,y#,newz#
position camera newx#,y#,newz#
SET CAMERA TO FOLLOW newx#,newy#,newz#,ang#+(180),cdist,chght,csmth,1
sync
until x#<(newx#+1) and x#>(newx#-1) and z#<(newz#+1) and z#>(newz#-1)

fubar
fubarpk
Retired Moderator
20
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 15th Jun 2005 21:17
I fixed the problem basically I couldn't use newx newy and newzvalue because my angle wasn't pointing in the direction I wanted to go. The problem with programming at early hours of the morning you can produce some bad code well atleast I do. Below is my solution.


oldx#=x#:oldz#=z#
ang#=object angle y(player1)
gosub placePlayer:show object player1
gosub showRadar
repeat
`PDist=calcDistance(oldx#,y#,oldz#,x#,y#,z#)
if oldx#>x# then dec oldx#
if oldz#>z# then dec oldz#
if oldx#<x# then inc oldx#
if oldz#<z# then inc oldz#
y#=get ground height(mymatrix,oldx#,oldz#)
position camera oldx#,y#,oldz#
SET CAMERA TO FOLLOW oldx#,y#,oldz#,ang#+(180),cdist,chght,csmth,1
`print PDist
`set particle frequency so explosions die out
paste image HUD,2,2
t=0:repeat
if computer(t).particleFrequency>0 then dec computer(t).particleFrequency,5:set particle emissions computer(t).missileObject,computer(t).particleFrequency
inc t:until t>level-1
POSITION LISTENER oldx#,y#,oldz#
sync
until oldx#<(x#+1) and oldx#>(x#-1) and oldz#<(z#+1) and oldz#>(z#-1)

fubar

Login to post a reply

Server time is: 2025-06-09 04:31:48
Your offset time is: 2025-06-09 04:31:48