I rewrote my ENTIRE game and for some reason the camera is going nuts. Can someone please tell me why?
Rem Project: 3dhptest
Rem Created: Sunday, August 08, 2010
Rem ***** Main Source File *****
sync on : sync rate 60
autocam off
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
#constant healthtube 1
#constant healthbarleftside 2
#constant healthbarrightside 3
#constant healthbar 4
#constant playerid 1
#constant obj 2
#constant obj2 3
#constant obj3 4
#constant enemyid 5
#constant healthbarid 6
#constant magicbarid 7
#constant magicbar 8
dim menuImage(20)
menuImage(healthtube)=find free image(healthtube,100000)
menuImage(healthbarleftside)=find free image(healthbarleftside,100000)
menuImage(healthbarrightside)=find free image(healthbarrightside,100000)
menuImage(healthbar)=find free image(healthbar,100000)
menuImage(magicbar)=find free image(magicbar,100000)
dim Object(20) as player
Object(playerid).id=find free object(playerid,100000)
Object(obj).id=find free object(obj,100000)
Object(obj2).id=find free object(obj2,100000)
Object(obj3).id=find free object(obj3,100000)
Object(playerid).actualhealth#=100001
Object(playerid).health# = Object(playerid).actualhealth#
Object(playerid).maxhealth# = 100001
Object(playerid).actualmagic#=100001
Object(playerid).magic# = Object(playerid).actualmagic#
Object(playerid).maxmagic# = 100001
Object(playerid).X# = 0.0
Object(playerid).Y# = 1.0
Object(playerid).Z# = 0.0
if Object(playerid).magic#>Object(playerid).maxmagic# then Object(playerid).magic#=Object(playerid).maxmagic#
if Object(playerid).health#>Object(playerid).maxhealth# then Object(playerid).health#=Object(playerid).maxhealth#
dim Object2(20) as enemy
Object2(enemyid).id=find free object(enemyid,100000)
Object2(enemyid).actualhealth#=10000
Object2(enemyid).health#=Object2(enemyid).actualhealth#
Object2(enemyid).maxhealth# = 2000000.0
Object2(enemyid).actualmagic#=10000
Object2(enemyid).magic#=Object2(enemyid).actualmagic#
Object2(enemyid).maxmagic# = 2000000.0
Object2(enemyid).X# = 0.0
Object2(enemyid).Y# = 1.0
Object2(enemyid).Z# = 0.0
global u#
global v#
LoadGame()
do
set camera to follow object position x(Object(playerid).id),object position y(Object(playerid).id),object position z(Object(playerid).id),0,4,2,20,1
move object up Object(playerid).id,(keystate(16)-keystate(18))*.1
`Update and position enemy health
if GetDist(0,0,Object(playerid).id,Object2(enemyid).id)<10 and GetDist(1,0,Object(obj).id,0)>1.6
position object Object2(enemyid).id,object position x(Object2(enemyid).id),object position y(Object2(enemyid).id) + (object size y(Object2(enemyid).id)+1)/2.0,object position z(Object2(enemyid).id)
lock object on Object2(enemyid).id
Show Object Object2(enemyid).id
else
hide Object Object2(enemyid).id
endif
move object Object(playerid).id,(keystate(17)-keystate(31))*.1
turn object left Object(playerid).id,(keystate(30)-keystate(32))*1
`if object visible(Object(playerid).id)
if keystate(44) and (Object(playerid).health# > 0.0)
dec Object(playerid).health#,100
if Object(playerid).health#>Object(playerid).maxhealth#
Object(playerid).health#=Object(playerid).maxhealth#
endif
endif
if keystate(45) and (Object(playerid).health# < Object(playerid).maxhealth#)
inc Object(playerid).health#,100
if Object(playerid).health#<0
Object(playerid).health#=0
endif
endif
`endif
if GetDist(0,0,Object(playerid).id,Object2(enemyid).id)<10 and GetDist(1,0,Object(obj).id,0)>1.6
`rotate object p.id+1,0,camera angle y(),0
`rotate object obj,0,camera angle y(),0
`rotate object obj2,0,camera angle y(),0
`rotate object obj3,0,camera angle y(),0
`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 Object(playerid).id
Show Object Object(obj).id
Show Object Object(obj2).id
Show Object Object(obj3).id
else
hide Object Object(playerid).id
hide Object Object(obj).id
hide Object Object(obj2).id
hide Object Object(obj3).id
endif
theobj = Object(healthbarid).id
twodorthreed=0
posx=0
posy=10
id=menuImage(healthbar)
x=0
y=0
width=100
height=10
P#=Object(playerid).health#
c1=rgbalpha(255,0,0,255)
c2=rgbalpha(255,255,0,255)
max#=Object(playerid).maxhealth#
CreateBar(theobj,twodorthreed,posx,posy,id,x,y,width,height,P#,c1,c2,max#)
theobj = Object(magicbarid).id
twodorthreed=0
posx=0
posy=0
id=menuImage(magicbar)
x=0
y=20
width=100
height=10
P#=Object(playerid).magic#
c1=rgbalpha(68,207,0,255)
c2=rgbalpha(68,207,255,255)
max#=Object(playerid).maxmagic#
CreateBar(theobj,twodorthreed,posx,posy,id,x,y,width,height,P#,c1,c2,max#)
center text screen width()/2,screen height()/2,"camx:"+str$(camera position x())
center text screen width()/2,screen height()/2+20,"camy:"+str$(camera position y())
center text screen width()/2,screen height()/2+40,"camz:"+str$(camera position z())
sync
loop
function load_objects()
`PLAYER
make object cube Object(playerid).id,1
`ENEMY
make object cube Object2(enemyid).id,1
`PLAYER HEALTH
Make Object Plain Object(obj).id,1.25,.1
set object transparency Object(obj).id,1
fix object pivot Object(obj).id
position object Object(obj).id,0,0,10
set object light Object(obj).id,0
SET OBJECT FILTER Object(obj).id,0
set object smoothing Object(obj).id,100
CreateBar(Object(obj).id,1,0,0,Object(playerid).id,0,0,100,10,Object(playerid).health#,rgbalpha(255,0,0,255),rgbalpha(255,255,0,255), Object(playerid).maxhealth#)
hide object Object(obj).id
`PLAYER MAGIC
Make Object Plain Object(obj2).id,1.25,.1
set object transparency Object(obj2).id,1
fix object pivot Object(obj2).id
position object Object(obj2).id,0,4,2
set object light Object(obj2).id,0
SET OBJECT FILTER Object(obj2).id,0
set object smoothing Object(obj2).id,100
CreateBar(Object(obj2).id,1,0,0,Object(playerid).id,0,0,100,10,Object(playerid).magic#,rgbalpha(68,207,0,255),rgbalpha(68,207,255,255), Object(playerid).maxmagic#)
hide object Object(obj2).id
`ENEMY HEALTH
Make Object Plain Object(obj3).id,1.25,.1
set object transparency Object(obj3).id,1
fix object pivot Object(obj3).id
position object Object(obj3).id,0,0,5
set object light Object(obj3).id,0
SET OBJECT FILTER Object(obj3).id,0
set object smoothing Object(obj3).id,100
CreateBar(Object(obj3).id,1,0,0,Object2(enemyid).id,0,0,100,10,Object2(enemyid).health#,rgbalpha(255,0,0,255),rgbalpha(255,255,0,255), Object2(enemyid).maxhealth#)
hide object Object(obj3).id
endfunction
Function LoadGame()
Progress("Loaded "+str$(1.0/20.0)+"%",1.0/20.0)
cls
load_images(menuImage(healthtube),menuImage(healthbarleftside),menuImage(healthbarrightside))
Progress("Loaded "+str$(2.0/20.0)+"%",2.0/20.0)
cls
load_objects()
Progress("Loaded "+str$(3.0/20.0)+"%",3.0/20.0)
cls
make mesh from object 1,Object(obj).id
Progress("Loaded "+str$(4.0/20.0)+"%",4.0/20.0)
cls
make mesh from object 2,Object(obj2).id
Progress("Loaded "+str$(5.0/20.0)+"%",5.0/20.0)
cls
make mesh from object 3,Object(obj3).id
Progress("Loaded "+str$(6.0/20.0)+"%",6.0/20.0)
cls
make vector3 1
Progress("Loaded "+str$(7.0/20.0)+"%",7.0/20.0)
set text font "MS Gothic"
set text size 10
set text to bold
EndFunction
FUNCTION Progress(t$,prog#)
if prog#>100.0 then prog#=100.0
prog_x=(screen width()/2)-128
prog_y=(screen height()/2)
ink rgb(255,255,255),0
center text prog_x+128,prog_y-16,t$
ink rgb(16,16,16),0
box prog_x-1,prog_y-1,prog_x+257,prog_y+17
ink rgb(255,16,16),0
box prog_x-1,prog_y-1,prog_x+1+(prog#*256),prog_y+17
sync
ENDFUNCTION
function round(n#,r)
n#= n#/r
n= int(n#+n#)-int(n#)
n= n*r
endfunction n
function load_images(id1,id2,id3)
load image "tube8.png", id1
load image "circle.png", id2
load image "circle.png", id3
endfunction
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(theobj,twodorthreed,posx=0,posy=0,id,x,y,width,height,P#,c1,c2,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, c2,c1,c2,c1
box x+seg, y, x+seg+seg, y+height, c2,c1,c2,c1
box x+seg+seg, y, x+width, y+height, c2,c1,c2,c1
` 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
box x, y, x+width, y+height*0.5, c2,c1,c2,c1
ink rgb(255,255,255),0
center text width/2,0,getnumber(int(P#*max#))+"/"+getnumber(int(max#))
if twodorthreed=0
GET IMAGE id,0,0,width,height,1
set current bitmap 0
paste image id,posx,posy
else
GET IMAGE id,0,0,width,height,1
set current bitmap 0
if object exist(obj)
texture object obj,id
else
exitfunction
endif
endif
endfunction
function getnumber(num)
n$=str$(num)
if num>999
n=num/1000
if n>999
m=n/1000
leng=len(str$(m))
re$=mid$(n$,leng+1)+mid$(n$,leng+2)
re$=mid$(n$,2)+mid$(n$,3)
r#=val(re$)
if r#>0.0
re$="."+re$
else
re$=""
endif
s$=str$(m)+re$+"M"
else
leng=len(str$(n))
re$=mid$(n$,leng+1)+mid$(n$,leng+2)
r#=val(re$)
if r#>0.0
re$="."+re$
else
re$=""
endif
s$=str$(n)+re$+"K"
endif
else
s$=str$(num)
endif
endfunction s$
function glue_object_to_object(a,b)
`get start and end point offsets
`start point
EZro_ObjFindOffsetFromPoint b, object position x(a),object position y(a),object position z(a)
x1#=EZro_GetOffsetX()
y1#=EZro_GetOffsetY()
z1#=EZro_GetOffsetZ()
`end point
move object a, 1
EZro_ObjFindOffsetFromPoint b, object position x(a),object position y(a),object position z(a)
x2#=EZro_GetOffsetX()
y2#=EZro_GetOffsetY()
z2#=EZro_GetOffsetZ()
`position child
position object a, x1#,y1#,z1#
`point at end point
point object a, x2#,y2#,z2#
`glue to main limb
glue object to limb a, b, 0
endfunction
function GetDist(camon,cam,myobj1,myobj2)
select camon
case 0
if myobj1<>0 and myobj2<>0
x1#=Object Position X(myobj2)
y1#=Object Position Y(myobj2)
z1#=Object Position Z(myobj2)
x2#=Object Position X(myobj1)
y2#=Object Position Y(myobj1)
z2#=Object Position Z(myobj1)
endif
endcase
case 1
if myobj1<>0
x1#=Camera Position X(cam)
y1#=Camera Position Y(cam)
z1#=Camera Position Z(cam)
x2#=Object Position X(myobj1)
y2#=Object Position Y(myobj1)
z2#=Object Position Z(myobj1)
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#
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/