Function Collision(BulletX#,BulletY#,BulletZ#,enemy,enemylife,pistol)
EnemyX#=Object position X(enemy)
EnemyY#=object position Y(enemy)
EnemyZ#=object position Z(enemy)
maxdist=150*150
dx#=BulletX#-EnemyX#
dy#=BulletY#-EnemyY#
dz#=BulletZ#-EnemyZ#
collide=((dx#*dx#)+(dy#*dy#)+(dz#+dz#))
If pistol=1
If collide<maxdist
enemylife=enemylife-0.25
endif
else
if pistol=0
if collide<maxdist
enemylife=enemylife-0.50
endif
endif
endif
endfunction enemylife
Some questions and thoughts (I can't check any of these out from my location)
1. Shouldn't collide=((dx#*dx#)+(dy#*dy#)+
(dz#+dz#)) be +(dz#*dz#)
2. Shouldn't enemylife, be enemylife# if you are subtracting 0.5?
3. Is there any performance gain if data remains of the same type. for example having collide be collide# and maxdist maxdist#?
4. What about making the maxdist a constant or just taking out the multiplication operation (how much performance gain), or just making it maxdist#= 22500.0
5. Is there any gain from checking against 0 first, are the only choices values for pistol 1 and 0?, eliminating the if after the else, and/or replacing if collide<maxdist with with if collide-maxdist>0. I'm not thinking to sharply right now, but I'm sure there is still a better way to code that if, and it should be unecessary to check the value of collide-maxdist twice.
if pistol=0
if collide-maxdist>0
enemylife#=enemylife#-.50
endif
else
if collide-maxdist<0
enemylife#=enemylife#-.25
endif
endif
6. What's faster in DBC?
enemylife#=enemylife#-.25
decrementing enemy life by .25 (dec enemylife# .25)
or is there a enemylife# -=.25
I'll have to try these when I get home
"When I look at that square... I wish FPSC noobs would stay on their side of the forums and stop polluting these boards." - Benjamin