people,
obviously i'm having a severe headach trying to make my enemy shoot back at me. i'm using the shooting game tutorial in DBC, but i have a problem, the sphere(bullet) dosnt move towards me.
here's the code i constructed:
`creat bullet for player (dummy version)
Make Object Sphere 212,5
Hide Object 212
`creat bullet for enemy (dummy version)
Make Object Sphere 213,10
Hide Object 213
repeat
posx#=object position x(player)
posy#=object position y(player)
posz#=object position z(player)
bX#=Object position X(212)
bY#=Object position Y(212)
bZ#=Object position Z(212)
MbX#=Object position X(213)
MbY#=Object position Y(213)
MbZ#=Object position Z(213)
`ENEMY FOR ROOM 1 (LEVEL 1)
loop object 1501,5,25
set object speed 1501,25
`rem this is a bullet trigged when the left mouse button is pressed
if Mouseclick()=1 and BulletLife=0
position object 212,posx#,posy#+36,posz#
Set object to camera orientation 212
BulletLife =30
Show object 212
Endif
if BulletLife > 0 then gosub Shootbullet
If EnemyBulletLife > 0 then Gosub EnemyShootBullet
`when opening room door the enemy point at me with a gun
if door7=1
show object 1511
loop object 1511,10,10
set object speed 701,25
hide object 1501
stop object 1501
point object 1511,posx#,32,posz#
Position object 213,-1079,32,-447
Set object to object orientation 213,1511
`goto enemyshootbullet subroutine
EnemyBulletLife =500
show object 213
else
stop object 1511
hide object 1511
show object 1501
loop object 1501,5,25
set object speed 1501,25
endif
Shootbullet:
`if the bullet is alive then move it
If BulletLife > 0
Dec BulletLife
Move object 212,90
if sqrt((wx# - bX#)^2 + (wy# - bY#)^2 + (wz# - bZ#)^2) < 20
print "THE ENEMY IS HIT"
hit=1
BulletLife = 0
Endif
`if the bullet is not alive then hide it
If BulletLife = 0 then Hide object 212
Endif
return
Rem Shoot Monster bullet
EnemyShootBullet:
Dec EnemyBulletLife
Move object 213,12
Show object 213
if Sqrt((posx# - MbX#)^2 + (posy#+25 - MbY#)^2 + (posz# - MbZ#)^2)<20
enemyBulletLife = 0
endif
Return
i sure need some help with this, its a little complicated, and i'm still not used to the language very much.
thankx for advance
‘Those who ignore the lessons of the past are doomed to repeat them’ (Napoleon)