@Satchmo
Before I get into that, here's a modification to your source that should help speed things up a bit. You have a loop after your is visible routine:
for n = 3000 to zombobj
move object n,2
next n
You can eliminate this loop by combining it into the is visible routine. With an ELSE condition, you can move a zombie if it is visible or not without haveing to iterate through all of the zombies a second time:
if aitimer = 0
for zombie=3000 to zombobj
if object in screen(zombie)=1
show object zombie
else
hide object zombie
endif
if object visible(zombie) > 0
position object 10000,object position x(zombie),50,object position z(zombie)
set object to object orientation 10000,zombie
move object 10000,40
updateObjectDBC(zombobj)
bang=intersectObjectDBC(0,0,object position x(zombie),object position y(zombie),object position z(zombie),object position x(10000),object position y(10000),object position z(10000),0)
if bang > 0
if object angle y(zombie) < 313 then yrotate object zombie,object angle y(zombie)+47
if object angle y(zombie) > 313 then yrotate object zombie,object angle y(zombie)+47-360
zombietimer(zombie-3000) = 25
endif
if zombietimer(zombie-3000) = 0 then point object zombie,object position x(9000),object position y(9000),object position z(9000)
if zombietimer(zombie-3000) > 0 then zombietimer(zombie-3000) = zombietimer(zombie-3000) - 1
rem move the visible zombie now
move object zombie,2
else
rem even if the zombie isn't visible we still want to update it's position
move object zombie,2
endif
next zombie
aitimer = 2
endif
Quote: "you mention in the other thread about combining multiple objects into a single object(eg. the scene) to save frames. I am using a editor I made so I can't do this in a 3d modeling app. Are there any commands in DBC that do this?"
Can your modeling app export a Scene as a single object? If so, you may be able to add your houses and trees and stuff to a scene and export it all at once.
In DBC, you would have to add each object as a limb to a single object. And after all of the limbs are added, you make a single mesh from the object and all the limbs, and then make an object from the mesh. The problem is if each object has it's own textures (it's own picture, jpg, bmp, etc), your final object won't be able to utilize them. However, if you didn't combine the limbed object into a single mesh, the individual limbs could be textured with their own images. The problem is, I don't think a limbed object would improve performance.
Anyway, here's an example that uses multiple limbs attached to one object (the green pillars). The subroutine that does this is called _environment_objects: . When you run this, the fps is displayed in the upper left hand corner. Use the mouse to turn and up arrow/down arrow to move:
set display mode 800,600,32
sync on
sync rate 0
autocam off
hide mouse
gosub _init
do
gosub _move_camera
text 0,0,str$(screen fps())
sync
loop
`---------------------------------------------------------------
_init:
randomize timer()
gosub _terrain:
gosub _environment_objects
gosub _player
position camera matx#/2,200,matz#/2
xrotate camera 60
ink rgb(255,255,255),0
return
`----------------------------------------------------------------
_terrain:
mat=1
matx#=3000
matz#=3000
tilex=15
tilez=15
make matrix mat,matx#,matz#,tilex,tilez
randomize matrix mat,20
update matrix mat
return
`----------------------------------------------------------------
_environment_objects:
make object box 1,10,80,10
offset limb 1,0,0,40,0
make mesh from object 1,1
delete object 1
make object 1,1,0
x#=matx#/2
z#=matz#/2
position object 1,x#,0,z#
rem make one solid object out of square pillars
for lm=1 to 300
add limb 1,lm,1
lx#=rnd(int(matx#))-x#
lz#=rnd(int(matz#))-z#
ly#=get ground height(mat,lx#,lz#)
offset limb 1,lm,lx#,ly#,lz#
next lm
`make mesh from object 1,1
`delete object 1
`make object 1,1,0
`delete mesh 1
color object 1,rgb(0,100,0)
rem set the object collision status for these pillars
set object collision on 1
set object collision to polygons 1
sync
return
`----------------------------------------------------------------
_move_camera:
yang#=wrapvalue(yang#+mousemovex())
yrotate camera yang#
newx#=newxvalue(object position x(2),yang#,(upkey()-downkey())*3)
newz#=newzvalue(object position z(2),yang#,(upkey()-downkey())*3)
position object pl,newx#,13+(get ground height(mat,newx#,newz#)),newz#
rem position camera with player but a little behind
cx#=newxvalue(newx#,yang#,-80)
cz#=newzvalue(newz#,yang#,-80)
yrotate object pl,yang#
position camera cx#,200+(get ground height(mat,cx#,cz#)),cz#
return
`----------------------------------------------------------------
_player:
pl=2
gosub _red
make object sphere pl,25
set object collision on pl
set object collision to boxes pl
texture object pl,red
position object pl,matx#/2,13,(matz#/2)+50
return
`----------------------------------------------------------------
_red:
red=2
bmp=1
while bitmap exist(bmp)
inc bmp
endwhile
create bitmap bmp,5,5
ink rgb(255,0,0),0
dot 0,0
`dot 1,1
get image red,0,0,1,2
delete bitmap bmp
return
`----------------------------------------------------------------
Uncomment:
`make mesh from object 1,1
`delete object 1
`make object 1,1,0
`delete mesh 1
and run it again. These lines combine the limbs into one object. The FPS should improve.
Your best bet to improve performance would be to find a way to make your scene as one object in your modeling program or combine groups of your individual objects as one object to reduce the number of individual objects you load into DBC.
If you have to load a bunch of individual objects, you can hide them when they are not in screen just like the zombies.
Enjoy your day.