Is there a flaw in the DB camera system?
I've come up with two different methods of mathematically moving a projectile from the player, but niether work on DB.
The Problem:
-At each axis, the projectile is perfectly aligned with the camera.
-At each 45º variant, it is aligned.
-but inbetween the axis, and it's 45º variant, it becomes offset.
anyone aware why?
I'll include one of the methods.
sync on : autocam off : hide mouse
width=screen width()
height=screen height()
colorDepth=screen depth()
set display mode width, height, colorDepth
set mipmap mode 2
Load image "Ground.bmp", 1
make matrix 1, 1000 , 1000, 50, 50 : set matrix wireframe on 1
randomize matrix 1,3 : position matrix 1,0,0,10
prepare matrix texture 1, 1, 1, 1
delete image 1
rem Make Gun
Make object cylinder 1,2
XRotate Object 1,90
Fix object pivot 1
Scale object 1,100,100,500
position object 1,0,-7,15
Lock object on 1
Rem Make bullet
Make Object Sphere 2,.5
Hide Object 2
sync rate 100
do
hide mouse
position mouse 320,240
if upkey()=1 then x#=newxvalue(x#, cy#, .5) : z#=newzvalue(z#, cy#, .5)
if downkey()=1 then x#=newxvalue(x#, cy#, -.5) : z#=newzvalue(z#, cy#, -.5)
if rightkey()=1 then x#=newxvalue(x#, cy#+90, .28) : z#=newzvalue(z#, cy#+90, .28)
if leftkey()=1 then x#=newxvalue(x#, cy#-90, .28) : z#=newzvalue(z#, cy#-90, .28)
if controlkey()=1 and jump=0 then jump=1
REM JUMP
if jump=1 then jump#=jump#+.8
if jump#=>4 and jump=1 then jump=2
if jump=2 then jump#=jump#+.5
if jump#=>7 and jump=2 then jump=3
if jump=3 then jump#=jump#-.5
if jump=3 and jump#=<4 then jump=4
if jump=4 then jump#=jump#-.8
if jump#=<0 and jump=4 then jump=0 : jump#=0
if jump#=<0 then jump=0
y#=(get ground height(1, x#, z#)+(5+jump#))
if Mouseclick()=1 and BulletLife=0
show object 2
BulletLife=25
rem x
gosub _getmath
rem y
rem z
rem if cy#<>90 and cy#<>270 then cosy2#=cos(cy#)*cos(cy#) : else cosy2#=0
if cy#<>180 then siny2#=sin(cy#)*sin(cy#) : else siny2#=0
rem z
if vy#=<360 and vy#=>180 then az#=az# : else az#=az#*-1
rem x
if vy#=>90 and vy#=<270 then ax#=ax# : else ax#=ax#*-1
rem y
if cx#=>180 and cx#=<360 then sinx2#=sinx2# : else sinx2#=sinx2#*-1
by#=y#-.5 : bz#=z# : bx#=x#
Endif
If BulletLife > 0
Dec BulletLife
speed#=1.3
bx#=bx#+ax#
by#=by#+sinx2#
bz#=bz#+az#
position object 2, bx#, by#, bz#
Endif
cx#=wrapvalue(cx#+mousemovey())
if cx#=>90 and cx#=<180 then cx#=89
if cx#=<270 and cx#=>180 then cx#=269
cy#=wrapvalue(cy#+mousemovex())
cy2#=wrapvalue(cy2#-mousemovex())
draw to front
rotate camera cx#, cy#,0
position camera x#, y#, z#
print "cx#= ",cx#
print "cy#= ",cy#
print cy2#
print bx#
print by#
print bz#
sync
loop
_getmath:
vy#=wrapvalue(cy2#-90)
if vy#=>0 and vy#=<91 then az#=vy#/90 : ax#=1-az#
if vy#=>91 and vy#=<181 then ax#=(vy#-90)/90 : az#=1-ax#
if vy#=>181 and vy#=<271 then az#=(vy#-180)/90 : ax#=1-az#
if vy#=>271 and vy#=<361 then ax#=(vy#-270)/90 : az#=1-ax#
return
This is the longer method, which uses 'if then' statements to decide what action to take.
I've decided not too include the other, since it is basically the same, only using trig.