Was here for a while in 2009 but life events disrupted my learning of DBP.
This is part of some code I was using for my spaceship game. It's been so long I can't remember if I really understood the code or not.
The problem is:
At 180 and 360 degrees on the Y axis the perspective changes.
Need help figuring it out if possible.
The full range is required for the project.
The Camera follows the object (in this case the bike model that comes with DBP)
Current Input Commands
1 = zoom in
2 = zoom out
mouse movement for camera view
F1 acceleration
F2 deceleration
F3 fast deceleration
W pivot down
S pivot up
D turn right
A turn left
E pivot right
Q pivot left
Rem ***** Main Source File *****
SYNC ON:SYNC RATE 30:
set display mode 1280,800,32
set camera range 1,999999999
rem backdrop on
rem color backdrop 0
rem Load Player Object
//make object box 1, 3, 5, 6
LOAD OBJECT "media\bike\bike.x",1
scale object 1,255,255,255
POSITION OBJECT 1,100,100,50
`Some of these dont apply to cutdown code.
SPD# = 0.1
ACC# = 0.0
MOD# = 0.001
PCX# = 0
PCY# = 0
PCZ# = 0
POSX# = PCSX
POSY# = PCSY
POSZ# = PCSZ
YROT# = 0
DIST# = 10
ZOOM# = 1
Make Light 1
set directional light 1, object position x(1), object position y(1), object position z(1)
`Start main DO/LOOP
DO
`frames per second
PRINT "FRAMES PER SECOND:"
PRINT SCREEN FPS()
PRINT "METERS PER SECOND SPEED:"
PRINT SPD# * 1000
`damage readout
`Movement Controls
MOVE OBJECT 1, SPD#
IF KEYSTATE(59)= 1
SPD# = SPD# + MOD#
if SPD# > 0.25 then SPD# = 0.25
ENDIF
IF KEYSTATE(60)= 1
SPD# = SPD# - MOD#
if SPD# < 0 then SPD# = 0
ENDIF
IF KEYSTATE(61)=1
DMOD# = DMOD# + MOD#
SPD# = SPD# - DMOD#
IF SPD# < 0 then SPD# = 0
IF SPD# = 0 then DMOD# = 0
ENDIF
`Camera Positioning
PCSX# = OBJECT POSITION X(1)
PCSY# = OBJECT POSITION Y(1)
PCSZ# = OBJECT POSITION Z(1)
POSX#=wrapvalue(POSX#+mousemovex()*.5)
POSY#=wrapvalue(POSY#+mousemovey()*.5)
//if ADJ# < 1 then POSY# = 1
//if ADJ# > 360 then POSY# = 360
position camera PCSX#+(sin(POSX#)*sin(POSY#)*DIST#),PCSY#+(cos(POSY#)*DIST#),PCSZ#+(cos(POSX#)*sin(POSY#)*DIST#)
//position camera PCSX#+POSX#+mousemovex(), POSY#+POSY#+mousemovey(),POSZ#+mousemovez()
point camera PCSX#,PCSY#,PCSZ#
print "POSX#",POSX#
print "POSY#",POSY#
print "POSZ#",POSZ#
POSX#=POSX#
POSY#=POSY#
POSZ#=POSZ#
IF KEYSTATE(32)= 1
RGT#=1+(KEYSTATE(32)*.5)
ENDIF
IF KEYSTATE(32)=0
RGT#=0
ENDIF
IF KEYSTATE(30)= 1
LFT#=1+(KEYSTATE(30)*.5)
ENDIF
IF KEYSTATE(30)=0
LFT#=0
ENDIF
IF KEYSTATE(31)=1
PUP#=1+(KEYSTATE(31)*.5)
ENDIF
IF KEYSTATE(31)=0
PUP#=0
ENDIF
IF KEYSTATE(17)=1
PDN#=1+(KEYSTATE(17)*.5)
ENDIF
IF KEYSTATE(17)=0
PDN#=0
ENDIF
IF KEYSTATE(16)=1
RLT#=1+(KEYSTATE(16)*.5)
ENDIF
IF KEYSTATE(16)=0
RLT#=0
ENDIF
IF KEYSTATE(18)=1
RRT#=1+(KEYSTATE(18)*.5)
ENDIF
IF KEYSTATE(18)=0
RRT#=0
ENDIF
TURN OBJECT RIGHT 1,RGT#
TURN OBJECT LEFT 1,LFT#
PITCH OBJECT UP 1,PUP#
PITCH OBJECT DOWN 1,PDN#
ROLL OBJECT RIGHT 1,RRT#
ROLL OBJECT LEFT 1,RLT#
`Camera Zoom
DIST#=wrapvalue(DIST#-keystate(2)*.5)
DIST#=wrapvalue(DIST#+keystate(3)*.5)
IF DIST# < 3
DIST# = 3
ENDIF
IF DIST# > 360
DIST# = 360
ENDIF
`(SYNC) and call the LOOP function
SYNC
LOOP
END