my code:
global t as integer
global charposx as float
global charposy as float
global charposz as float
global enemyposx as float
global enemyposz as float
make object cube 1,3
do
camera_stuff(charposx,charposy,charposz)
move_char()
char_pos(charposx,charposy,charposz)
make_enemy(t)
loop
function char_pos(charposx,charposy,charposz)
charposx= object position x(1)
charposy= object position y(1)
charposz= object position z(1)
endfunction
function camera_stuff(charposx,charposy,charposz)
position camera charposx,charposy+5,charposz-5
endfunction
function make_enemy(t)
for t = 2 to 5
if object exist(t)=0
make object sphere t,2
position object t,rnd(10),0,rnd(10)
endif
kill_enemy(enemyposx,enemyposz,charposx,charposz,t)
next t
endfunction
function kill_enemy(enemyposx,enemyposz,charposx,charposz,t)
enemyposx=object position x(t)
enemyposz=object position z(t)
if abs(charposx-enemyposx)<1.5 and abs(charposz-enemyposz)<1.5
delete object t
endif
endfunction
function move_char()
if upkey()=1 then move object 1,.1
if downkey()=1 then move object 1,-.1
if rightkey()=1 then turn object right 1,.1
if leftkey()=1 then turn object left 1,.1
endfunction
i know my camera movent sucks but for this purpose it works.
it wont delete the enimies you can pass right thorugh them
edited: globaled t