This is a small improvement on the usual monster array i have shown before.
Questions about Types and OOP like structures pop up every now and then.
it also displays some function use for output info
I also added a small silly AI feature so they dont just stand there with no collision.
click either code snippet box to access it
sync on : sync rate 60
set text size 14 : set text font "verdana"
ink rgb(255,255,255),1
make matrix 1,100,100,10,10
position matrix 1,-50,0,-50
maxM = 10
TYPE Monster
NUM AS INTEGER
NAME AS STRING
HPS AS INTEGER
x# as FLOAT
y# as FLOAT
z# as FLOAT
ENDTYPE
dim Monster(maxM) as Monster
for i = 1 to maxM
Monster(i).NUM=i
Monster(i).NAME="orc "+STR$(i)
Monster(i).HPS= 4 + rnd(7)+1
Monster(i).x#=1.0*i
Monster(i).y#=0.0
Monster(i).z#=1.0*i
make object cube Monster(i).NUM,1
position object Monster(i).NUM,Monster(i).x#,Monster(i).y#,Monster(i).z#
color object i,rgb(rnd(255),rnd(255),rnd(255))
next i
position camera 0,25,-6
point camera 0,0,0
disable escapekey
while escapekey()=0
for i = 1 to maxM
D = rnd(2)
if D = 0
turn object left i,3
endif
if D = 1
turn object right i,3
endif
move object i,0.1
next i
point camera object position x(1),object position y(1), object position z(1)
DisplayInfo(maxM)
fastsync
endwhile
delete matrix 1
for i = 1 to maxM
delete object Monster(i).NUM
next i
undim Monster(maxM)
end
function DisplayInfo(maxM)
for i = 1 to maxM
center text object screen x(i),object screen y(i),""+Monster(i).NAME
center text object screen x(i),object screen y(i)+15,"hps:"+STR$(Monster(i).HPS)
next i
endfunction