here's the WHOLE code.
Rem Project: Dark Basic Pro Project
Rem Created: Tuesday, August 03, 2010
Rem ***** Main Source File *****
sync on : sync rate 60
autocam off
make vector3 1
set text font "MS Gothic"
set text size 10
set text to bold
type player
health# as float
actualhealth# as float
maxhealth# as float
magic# as float
actualmagic# as float
maxmagic# as float
X# as float
Y# as float
Z# as float
Speed# as float
TSpeed# as float
id as integer
endtype
type enemy
health# as float
actualhealth# as float
maxhealth# as float
magic# as float
actualmagic# as float
maxmagic# as float
X# as float
Y# as float
Z# as float
Speed# as float
TSpeed# as float
id as integer
endtype
global p as player
global e as enemy
p.actualhealth#=10000
p.health# = p.actualhealth#
p.maxhealth# = 1000000.0
p.actualmagic#=10000
p.magic# = p.actualmagic#
p.maxmagic# = 1000000.0
p.X# = 0.0
p.Y# = 1.0
p.Z# = 0.0
p.id = 1
e.actualhealth#=10000
e.health# = e.actualhealth#
e.maxhealth# = 1000000.0
p.actualmagic#=10000
e.magic# = e.actualmagic#
e.maxmagic# = 1000000.0
e.X# = 0.0
e.Y# = 1.0
e.Z# = 0.0
e.id = 50
img=rnd(e.id*1000)
img2=rnd(e.id*1000)
img3=rnd(e.id*1000)
obj=rnd(e.id*1000)
obj2=rnd(e.id*1000)
obj3=rnd(e.id*1000)
`load test tube
load image "tube8.png", img,1
load image "circle.png", img2,1
load image "circle.png", img3,1
make object plain obj,2,1
set object transparency obj,1
set alpha mapping on obj,100
texture object obj,img
set object light obj,0
position object obj,0,2,0
make object plain obj2,.2,.2
set object transparency obj2,1
set alpha mapping on obj2,100
texture object obj2,img2
set object light obj2,0
position object obj2,-.4,1.97,-.01
make object plain obj3,.2,.2
set object transparency obj3,1
set alpha mapping on obj3,100
texture object obj3,img3
set object light obj3,0
position object obj3,.4,1.97,-.01
global maxhealth#
maxhealth#=p.maxhealth#
global maxmagic#
maxmagic#=p.maxmagic#
`SKY
make object sphere 10,1000
set object cull 10,0
color object 10,rgb(68,207,252)
set object smoothing 10,100
`PLAYER
make object cube p.id,1
`ENEMY
make object cube e.id,1
`PLAYER HEALTH
Make Object Plain p.id+1,1.25,.1
set object transparency p.id+1,1
fix object pivot p.id+1
position object p.id+1,0,0,10
set object light p.id+1,0
SET OBJECT FILTER p.id+1,0
set object smoothing p.id+1,100
CreateBar(p.id+1,p.id,0,0,100,10,p.health#,0xCCFFFFFF,0x33FFFFFF, p.maxhealth#)
hide object p.id+1
`PLAYER MAGIC
Make Object Plain p.id+2,1.25,.1
set object transparency p.id+2,1
fix object pivot p.id+2
position object p.id+2,0,4,2
set object light p.id+2,0
SET OBJECT FILTER p.id+2,0
set object smoothing p.id+2,100
CreateBar(p.id+2,p.id,0,0,100,10,p.magic#,0xCCFFFFFF,0x33FFFFFF, p.maxmagic#)
hide object p.id+2
`ENEMY HEALTH
Make Object Plain e.id+1,1.25,.1
set object transparency e.id+1,1
fix object pivot e.id+1
position object e.id+1,0,0,5
set object light e.id+1,0
SET OBJECT FILTER e.id+1,0
set object smoothing e.id+1,100
CreateBar(e.id+1,e.id,0,0,100,10,e.health#,0xCCFFFFFF,0x33FFFFFF, e.maxhealth#)
hide object e.id+1
global u#
global v#
make mesh from object 1,p.id+1
`make mesh from object 2,obj
`make mesh from object 3,obj2
`make mesh from object 4,obj3
append limb p.id+1,1
delete mesh 1
`THE MAIN LOOP
DO
if keystate(19)
inc u#,.009
scroll object texture obj,u#,0
else
if keystate(20)
dec u#,.009
scroll object texture obj,u#,0
else
if keystate(21)
inc v#,.009
scroll object texture obj,0,v#
else
if keystate(22)
dec v#,.009
scroll object texture obj,0,v#
endif
endif
endif
endif
if u#>.008 then u#=.008
if u#<-.008 then u#=-.008
if v#>.008 then v#=.008
if v#<-.008 then v#=-.008
set camera to follow object position x(p.id),object position y(p.id),object position z(p.id),0,4,2,20,1
move object up p.id,(keystate(16)-keystate(18))*.1
`Update and position enemy health
if GetDist(0,0,p.id,e.id)<10 and GetDist(1,0,obj,0)>1.6
position object e.id+1,object position x(e.id),object position y(e.id) + (object size y(e.id)+1)/2.0,object position z(e.id)
lock object on e.id+1
Show Object e.id+1
else
hide Object e.id+1
endif
move object p.id,(keystate(17)-keystate(31))*.1
turn object left p.id,(keystate(30)-keystate(32))*1
if object visible(p.id+1)
if keystate(44) and (p.health# > 0.0)
dec p.health#,10000
if p.health#>p.maxhealth#
p.health#=p.maxhealth#
endif
endif
if keystate(45) and (p.health# < maxhealth#)
inc p.health#,10000
if p.health#<0
p.health#=0
endif
endif
endif
if GetDist(0,0,p.id,e.id)<10 and GetDist(1,0,obj,0)>1.6
position object p.id+1,object position x(p.id),object position y(p.id) + (object size y(p.id)+1)/2.0,object position z(p.id)
position object obj,object position x(p.id+1),object position y(p.id+1)+.04,object position z(p.id+1)
position object obj2,object position x(p.id+1)-.6,object position y(p.id+1)+.02,object position z(p.id+1)-.01
position object obj3,object position x(p.id+1)+.6,object position y(p.id+1)+.02,object position z(p.id+1)-.01
Show Object p.id+1
Show Object obj
Show Object obj2
Show Object obj3
else
hide Object p.id+1
hide Object obj
hide Object obj2
hide Object obj3
endif
`Update and position player health
remstart
if GetDist(0,0,p.id,e.id)<=10
position object p.id+2,object position x(p.id),object position y(p.id) + (object size y(p.id))/4,object position z(p.id)
Show Object p.id+1
Show Object p.id+2
else
hide Object p.id+1
hide Object p.id+2
endif
remend
text 10,10,"GetDist(0,0,p.id,e.id):"+str$(GetDist(0,0,p.id,e.id))
text 10,30,"u#:"+str$(u#)
text 10,50,"v#:"+str$(v#)
text 10,70,"GetDist(1,0,obj,0):"+str$(GetDist(1,0,obj,0))
text 10,90,"ObjFacing:"+str$(ObjFacing(p.id))
SYNC
LOOP
function rgbalpha(r,g,b,a)
c = (a and 0xff) << 24 or ((r and 0xff) << 16) or ((g and 0xff) << 8) or (b and 0xff)
endfunction c
function CreateBar(obj, id, x, y, width, height, P#,c1=0xCCFFFFFF,c2=0x33FFFFFF, max#)
if bitmap exist(id)=0
CREATE BITMAP id,width,height
endif
set current bitmap id
P# = P#/max#
if P#<0.0 then P#=0.0
rem gradient bar
seg = width / 3
box x, y, x+seg, y+height, rgbalpha(255,0,0,255),rgbalpha(255,0,0,255),rgbalpha(170,85,0,255),rgbalpha(170,85,0,255)
box x+seg, y, x+seg+seg, y+height, rgbalpha(170,85,0,255),rgbalpha(170,85,0,255),rgbalpha(85,170,0,255),rgbalpha(85,170,0,255)
box x+seg+seg, y, x+width, y+height, rgbalpha(85,170,0,255),rgbalpha(85,170,0,255),rgbalpha(0,255,0,255),rgbalpha(0,255,0,255)
` rem empty bit
` ink rgb(92,92,92),0
` box x+width*P#, y, x+width, y+height
rem highlight
c3 = c1
c4 = c2
box x, y, x+width, y+height*0.5, c3,c4,c3,c4
ink rgb(255,255,255),0
center text width/2,0,str$(int(P#*max#))+"/"+str$(int(max#))
GET IMAGE id,0,0,width,height,1
set current bitmap 0
if object exist(obj)
texture object obj,id
else
exitfunction
endif
endfunction
function GetDist(camon,cam,obj1,obj2)
select camon
case 0
if obj1<>0 and obj2<>0
x1#=Object Position X(obj2)
y1#=Object Position Y(obj2)
z1#=Object Position Z(obj2)
x2#=Object Position X(obj1)
y2#=Object Position Y(obj1)
z2#=Object Position Z(obj1)
endif
endcase
case 1
if obj1<>0
x1#=Camera Position X(cam)
y1#=Camera Position Y(cam)
z1#=Camera Position Z(cam)
x2#=Object Position X(obj1)
y2#=Object Position Y(obj1)
z2#=Object Position Z(obj1)
endif
endcase
endselect
dist# = Dist(x1#,x2#,y1#,y2#,z1#,z2#)
endfunction dist#
Function Dist(x1#,x2#,y1#,y2#,z1#,z2#)
Set Vector3 1,x1#-x2#,y1#-y2#,z1#-z2#
rdist#=Length Vector3(1)
EndFunction rdist#
function objfacing(obj)
ang# = object angle y(obj)
if ang#=-0 then ang#=0
endfunction ang#
function camfacing(cam)
ang# = camera angle y(cam)
if ang#=-0 then ang#=0
endfunction ang#
CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/