http://66.98.192.31/~jeriko/pub/delete.rar
long time since I tried dbp
basically I tried to use the dll,to see when the player obj collides with a flat surface and when with a wall,by using the collision angle..but it wasnt very successful
sync on:sync rate 0
GOSUB Time_Setup
GOSUB FlushElTime
hide mouse
`init mouseout function
mouseout(0)
`set main menu
phase = 0
`image plan
`1 pointer
`2 sp main menu
`3 quite main menu
`use memblock command for sparky dll
temp = MEMBLOCK EXIST(1)
do
`pointer
if image exist(1) = 0 then load image "pointer.png",1,1
sprite 1,mousex(),mousey(),1:set sprite priority 1,1
`----------------------------------main
if phase = 0
`mouseout function
mout = mouseout(1)
`sp
if image exist(2) = 0 then load image "sp.png",2,1
if sprite exist(2) = 0 then sprite 2,100,100,2
`quit
if image exist(3) = 0 then load image "quit.png",3,1
if sprite exist(3) = 0 then sprite 3,100,250,3
`sp
if sprite collision(1,2) = 1
if mout > 0
phase = 1
for t = 2 to 3
if sprite exist(t) = 1 then delete sprite t
if image exist(t) = 1 then delete image t
next t
endif
endif
`quit
if sprite collision(1,3) = 1
if mout > 0
for t = 2 to 3
if sprite exist(t) = 1 then delete sprite t
if image exist(t) = 1 then delete image t
next t
mouseout(2)
end
endif
endif
endif
`----------------------sprep
if phase = 1
autocam off
set camera range 0.0001,1000
`ship
load object "ship.x",1
`bearing sphere
make object sphere 3,.01
hide object 3
`player obj
make object sphere 2,.1
position object 2,limb position x(1,1),object position y(1)+.5,limb position z(1,1)
`setup ship collision
setupComplexObject 1,0,2
`vars
movespeed# = .01
grav# = .0003
`go!
phase = 2
endif
`--------------------sp
if phase = 2
`sparky
oldx# = object position x(2)
oldy# = object position y(2)
oldz# = object position z(2)
rotate object 2,0,object angle y(2)+mousemovex(),0
`WASD
if keystate(17)=1 then position object 2,newxvalue(object position x(2),object angle y(2),movespeed#),object position y(2),newzvalue(object position z(2),object angle y(2),movespeed#)
if keystate(31)=1 then position object 2,newxvalue(object position x(2),object angle y(2),-1*movespeed#),object position y(2),newzvalue(object position z(2),object angle y(2),-1*movespeed#)
if keystate(32)=1 then position object 2,newxvalue(object position x(2),object angle y(2)+90,movespeed#),object position y(2),newzvalue(object position z(2),object angle y(2)+90,movespeed#)
if keystate(30)=1 then position object 2,newxvalue(object position x(2),object angle y(2)+90,-1*movespeed#),object position y(2),newzvalue(object position z(2),object angle y(2)+90,-1*movespeed#)
`bearing sphere
position object 3,object position x(2),object position y(2),object position z(2)
x# = object position x(2)
y# = object position y(2)
z# = object position z(2)
`updates the ship collision, including scaling if allowed.
`updateObject 1
collide = intersectObject(0,0,oldx#,oldy#,oldz#,x#,y#-grav#,z#,0)
if collide > 0
point object 3,object position x(2),getStaticCollisionY(),object position z(2)
`vertcol
if wrapvalue(object angle x(3)) => 270
grav# = 0
else
`grav# = .0003
endif
else
grav# = .0003
endif
`playergrav
position object 2,object position x(2),object position y(2)-grav#,object position z(2)
`camera
position camera object position x(2),object position y(2),object position z(2)
rotate camera 0,object angle y(2),0
text 10,10,str$(collide)+"fps: "+str$(screen fps())+" colangle: "+Str$(wrapvalue(object angle x(3)))+" grav: "+str$(grav#)
endif
`GOSUB Time_Update
if upkey()=1 then move object 1,.003*NTime#
sync
loop
function infront(objno,xcoord#,zcoord#)
oppadj#=abs(object position x(objno)-xcoord#)/abs(object position z(objno)-zcoord#)
oangle#=atan(oppadj#)
if (180-oangle#)=>90 then front=0
if (180-oangle#)=<90
front=1
else
front=0
endif
endfunction front
function mouseout(ins)
if ins=0
dim mouse_click(0)
endif
if ins=1
if mouse_click(0)>0
if mouseclick()=0
mresult=mouse_click(0)
else
mresult=0
endif
endif
mouse_click(0)=mouseclick()
endif
if ins=2
undim mouse_click(0)
endif
endfunction mresult
`************************************************************************************
Time_Setup:
`************************************************************************************
IntLoops AS INTEGER = 0
Integrator AS INTEGER = 4
DIM ElTime#(Integrator)
GOSUB FlushElTime
RETURN
`************************************************************************************
Time_Update:
`************************************************************************************
`Subroutine to track framerate
IF IntLoops <= Integrator THEN IntLoops = IntLoops + 1
OldNTime# = NTime#
IF OldNtime# = 0 THEN OldNtime# = 15
FOR a = (Integrator - 1) TO 0 STEP -1
ElTime#(a+1) = ElTime#(a)
NEXT a
ElTime#(0) = TIMER() - Time#
`MAX AND MIN TIME CAPS
`MinTime# = 12 :`1000 divided by this number is the FPS Value
`MaxTime# = 22 :`1000 divided by this number is the FPS Value
`IF ElTime#(0) < MinTime#
` WaitTime# = MinTime# - ElTime#(0)
` WAIT WaitTime#
` ElTime#(0) = MinTime#
`ENDIF
`IF ElTime#(0) > MaxTime# THEN ElTime#(0) = MaxTime#
Time# = TIMER()
NTime# = 0
FOR a = 0 TO Integrator
NTime# = NTime# + ElTime#(a)
NEXT a
NTime# = NTime# / IntLoops
`RATE OF CHANGE CAPS - This will limit any large change to +/- 10%
`IF NTime# > OldNTime# * 1.1 THEN NTime# = OldNTime# * 1.1
`IF NTime# < OldNTime# * 0.9 THEN NTime# = OldNTime# * 0.9
IF NTime# = 0 then NTime# = 15: `Make sure some value is used for NTime#
adjfps# = 1000/NTime#
`AnimAdj# = TuneFPS# / adjFPS#
RETURN
`************************************************************************************
FlushElTime:
`************************************************************************************
`Subroutine to reset timing system
IntLoops = 0
Time# = TIMER() - 100
FOR a = 0 TO Integrator
ElTime#(a) = 0
NEXT a
RETURN
It's Mr.Yian to you.