DBPRO
So i had to write them for my game, figured i might aswel release the code, so i edited a little and put it into a snipet...
enjoy
Using Sparkys
Sync On
Sync Rate 30
Backdrop On
autocam off
//////////////////
// SET GLOBALS //
//////////////////
global V# as float //Velocity
global A# as float //Alpha (Angle of elevation from the horizontal0
global G# as float //Gravity (-9.81)
global T# as float //Time
global P as integer //Particle Object ID
global throw as boolean //Throwing Boolean
global rotation as float //Particle Rotation
global CamAng as integer //Camera Y angle
global Xpos as double float
global Ypos as double float
global Zpos as double float
global Xstart# as float
global Ystart# as float
global Zstart# as float
global Sca# as integer
global ExpT# as integer
V# = 80
G# = (9.81)*2.5
P = 1
throw = 0
/////////////////////////////////
// MAKE FLOOR/ POSITION CAMERA //
/////////////////////////////////
make object box 5000, 10000, 10, 10000
position object 5000, 0, -100, 0
color object 5000, rgb(0, 50, 0)
set object ambience 5000, rgb(0, 50, 0)
SC_SetupObject 5000,1,2
position camera 0, -70, 0
set ambient light 40
///////////////
// MAIN LOOP //
///////////////
Do
///////////////////////
// PARTICLE CONTROLS //
///////////////////////
if MouseClick() = 1 and throw = 0
MakeParticle()
throw = 1
endif
if throw = 1 then ThrowParticle()
/////////////////////
// CAMERA CONTROLS //
/////////////////////
local yrotation as float
local xrotation as float
yrotation=mousemovex()/3.0
xrotation=mousemovey()/3.0
xrotate camera wrapvalue(xrotation+camera angle x())
yrotate camera wrapvalue(yrotation+camera angle y())
position mouse screen width()/2, Screen Height()/2
text 0, 100, "X Camera Angle : " + Str$(-Camera Angle X()+360,0)
text 0, 120, "Y Camera Angle : " + Str$(Camera Angle Y(),0)
text 0, 42, "Velocity : " + Str$(V#)
text 0, 56, "Angle : " + Str$(A#)
Sync
Loop
Function MakeParticle()
inc P
make object sphere p, 8
color object P, RGB(0, 255, 0)
set object ambience P, RGB(0, 255, 0)
position object P, Camera Position X(), Camera Position Y(), Camera Position Z()
Sc_SetupObject P, 2, 1
scale object P, 50, 70, 50
A# = -Camera angle X()
T# = 0`Timer()
V# = 80
rotation = 0
CamAng = camera angle y()
Xstart# = Camera Position X()
Ystart# = Camera Position Y()
Zstart# = Camera Position Z()
Sca# = 0
ExpT# = 0
endFunction
Function ThrowParticle()
rotation = rotation + rnd(4)
Xpos = ((V#)*((T#)/1000)*cos(A#))*sin(CamAng) + Xstart#
Ypos = ((V#)*((T#)/1000)*sin(A#)) - (0.5*(G#*((T#)/1000)^2)) + Ystart#
Zpos = ((V#)*((T#)/1000)*cos(A#))*cos(CamAng) + Zstart#
if ExpT# < 8000
position object P, Xpos, Ypos, Zpos
if V# > 1 then zrotate object P, rotation
Sc_UpdateObject P
endif
inc T#, 40
inc ExpT#, 40
text 0, 0, "x position : " + Str$(Xpos, 4)
text 0, 14, "y position : " + Str$(Ypos, 4)
text 0, 28, "time in air : " + str$((Timer()-T#)/1000, 2) + "s"
if Sc_ObjectCollision(P, 5000) and Bounce = 0
Bounce = 1
A# = A#
T# = 40`Timer()
V# = V#/1.5
Xstart# = Object Position X(P)
Ystart# = Object Position Y(P)
Zstart# = Object Position Z(P)
endif
if ExpT# > 8000
inc Sca#, 200
color object P, rgb(255, 0, 0)
set object ambience P, rgb(255, 0, 0)
scale object P, 50+Sca#, 70+Sca#, 50+Sca#
V# = 0
endif
if Sc_ObjectCollision(P, 5000) = 0 then Bounce = 0
if V# < 1 and Sca# >= 2000 then throw = 0
endFunction
Using DBPro Collision Commands
Sync On
Sync Rate 30
Backdrop On
autocam off
//////////////////
// SET GLOBALS //
//////////////////
global V# as float //Velocity
global A# as float //Alpha (Angle of elevation from the horizontal
global G# as float //Gravity (-9.81)
global T# as float //Time
global P as integer //Particle Object ID
global throw as boolean //Throwing Boolean
global rotation as float //Particle Rotation
global CamAng as integer //Camera Y angle
global Xpos as double float
global Ypos as double float
global Zpos as double float
global Xstart# as float
global Ystart# as float
global Zstart# as float
global Sca# as integer
global ExpT# as integer
V# = 80
G# = (9.81)*2.5
P = 1
throw = 0
/////////////////////////////////
// MAKE FLOOR/ POSITION CAMERA //
/////////////////////////////////
make object box 5000, 10000, 10, 10000
position object 5000, 0, -100, 0
color object 5000, rgb(0, 50, 0)
set object ambience 5000, rgb(0, 50, 0)
Set object collision on 5000
position camera 0, -70, 0
set ambient light 40
///////////////
// MAIN LOOP //
///////////////
Do
///////////////////////
// PARTICLE CONTROLS //
///////////////////////
if MouseClick() = 1 and throw = 0
MakeParticle()
throw = 1
endif
if throw = 1 then ThrowParticle()
/////////////////////
// CAMERA CONTROLS //
/////////////////////
local yrotation as float
local xrotation as float
yrotation=mousemovex()/3.0
xrotation=mousemovey()/3.0
xrotate camera wrapvalue(xrotation+camera angle x())
yrotate camera wrapvalue(yrotation+camera angle y())
position mouse screen width()/2, Screen Height()/2
text 0, 100, "X Camera Angle : " + Str$(-Camera Angle X()+360,0)
text 0, 120, "Y Camera Angle : " + Str$(Camera Angle Y(),0)
text 0, 42, "Velocity : " + Str$(V#)
text 0, 56, "Angle : " + Str$(A#)
Sync
Loop
Function MakeParticle()
inc P
make object sphere p, 8
color object P, RGB(0, 255, 0)
set object ambience P, RGB(0, 255, 0)
position object P, Camera Position X(), Camera Position Y(), Camera Position Z()
Set object collision on P
scale object P, 50, 70, 50
A# = -Camera angle X()
T# = 0`Timer()
V# = 80
rotation = 0
CamAng = camera angle y()
Xstart# = Camera Position X()
Ystart# = Camera Position Y()
Zstart# = Camera Position Z()
Sca# = 0
ExpT# = 0
endFunction
Function ThrowParticle()
rotation = rotation + rnd(4)
Xpos = ((V#)*((T#)/1000)*cos(A#))*sin(CamAng) + Xstart#
Ypos = ((V#)*((T#)/1000)*sin(A#)) - (0.5*(G#*((T#)/1000)^2)) + Ystart#
Zpos = ((V#)*((T#)/1000)*cos(A#))*cos(CamAng) + Zstart#
if ExpT# < 8000
position object P, Xpos, Ypos, Zpos
if V# > 1 then zrotate object P, rotation
endif
inc T#, 40
inc ExpT#, 40
text 0, 0, "x position : " + Str$(Xpos, 4)
text 0, 14, "y position : " + Str$(Ypos, 4)
text 0, 28, "time in air : " + str$((Timer()-T#)/1000, 2) + "s"
if Object Collision(P, 5000) and Bounce = 0
Bounce = 1
A# = A#
T# = 40`Timer()
V# = V#/1.5
Xstart# = Object Position X(P)
Ystart# = Object Position Y(P)
Zstart# = Object Position Z(P)
endif
if ExpT# > 8000
inc Sca#, 200
color object P, rgb(255, 0, 0)
set object ambience P, rgb(255, 0, 0)
scale object P, 50+Sca#, 70+Sca#, 50+Sca#
V# = 0
endif
if Object Collision(P, 5000) = 0 then Bounce = 0
if V# < 1 and Sca# >= 2000 then throw = 0
endFunction
Using Ground Y-Coordinate
Sync On
Sync Rate 30
Backdrop On
autocam off
//////////////////
// SET GLOBALS //
//////////////////
global V# as float //Velocity
global A# as float //Alpha (Angle of elevation from the horizontal
global G# as float //Gravity (-9.81)
global T# as float //Time
global P as integer //Particle Object ID
global throw as boolean //Throwing Boolean
global rotation as float //Particle Rotation
global CamAng as integer //Camera Y angle
global Xpos as double float
global Ypos as double float
global Zpos as double float
global Xstart# as float
global Ystart# as float
global Zstart# as float
global Sca# as integer
global ExpT# as integer
V# = 80
G# = (9.81)*2.5
P = 1
throw = 0
/////////////////////////////////
// MAKE FLOOR/ POSITION CAMERA //
/////////////////////////////////
make object box 5000, 10000, 10, 10000
position object 5000, 0, -100, 0
color object 5000, rgb(0, 50, 0)
set object ambience 5000, rgb(0, 50, 0)
position camera 0, -70, 0
set ambient light 40
///////////////
// MAIN LOOP //
///////////////
Do
///////////////////////
// PARTICLE CONTROLS //
///////////////////////
if MouseClick() = 1 and throw = 0
MakeParticle()
throw = 1
endif
if throw = 1 then ThrowParticle()
/////////////////////
// CAMERA CONTROLS //
/////////////////////
local yrotation as float
local xrotation as float
yrotation=mousemovex()/3.0
xrotation=mousemovey()/3.0
xrotate camera wrapvalue(xrotation+camera angle x())
yrotate camera wrapvalue(yrotation+camera angle y())
position mouse screen width()/2, Screen Height()/2
text 0, 100, "X Camera Angle : " + Str$(-Camera Angle X()+360,0)
text 0, 120, "Y Camera Angle : " + Str$(Camera Angle Y(),0)
text 0, 42, "Velocity : " + Str$(V#)
text 0, 56, "Angle : " + Str$(A#)
Sync
Loop
Function MakeParticle()
inc P
make object sphere p, 8
color object P, RGB(0, 255, 0)
set object ambience P, RGB(0, 255, 0)
position object P, Camera Position X(), Camera Position Y(), Camera Position Z()
scale object P, 50, 70, 50
A# = -Camera angle X()
T# = 0`Timer()
V# = 80
rotation = 0
CamAng = camera angle y()
Xstart# = Camera Position X()
Ystart# = Camera Position Y()
Zstart# = Camera Position Z()
Sca# = 0
ExpT# = 0
endFunction
Function ThrowParticle()
rotation = rotation + rnd(4)
Xpos = ((V#)*((T#)/1000)*cos(A#))*sin(CamAng) + Xstart#
Ypos = ((V#)*((T#)/1000)*sin(A#)) - (0.5*(G#*((T#)/1000)^2)) + Ystart#
Zpos = ((V#)*((T#)/1000)*cos(A#))*cos(CamAng) + Zstart#
if ExpT# < 8000
position object P, Xpos, Ypos, Zpos
if V# > 1 then zrotate object P, rotation
endif
inc T#, 40
inc ExpT#, 40
text 0, 0, "x position : " + Str$(Xpos, 4)
text 0, 14, "y position : " + Str$(Ypos, 4)
text 0, 28, "time in air : " + str$((Timer()-T#)/1000, 2) + "s"
if Ypos <= object position y(5000)+6 and Bounce = 0
Bounce = 1
A# = A#
T# = 40`Timer()
V# = V#/1.5
Xstart# = Object Position X(P)
Ystart# = Object Position Y(P)
Zstart# = Object Position Z(P)
endif
if ExpT# > 8000
inc Sca#, 200
color object P, rgb(255, 0, 0)
set object ambience P, rgb(255, 0, 0)
scale object P, 50+Sca#, 70+Sca#, 50+Sca#
V# = 0
endif
if Ypos > object position y(5000)+6 then Bounce = 0
if V# < 1 and Sca# >= 2000 then throw = 0
endFunction
Yours Tv.
Click my signature for free webhosting!